Created
February 15, 2018 00:12
-
-
Save jechasteen/cea3f3735b1c27fd755eb0449951d9b0 to your computer and use it in GitHub Desktop.
Redirects to a random Euler Problem
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
// 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