Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my @n = 20,9,11,0,1,2;
- my %l; %l{@n} = ^@n;
- for @n.end..29_999_999 -> $t {
- if $t == %l{@n[$t]} { # first time spoken
- @n[$t+1] = 0;
- }
- else {
- @n[$t+1] = $t - %l{@n[$t]};
- %l{@n[$t]} = $t;
- }
- %l{@n[$t+1]} //= $t+1;
- }
- say "Part One: " ~ @n[2019];
- say "Part Two: " ~ @n[29_999_999];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement