I just completed "Dive!" - Day 2 - Advent of Code 2021 adventofcode.com/2021/day/2 #AdventOfCode using #rakulang Solutions below. Consider yourself spoiler warned.

11:21 AM · Dec 2, 2021

2
2
0
3
Part 1. my %d = forward => (1,0), up => (0,-1), down => (0,1); say [*] [Z+] "input.txt".IO.lines.map( *.split: ' ' ).map({ %d{ .[0] } >>*>> .[1] }); Note the use hyper operators. andrewshitov.com/2018/10/31/…
0
0
0
1
Part 2. my $aim = 0; my @pos = 0,0; my %d = forward => sub ($v) { @pos[0] += $v; @pos[1] += $aim * $v }, up => sub ($v) { $aim -= $v }, down => sub ($v) { $aim += $v }; %d{ .[0] }( .[1] ) for "input.txt".IO.lines.map( *.split: ' ' ); say [*] @pos; Simple Dispatch
1
0
0
1
I generally try to avoid iterative code these days as it tends to be longer, but here it is easier than carrying arguments around.
0
0
0
1