add tasks starting with a number

This commit is contained in:
Ingy döt Net 2013-04-10 14:23:37 -07:00
parent 9246b988c7
commit 2dd7375f96
204 changed files with 3726 additions and 0 deletions

View file

@ -0,0 +1,19 @@
var
n = 100,
doors = [n],
step,
idx;
// now, start opening and closing
for (step = 1; step <= n; step += 1)
for (idx = step; idx <= n; idx += step)
// toggle state of door
doors[idx] = !doors[idx];
// find out which doors are open
var open = doors.reduce(function(open, val, idx) {
if (val) {
open.push(idx);
}
return open;
}, []);
document.write("These doors are open: " + open.join(', '));