Last active
July 8, 2017 02:07
-
-
Save una-ada/2b8625ba7e690183e5ec3f5a65de4ea9 to your computer and use it in GitHub Desktop.
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
// Set random elements on the page to random colors | |
setInterval(()=>{r=()=>Math.random(),d=document.querySelectorAll('*');d[~~(r()*d.length)].style.background=`hsl(${r()*360},80%,60%)`},10); | |
// Generate an m x n matrix with elements filled in order | |
f=(m,n)=>{for(var a=[],i=0;i<m*n;)(a[~~(i/m)]||(a[~~(i/m)]=[]))[~~(i%m)]=++i;return a} | |
// Maximum value in a multidemnsional array | |
m=(a)=>{return Math.max(...[].concat(...a))} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment