
Lobby
Advent of Code 2025 Day 3 Part 1 Considering my options, from worst to best Each line is an ordered list of positive digits. I must identify the largest 2-digit number made from any two digits appearing in order. I can think of a few ways to do this, from brute-force to better. Brute force Compare every possible combination of digits: Set an initial value, max, to 0 For each digit except the last For each subsequent digit If the ordered concatenation of digits is greater than 'max' Update max to reflect this 2-digit number Measuring performance: Given line length, L This will run L + L-1 + L-2 + L-3 + ... times Example: L = 10 - runs 10 times for first number, 9 times for second number, etc. - 55 times Not great. But still should complete quickly even for line lengths less than 100. My puzzle input lines are roughly 40 digits long. Brute force but optimized Compare digit pairings for increasing 10s-place digits Set an initial value, max, to 0 Set an initial value, lower, to 0 Set an in
Continue reading on Dev.to JavaScript
Opens in a new tab




