Created
March 24, 2014 15:33
-
-
Save GZShi/9742586 to your computer and use it in GitHub Desktop.
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
function getRandomPokes(n) { | |
var pokes = []; | |
while(pokes.length < 54) { | |
pokes.push(pokes.length + 1); | |
} | |
pokes.sort(function (a, b) { | |
return Math.random() < 0.5; | |
}); | |
return pokes.slice(0, Math.floor(Math.random() * n) + 1); | |
} | |
function assert(pokes, pokes1) { | |
Array.prototype.push.apply(pokes, pokes1); | |
pokes.sort(function (a, b) { | |
return a > b; | |
}); | |
pokes.map(function (e, i, a) { | |
a[i] = e % 4; | |
}); | |
var aces = 0; | |
var jokes = 0; | |
pokes.every(function (e, i, a) { | |
if(e === 1) { | |
aces++; | |
return true; | |
} else if(e === 14) { | |
jokes++; | |
return true; | |
} else { | |
if(e === a[i-1] || e === a[i-1] + 1) { | |
return true; | |
} else if(e === 2) { | |
if(aces > 0) { | |
aces--; | |
return true; | |
} else if(jokes > 0) { | |
jokes--; | |
return true; | |
} else { | |
return false; | |
} | |
} else { | |
if() | |
} | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment