Skip to content

Instantly share code, notes, and snippets.

@lancetw
Created April 25, 2020 02:25
Show Gist options
  • Save lancetw/10ce2e016913ebf467d1b263b29f1ea8 to your computer and use it in GitHub Desktop.
Save lancetw/10ce2e016913ebf467d1b263b29f1ea8 to your computer and use it in GitHub Desktop.
var alphabetBoardPath=function(f){var g=new Map(Array.from("abcdefghijklmnopqrstuvwxyz").map(function(a,c){return[a,{x:c/5|0,y:c%5|0}]})),d=function(a,c){return 0>=c?"":a.repeat(c)},a={x:0,y:0};return Array.from(f).reduce(function(e,c){var b=g.get(c);e.push(b.y<a.y?d("L",a.y-b.y):"",b.x<a.x?d("U",a.x-b.x):"",b.x>a.x?d("D",b.x-a.x):"",b.y>a.y?d("R",b.y-a.y):"","!");a=b;return e},[]).join("")};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment