Day 19 weirdness
This commit is contained in:
parent
4174f133d0
commit
b5e0e6ca59
@ -1,5 +1,3 @@
|
|||||||
var input = 7;
|
|
||||||
|
|
||||||
var elves = [];
|
var elves = [];
|
||||||
for(var i = 0; i < input; i++){
|
for(var i = 0; i < input; i++){
|
||||||
elves.push(i+1);
|
elves.push(i+1);
|
||||||
@ -9,7 +7,7 @@ var i = 0;
|
|||||||
while(elves.length > 1){
|
while(elves.length > 1){
|
||||||
if(!(elves.length%1000)) console.log(elves.length)
|
if(!(elves.length%1000)) console.log(elves.length)
|
||||||
var toRemove = Math.floor((i + (elves.length/2)))%(elves.length)
|
var toRemove = Math.floor((i + (elves.length/2)))%(elves.length)
|
||||||
//console.log(i, elves[i], elves[toRemove], elves);
|
console.log(i, elves[i], elves[toRemove], elves);
|
||||||
elves.splice(toRemove, 1);
|
elves.splice(toRemove, 1);
|
||||||
if(toRemove > i){
|
if(toRemove > i){
|
||||||
i = (i+1)%elves.length;
|
i = (i+1)%elves.length;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
var input = 3012210;
|
var input = 10000;
|
||||||
|
|
||||||
var elves = [];
|
var elves = [];
|
||||||
for(var i = 0; i < input; i++){
|
for(var i = 0; i < input; i++){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user