Skip to content

Instantly share code, notes, and snippets.

@vulpesfoxnik
Created June 29, 2017 23:44
Show Gist options
  • Save vulpesfoxnik/d49ecc85ab26c39b26506f88b93f0744 to your computer and use it in GitHub Desktop.
Save vulpesfoxnik/d49ecc85ab26c39b26506f88b93f0744 to your computer and use it in GitHub Desktop.
Distribution calculation method for the Peak game
(()=>{
const distribution = [8,12,20,12,10,20,17,1];
console.log(distribution.reduce((x,y)=>x+y, 0));
return (distribution.reduce(function (array, cur){
const previous = array[array.length-1]|| []
, previousRemoved = previous[0]||0
, previousRemaining = previous[1]||100;
return array.concat([[cur, previousRemaining - previousRemoved]]);
}, []).map((x)=>x.join("/")).join(', '));
})();
/*
8/100, 12/92, 20/80, 12/60, 10/48, 20/38, 17/18
2/25, 3/23, 1/4 , 2/10, 5/24, 10/19, 17/18
2d13, 2d12, 1d4, 1d10, 1d24, 2d10, 1d18
3<, 5<, 1<, 2<, 5<, 11<, =18
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment