Day 19 part 1
This commit is contained in:
parent
6f45c42781
commit
a2bbd41f78
19
day19/part1.js
Normal file
19
day19/part1.js
Normal file
@ -0,0 +1,19 @@
|
||||
var input = 3012210;
|
||||
|
||||
var elves = [];
|
||||
for(var i = 0; i < input; i++){
|
||||
elves.push(true);
|
||||
}
|
||||
var i = 0;
|
||||
while(elves.indexOf(true) != -1){
|
||||
while(elves[i] == false){
|
||||
i = (i+1)%(elves.length);
|
||||
}
|
||||
i = (i+1)%(elves.length);
|
||||
while(elves[i] == false){
|
||||
i = (i+1)%(elves.length);
|
||||
}
|
||||
last = i;
|
||||
elves[i] = false;
|
||||
}
|
||||
console.log(last+1);
|
Loading…
x
Reference in New Issue
Block a user