Skip to content

Instantly share code, notes, and snippets.

@zoffixznet

zoffixznet/p6.p6 Secret

Created December 22, 2017 17:20
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/74df6fb0e9478584e6721bfb5331ee84 to your computer and use it in GitHub Desktop.
Save zoffixznet/74df6fb0e9478584e6721bfb5331ee84 to your computer and use it in GitHub Desktop.
use nqp;
nqp::stmts(
(my $ins := nqp::getattr('day_05.input'.IO.slurp.words.map(*.Int).eager.List,
List, '$!reified')),
(my int $index),
(my int $stop = nqp::elems($ins)),
(my int $jump),
(my int $iterations),
nqp::while(
nqp::islt_i($index, $stop),
nqp::stmts(
($jump = nqp::atpos($ins,$index)),
nqp::if(
nqp::isge_i($jump,3),
nqp::bindpos($ins,$index,nqp::sub_i(nqp::atpos($ins,$index),1)),
nqp::bindpos($ins,$index,nqp::add_i(nqp::atpos($ins,$index),1))),
($index = nqp::add_i($index,$jump)),
($iterations = nqp::add_i($iterations, 1)))),
nqp::say($iterations));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment