Skip to content

Instantly share code, notes, and snippets.

@zoffixznet

zoffixznet/p6.p6 Secret

Created December 22, 2017 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zoffixznet/7a66bbbbae5aa70e5c657203c42205c5 to your computer and use it in GitHub Desktop.
Save zoffixznet/7a66bbbbae5aa70e5c657203c42205c5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl6
my int @instructions = 'day_05.input'.IO.lines.map: *.Int;
my int $index = 0;
my int $stop = @instructions.elems;
my int $iterations = 0;
my int $jump;
while $index < $stop {
$jump = @instructions.AT-POS: $index;
$jump >= 3 ?? --@instructions.AT-POS: $index
!! ++@instructions.AT-POS: $index;
$index = $index + $jump;
++$iterations;
}
say $iterations;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment