-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathThe Owls Are Not What They Seem.js
23 lines (18 loc) · 1.07 KB
/
The Owls Are Not What They Seem.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
Description:
To pass the series of gates guarded by the owls, Kenneth needs to present them each with a highly realistic portrait of one. Unfortunately, he is absolutely rubbish at drawing, and needs some code to return a brand new portrait with a moment's notice.
All owl heads look like this:
''0v0''
Such beautiful eyes! However, they differ in their plumage, which is always symmetrical, eg.:
VVHVAV''0v0''VAVHVV
or
YYAYAH8XH''0v0''HX8HAYAYY
So Kenneth needs a method that will take a garble of text generated by mashing at his keyboard (numbers and letters, but he knows how to avoid punctuation etc.) for a bit and give him a symmetrical owl with a lovely little face, with a truly symmetrical plumage made of uppercase letters and numbers.
(To be clear, the acceptable characters for the plumage are 8,W,T,Y,U,I,O,A,H,X,V and M.)
*/
function owlPic(text){
const dict=['8','W','T','Y','U','I','O','A','H','X','V','M']
const left=text.toUpperCase().split('').filter(v=>dict.includes(v)).join('')
const right=left.split('').reverse().join('')
return left+`''0v0''`+right
}