Created
February 12, 2018 15:56
-
-
Save janpaul123/d6169e46c0430149c735dc422d951067 to your computer and use it in GitHub Desktop.
Number of unique corners for given color / dot schemes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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