aboutsummaryrefslogtreecommitdiff
path: root/challenge-091/polettix/perl/ch-2.pl
blob: c3759fd93fb2d2e3aa5a8cb33753f0831c00ff19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/usr/bin/env perl
use 5.024;
use warnings;
use experimental qw< postderef signatures >;
no warnings qw< experimental::postderef experimental::signatures >;

sub jump_game ($N) {
   my $position = 0;
   $position += $N->[$position] while $position < $#$N && $N->[$position];
   return $position == $#$N ? 1 : 0;
}

my @sequence = @ARGV ? @ARGV : (1, 2, 1, 2);
say jump_game(\@sequence);