diff --git a/2016/19/1.pl b/2016/19/1.pl index d30208f..520a47e 100644 --- a/2016/19/1.pl +++ b/2016/19/1.pl @@ -5,7 +5,6 @@ my $input = 3004953; my @elves = 1..$input; while( @elves > 1 ) { - say $elves[0]; push @elves, shift @elves; shift @elves; } diff --git a/2016/19/2.pl b/2016/19/2.pl new file mode 100644 index 0000000..3a4f2d0 --- /dev/null +++ b/2016/19/2.pl @@ -0,0 +1,15 @@ +use 5.20.0; + +my $input = 3004953; + +my @elves = 1..$input; + +my $j; + +while( @elves > 1 ) { + say $elves[0] unless $j++ % 1000; + splice @elves, @elves/2, 1; + push @elves, shift @elves; +} + +say @elves;