Re:Is this prime?
by WA on Tuesday March 08, 2016 @11:30AM
(#11246269)
Ah, you beat me to the minute (game comes with a function is_prime):
[ Parent
| on HN ]
Or, do away with the whole "checking" nonsense:
game.check = function (answer) {
this.streak += 1;
this.next_n();
}
setInterval(function() {
document.querySelector("#yes").click();
}, 0);
document.querySelector("#start").click();
(High score of 15,000!)
Re:Is this prime?
by andrewstuart2 on Tuesday March 08, 2016 @09:44PM
(#11250525)
Why only add 1? Why add anything at all?
game.check = function() {
this.streak = Number.MAX_VALUE;
this.next_n();
};
document.querySelector("#start").click();
document.querySelector("#yes").click();24607 (with the cheat), 621 (without) :D
Fun evening challenge :P
function isPrime(n){
if ((n<=1) || (!n % 2)) {
return false;
}
for (var k = 3; k < Math.round(Math.sqrt(n) + 0.5); k = k+2) {
if (n % k == 0) {
return false;
}
}
return true;
}
var nSpan = $("span#n")
var yesButton = $("button#yes");
var noButton = $("button#no");
var body = $("body");
function solve(){
if (isPrime(parseInt(nSpan.innerHTML)) {
yesButton.click();
} else {
noButton.click();
}
if (body.className != "end") {
setTimeout(solve,0);
}
}
solve();this. IF you cheat, you might as well take the easiest path of all :D