Skip to content

Instantly share code, notes, and snippets.

@janpaul123
Created February 12, 2018 15:56
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 janpaul123/d6169e46c0430149c735dc422d951067 to your computer and use it in GitHub Desktop.
Save janpaul123/d6169e46c0430149c735dc422d951067 to your computer and use it in GitHub Desktop.
Number of unique corners for given color / dot schemes
const uniq = require('lodash/uniq');
function permutations(n, colors, arr) {
if (!n) return [arr];
if (!arr) arr = [];
let ret = [];
for (let i = 0; i < colors; i++) ret = ret.concat(permutations(n - 1, colors, arr.concat([i])));
return ret;
}
console.log(
'Code240 (Dynamicland; per corner):',
permutations(5, 4).filter(colors => uniq(colors).length >= 4).length
);
console.log(
'Paper Programs v1:',
permutations(5, 5).length / 5
);
console.log(
'Double dots with unique corners and each color in a corner at least once:',
permutations(8, 4).filter(colors => uniq(colors).length >= 4).length / 4
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment