Skip to content

Instantly share code, notes, and snippets.

@tokdaniel
Last active February 24, 2021 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tokdaniel/5fd150ab1acd6b354a225e4c9723bf00 to your computer and use it in GitHub Desktop.
Save tokdaniel/5fd150ab1acd6b354a225e4c9723bf00 to your computer and use it in GitHub Desktop.
const range = (m: number, n: number): number[] => Array.from(Array(n - m + 1).keys()).map(n => n + m)
const isEvil = (n: number): boolean => (
n.toString(2).split('').filter((x) => x === '1').length % 2 == 0
)
range(0, 50).filter(isEvil)
// print
console.log(range(0,50).filter(isEvil).join('\n'))
// Compiled
const range = (m, n) => Array.from(Array(n - m + 1).keys()).map(n => n + m);
const isEvil = (n) => (n.toString(2).split('').filter((x) => x === '1').length % 2 == 0);
range(0, 50).filter(isEvil);
// print
console.log(range(0, 50).filter(isEvil).join('\n'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment