Last active
January 29, 2021 03:58
-
-
Save on3dd/2a550cd1e443043890aca8c4d40eb1b2 to your computer and use it in GitHub Desktop.
fp flavored solutions for https://youtu.be/XlI1zoH2gjU
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const unriddle_me_1 = (str: string): string => { | |
const length = Math.ceil(str.length / 2); | |
const [a, b] = [str.slice(0, length), str.slice(length)]; | |
return a.split('').reduce((acc, curr, idx) => { | |
return acc + curr + (b[idx] || ''); | |
}, ''); | |
}; | |
console.log( | |
unriddle_me_1('Wligo ae n eeoigsfwrakn nwtraddvlpn otae'), | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const unriddle_me_2 = (str: string): string => { | |
return str.split('').reduce((acc, curr, idx) => { | |
return idx % 2 ? acc : acc + curr; | |
}, ''); | |
}; | |
console.log( | |
unriddle_me_2( | |
'f rqofmv fa gstpheuc ikfuiyctaqtaixocnv fagrhey euaksiy', | |
), | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const unriddle_me_3 = (str: string): string => { | |
return str | |
.slice(2) | |
.split('') | |
.reduce((acc, curr, idx) => { | |
return idx % 3 ? acc : acc + curr; | |
}, ''); | |
}; | |
console.log( | |
unriddle_me_3( | |
` gihjfkl oib 4o6jtaxhdb gha trh?e't r3fesrqqoa zs efgngy.`, | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment