this post was submitted on 03 Dec 2023
95 points (92.8% liked)

Advent Of Code

857 readers
79 users here now

An unofficial home for the advent of code community on programming.dev!

Advent of Code is an annual Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

AoC 2024

Solution Threads

M T W T F S S
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 18 20 21 22
23 24 25

Rules/Guidelines

Relevant Communities

Relevant Links

Credits

Icon base by Lorc under CC BY 3.0 with modifications to add a gradient

console.log('Hello World')

founded 1 year ago
MODERATORS
 

Thanks Homer.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 4 points 1 year ago

I don't want to read the number string from both left to right and Ruth to left. So, I

  1. iterate through each row and read the number string from left to right
  2. Store each number along with its cell range. ie: 467 is 0-2.
  3. Then from each symbol, find out if the position of the symbol +/-1 falls into any range. If so then sum that number.