This is a solution to Advent of Code 2025 day 10, written in Raku.
https://adventofcode.com/2025/day/10
Part One
Analyze each machine's indicator light diagram and button wiring schematics. What is the fewest button presses required to correctly configure the indicator lights on all of the machines?
use Test;
#use Grammar::Tracer;
class Machine {
has $.lights;
has @.buttons;
has @.joltages;
}
grammar Machine-grammar {
rule TOP {
<lights> <buttons> <joltages>
{ make Machine.new(
lights => $<lights>.made.trans('.#' => '01').flip.parse-base(2),
buttons => $<buttons>.made,
joltages => $<joltages>.made)
}
}
token lights { '[' ( <[.#]>+ ) ']' { make $/[0].Str } }
token buttons { <button>+ % ' ' { make $<button>>>.made } }
token button { '(' (\d+)+ % ',' ')' { make $/[0]>>.Int } }
token joltages { '{' (\d+)+ % ',' '}' { make $/[0]>>.Int } }
}
sub part-one($input) {
my @machines = $input.IO.lines.map(
-> $line {
Machine-grammar.parse($line).made
});
sub evaluate($target, @values) {
for 1..+@values -> $n {
for @values.combinations($n) -> @candidate {
return $n if $target == [+^] @candidate;
}
}
return False;
}
[+] @machines.map(
-> $m {
my @values = $m.buttons.map(
-> @wiring {
[+] @wiring.map( -> $x { 1 +< $x })
});
evaluate($m.lights, @values);
});
}
is part-one('10-test.txt'), 7, 'test input';
{
say "Part one: ", part-one('10-input.txt');
say "Took " ~ (now - ENTER now).base(10,2) ~ " seconds";
}ok 1 - test input Part one: 578 Took 0.24 seconds
Part Two
Analyze each machine's joltage requirements and button wiring schematics. What is the fewest button presses required to correctly configure the joltage level counters on all of the machines?
It's a WIP….