2024 Day 4: Ceres Search

Part 1 went smoothly for me, but I had to take a phone call and will finish part 2 tomorrow finished a bit late. Opening the thread for discussion now.

Part 2 tripped me up because I was imagining some crazy matrix transform but it turned out to be much simpler.

1 Like

@JeremyGrosser I really like your Coordinate + Direction approach; this makes it very readable. :slightly_smiling_face:
(My checks are much less pretty.)

1 Like

Spent a long time debugging part 2 until I realized you cannot have horizontal or vertical MAS like

.M.
MAS
.S.

Today was a bit mundane. It reminded me of teaching Pascal to first year students. I used a vector of unbounded strings, and then scan in all 8 directions for XMAS. The second assignment was even simpler.

The first week is usually pretty easy… It’s gonna hurt after day 10 :slight_smile:

1 Like

Seems to me that most of the challenges results in a Command Line Interface app.
I’ve done this one just to check if bbt was useful in this context, and it is.
I could build gradually the exe, and pass the test at first try.

One of the test, to give you an idea:

## Scenario example 2
- Given the file `input_ex2`
```
....XXMAS.
.SAMXMS...
...S..A...
..A.A.MS.X
XMASAMX.MM
X.....XA.A
S.S.S.S.SS
.A.A.A.A.A
..M.M.M.MM
.X.X.XMASX
```

- When I run `day_04 XMAS input_ex2`
- Then output contains `Pattern Count = 18`

The complete file is here : Advent_of_code_2024/day_04_tests.md at c31f902a059d783d5359bc75cdad730168be4549 · LionelDraghi/Advent_of_code_2024 · GitHub

My proposal work’s with whatever input size (because I wanted to use all given examples in my test).

And because it was fun, the pattern is a parameter, and I compute the count on the fly on each line. Could work with a couple of tera Bytes on input :slight_smile:

But I’m not going to make the second part, my goal was to make a use case for bbt, job done (and it’s 2AM here!)

(incidentally, I found a bug in GNAT)

1 Like

That’s quite the flex!