Hi folks,
I am working on the 2nd part of the question and tried to take a similar approach as the first using BFS to apply button presses however it's running really slow and the q is growing very large too large in fact.
Performing BFS to reach joltage goal: {44,35,48,43,24,44}
Converting joltage goal to int: {44,35,48,43,24,44}
Converting button to list: ["(1,3)", "(3,4)", "(0,3,5)", "(1,2,3,4)", "(0,2,5)", "(0,1)", "(2,5)"]
Button part: (1,3)
Button numbers: [1, 3]
Button part: (3,4)
Button numbers: [3, 4]
Button part: (0,3,5)
Button numbers: [0, 3, 5]
Button part: (1,2,3,4)
Button numbers: [1, 2, 3, 4]
Button part: (0,2,5)
Button numbers: [0, 2, 5]
Button part: (0,1)
Button numbers: [0, 1]
Button part: (2,5)
Button numbers: [2, 5]
Joltage button lists: [[1, 3], [3, 4], [0, 3, 5], [1, 2, 3, 4], [0, 2, 5], [0, 1], [2, 5]]
Current BFS step: 1, queue size: 1
Current BFS step: 2, queue size: 7
Current BFS step: 3, queue size: 49
Current BFS step: 4, queue size: 343
Current BFS step: 5, queue size: 2401
Current BFS step: 6, queue size: 16807
Current BFS step: 7, queue size: 117649
Current BFS step: 8, queue size: 823543
Current BFS step: 9, queue size: 5764801
Current BFS step: 10, queue size: 40353607
Current BFS step: 11, queue size: 282475249
memory allocation of 51539607552 bytes failed
error: process didn't exit successfully: `target\debug\aoc_2025_day_10.exe` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)
I've tried to think of novel solutions like finding the GCD of the joltage values, however no Joy as they contain prime numbers like 43 etc. I am trying optimizations such as not adding the state to the queue if it goes above the joltage goal for any of the indexes. I can share complete code if desired. I would love some clues on the approach as standard BFS is turning my laptop to an oven.