Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
1 to 50 solver
// http://zzzscore.com/1to50/en
function clickAllSquares(){
var clickedCount=0;
for(currentNum=1;currentNum<51;currentNum++){
console.log("processing "+currentNum);
cells = document.querySelectorAll("div#grid div");
for(var cellindex=0;cellindex<cells.length;cellindex++){
var foundInt = parseInt(cells[cellindex].innerText);
if(foundInt==currentNum){
cells[cellindex].dispatchEvent(new Event('tap', { 'bubbles': true }));
clickedCount++;
break;
}
}
}
return clickedCount;
}
// need to pass some control back to the browser to re-render so using setInterval
// to give the browser time to act
function initiateClick(){
if(clickAllSquares()>0){
window.setInterval(initiateClick,1);
}
}
initiateClick();
// TODO: this could be much more efficient
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment