Skip to content

Instantly share code, notes, and snippets.

@jechasteen
Created February 15, 2018 00:12
Show Gist options
  • Save jechasteen/cea3f3735b1c27fd755eb0449951d9b0 to your computer and use it in GitHub Desktop.
Save jechasteen/cea3f3735b1c27fd755eb0449951d9b0 to your computer and use it in GitHub Desktop.
Redirects to a random Euler Problem
// To use, go to https://projecteuler.net/archives
// then open the developer console and paste the contents of this file
// This will automatically direct to a random problem.
function getTotalProbs(){
var p = document.querySelector( "p" ).textContent;
var total = "";
for ( var i = 0; i < p.length; i++ ) {
if ( p[i] === "1" ){
for ( var j = i + 5; p[j] != "."; j++ ) {
total += p[j];
}
return Number( total );
}
}
}
window.location.href = "https://projecteuler.net/problem="
+ Math.floor( Math.random() * getTotalProbs() );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment