Skip to content

Instantly share code, notes, and snippets.

@robhol
Created October 23, 2015 21:31
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 robhol/dc0c2201a9935576bd21 to your computer and use it in GitHub Desktop.
Save robhol/dc0c2201a9935576bd21 to your computer and use it in GitHub Desktop.
inp => inp.split('')
.map( (c, i) => [i > 0 ? lookup[inp.charAt(i-1)] : 0, lookup[c] ] )
.map( x => [ x[0] < x[1] ? x[0] : 0, x[1] ] )
.reduce( (pv, x) => pv + x[1] - 2 * x[0], 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment