Created
April 27, 2013 15:38
-
-
Save tmshv/5473527 to your computer and use it in GitHub Desktop.
dropquest 2012 step1 bruteforcer
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
var n1; | |
var n2; | |
var n3; | |
var n4; | |
var n5; | |
//The product of the first two digits is 24. | |
function rule1(){ | |
return (n1 * n2) == 24; | |
} | |
//The fourth digit is half of the second digit. | |
function rule2(){ | |
return n4 == (n2/2); | |
} | |
//The sum of the last two digits is the same as the sum of the first and third digits. | |
function rule3(){ | |
return (n4 + n5) == (n1 + n3); | |
} | |
//The sum of all the digits is 26. | |
function rule4(){ | |
return (n1 + n2 + n3 + n4 + n5) == 26; | |
} | |
//The second digit is greater than the last digit. | |
function rule5(){ | |
return (n2 + n3) > n5; | |
} | |
for(var i=0; i<100000; i++){ | |
var num = i; | |
var d1 = Math.floor(num / 10000) * 10000; | |
num -= d1; | |
var d2 = Math.floor(num / 1000) * 1000; | |
num -= d2; | |
var d3 = Math.floor(num / 100) * 100; | |
num -= d3; | |
var d4 = Math.floor(num / 10) * 10; | |
num -= d4; | |
var d5 = num; | |
n1 = d1 / 10000; | |
n2 = d2 / 1000; | |
n3 = d3 / 100; | |
n4 = d4 / 10; | |
n5 = d5;// / 1; | |
if(rule1() && rule2() && rule3() && rule4() && rule5()){ | |
console.log(i); | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment