copy pasting the rules from last year’s thread:

Rules: no spoilers.

The other rules are made up aswe go along.

Share code by link to a forge, home page, pastebin (Eric Wastl has one here) or code section in a comment.

You are viewing a single thread.
View all comments
3 points
*

Day 4 - Ceres Search

discussion

There’s probably a smarter way to do this…

For part 1, I dumped everything into a matrix. Then I scanned it element by element. If I found an X, I searched in 8 directions from there and counted up if I found M A S in sequence.

For part 2 I searched for an A, checked each diagonal corner, and counted up if the opposites were M S or S M

https://github.com/gustafe/aoc2024/blob/main/d04-Ceres-Search.pl

permalink
report
reply
1 point
*
discussion

Same, except in 4-1 I used a recursive function to traverse each direction according to the offset decided by the selected direction (like SW is row++,col–) , due to functional programming induced brain damage.

Would have been pretty useful too if 4-2 turned out to be about finding longer patterns, instead of smaller and in half the directions.

permalink
report
parent
reply

NotAwfulTech

!notawfultech@awful.systems

Create post

a community for posting cool tech news you don’t want to sneer at

non-awfulness of tech is not required or else we wouldn’t have any posts

Community stats

  • 345

    Monthly active users

  • 55

    Posts

  • 151

    Comments

Community moderators