Skip to content

Instantly share code, notes, and snippets.

@ab5tract
Last active December 2, 2025 18:26
Show Gist options
  • Select an option

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

Select an option

Save ab5tract/f8acb0519396c763c854727d8525b7be to your computer and use it in GitHub Desktop.
#!/usr/bin/env raku
use v6.d;
my @input = "./day2.input".IO.slurp.split(',');
my $found-ids = SetHash.new;
my $running-total = 0;
for @input.map(*.split('-')) -> (Int() $start, Int() $end) {
print ".";
ID: for $start..$end -> $id {
next if $found-ids{$id};
my $id-chars = $id.comb %% 2 ?? $id.comb / 2 !! ($id.comb / 2).floor;
my @checks = |(1..$id-chars).grep($id.comb %% *);
for @checks -> $c {
my @maybe-match = do if $id ~~ m/^ (\d ** {$c})+ $/ {
$/.values.map(*.Str)
}
if @maybe-match.Set == 1 {
$found-ids.set: $id;
next ID
}
}
}
}
say "\n{ [+] $found-ids.keys }";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment