4 ms·
Ah, you beat me to the minute (game comes with a function is_prime): var yes = document.getElementById('yes'), no = document.getElementById('no'),
by WA 11y ago
Ah, you beat me to the minute (game comes with a function is_prime):
var yes = document.getElementById('yes'),
no = document.getElementById('no'),
n = document.getElementById('n'),
start = document.getElementById('start');
function tick() {
console.log('tick');
if (is_prime(n.innerHTML) === 'prime') {
yes.click();
} else {
no.click();
}
window.setTimeout(tick, 500);
}
start.click();
tick();
- mfoy_ 11y agoOr, 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!)
- malka 11y agothis. IF you cheat, you might as well take the easiest path of all :D
- rMBP 11y ago"Inspect Element"
- gfmio 11y ago24607 (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();
- andrewstuart2 11y agoWhy 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();