This file contains 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
// some one-liner functions i wrote and condensed as far as i could :) | |
// warning! some of these pollute the global namespace! | |
// palindrome checker - 51 chars - string => boolean | |
([...s])=>s.reduce((a,v,i)=>a*=s.reverse()[i]==v,1) | |
// roman numeral generator up to 3999 - 138 chars - integer => string | |
n=>Object.entries({M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1}).map(([k,v])=>(a=n,n%=v,k.repeat(a/v))).join`` | |
// shortest vowel distance - 127 chars - lowercase string => array |