adventofcode/2017/05/maze2.pl

14 lines
213 B
Perl
Raw Normal View History

2017-12-05 17:47:22 +00:00
my @maze = <>;
my $position = 0;
my $steps = 0;
2017-12-28 17:15:15 +00:00
my $p;
2017-12-05 17:47:22 +00:00
while( $position < @maze ) {
$steps++;
my $i = $position;
2017-12-28 17:15:15 +00:00
$position += $p = $maze[$position];
$maze[$i] += $p > 2 ? -1 : 1;
2017-12-05 17:47:22 +00:00
}
2017-12-28 17:15:15 +00:00
print $steps;