Created
June 28, 2014 17:21
-
-
Save quentint/6194d41c88d790df326f to your computer and use it in GitHub Desktop.
Gros caca kilométrique
This file contains hidden or 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
/** | |
* Gros caca kilométrique | |
*/ | |
background: #f06; | |
background: linear-gradient(45deg, #f06, yellow); | |
min-height: 100%; |
This file contains hidden or 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
<!-- content to be placed inside <body>…</body> --> |
This file contains hidden or 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
// Gros caca | |
var min=12, max=120; | |
var currentTotal=0; | |
var lines=[]; | |
function kmToVal(km) { | |
return .491*km; | |
} | |
function addKm(km) { | |
currentTotal+=km; | |
lines.push({km:km, val:kmToVal(km)}); | |
} | |
function grosCaca(total) { | |
console.log('—'); | |
while (currentTotal<total) { | |
var currentVal=min+max*Math.random(); | |
if (currentTotal+currentVal>total) { | |
addKm(total-currentTotal); | |
break; | |
} | |
addKm(currentVal); | |
} | |
} | |
grosCaca(450); | |
console.table(lines); |
This file contains hidden or 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
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"javascript"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment