Day 4: Ceres Search
Megathread guidelines
- Keep top level comments as only solutions, if you want to say something other than a solution put it in a new post. (replies to comments can be whatever)
- You can send code in code blocks by using three backticks, the code, and then three backticks or use something such as https://topaz.github.io/paste/ if you prefer sending it through a URL
FAQ
- What is this?: Here is a post with a large amount of details: https://programming.dev/post/6637268
- Where do I participate?: https://adventofcode.com/
- Is there a leaderboard for the community?: We have a programming.dev leaderboard with the info on how to join in this post: https://programming.dev/post/6631465
You are viewing a single thread.
View all comments 2 points
Uiua
This one was nice. The second part seemed quite daunting at first but wasnât actually that hard in the end.
Run with example input here
Row â â "XMAS"
RevRow â â"SAMX"
Sum â /+/+
Count â +â©SumâRow RevRow
PartOne â (
&rs â &fo "input-4.txt"
âââ @\n.
â+ââ©Countââ # horizontal and vertical search
â(/+â§(CountââĄâŹ@ â»âĄâ§».)4)
/+â§(CountââĄâŹ@ â»ÂŻâĄâ§».)4
++
)
Mask â °âĂ2âĄ5
# Create variations of X-MAS
Vars â (
["M S"
" A "
"M S"]
âĄâ[â©ââ]âĄâ.
Mask
â0ââœÂ€
)
PartTwo â (
&rs â &fo "input-4.txt"
âââ @\n.
â§(/+ââââ€VarsâœMaskâ)3_3
Sum
)
&p "Day 4:"
&pf "Part 1: "
&p PartOne
&pf "Part 2: "
&p PartTwo