Created
October 26, 2014 13:11
-
-
Save yohanes/1634d1a6e58e67a2a729 to your computer and use it in GitHub Desktop.
Secuinside 2014
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 (rand) { | |
function stage1() { | |
var a = Array.apply(null, | |
new Array(Math.floor(Math.random() * 20) + 10)).map(function () {return Math.random() * 0x10000;}); | |
var b = rand(a.length); | |
if (!Array.isArray(b)) { | |
print("You're a cheater!"); | |
return false; | |
} | |
if (b.length < a.length) { | |
print("hmm.. too short.."); | |
for (var i = 0, n = a.length - b.length; i < n; i++) { | |
delete b[b.length]; | |
b[b.length] = [Math.random() * 0x10000]; | |
} | |
} else if (b.length > a.length) { | |
print("hmm.. too long.."); | |
for (var i = 0, n = b.length - a.length; i < n; i++) | |
Array.prototype.pop.apply(b); | |
} | |
for (var i = 0, n = b.length; i < n; i++) { | |
if (a[i] != b[i]) { | |
print("ddang~~"); | |
return false; | |
} | |
} | |
return true; | |
} | |
function stage2() { | |
var a = Array.apply(null, new Array((myRand() % 20) + 10)).map(function () {return myRand() % 0x10000;}); | |
var b = rand(a.length); | |
if (!Array.isArray(b)) { | |
print("You're a cheater!"); | |
return false; | |
} | |
if (b.length < a.length) { | |
print("hmm.. too short.."); | |
for (var i = 0, n = a.length - b.length; i < n; i++) { | |
delete b[b.length]; | |
b[b.length] = [Math.random() * 0x10000]; | |
} | |
} else if (b.length > a.length) { | |
print("hmm.. too long.."); | |
for (var i = 0, n = b.length - a.length; i < n; i++) | |
Array.prototype.pop.apply(b); | |
} | |
for (var i = 0, n = b.length; i < n; i++) { | |
if (a[i] != b[i]) { | |
print("ddang~~"); | |
return false; | |
} | |
} | |
return true; | |
} | |
print("stage1"); | |
if (!stage1()) | |
return; | |
print("stage2"); | |
if (!stage2()) | |
return; | |
print("awesome!"); | |
return flag; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment