Skip to content

Instantly share code, notes, and snippets.

@ab5tract
Last active December 4, 2025 16:03
Show Gist options
  • Select an option

  • Save ab5tract/7f5410af74e11e056f77fd0a8a1117f5 to your computer and use it in GitHub Desktop.

Select an option

Save ab5tract/7f5410af74e11e056f77fd0a8a1117f5 to your computer and use it in GitHub Desktop.
use v6.*;
my @input = "day3.input".IO.lines;
#my @input = [ "23191392", "14928318" ];
my $total = 0;
for @input.map(*.comb>>.Int) -> @i {
my ($idx,$first) = @i.max(:kv);
my $second;
if $idx == @i - 1 {
$second = $first;
$first = @i[^$idx].max;
} else {
$second = @i[($idx+1)..*].max;
}
$total += "$first$second".Int;
print ".";
}
say "\n$total"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment