Aetherus
I spent 3 hours struggling in part 2, until I noticed a very basic mistake ![]()
Here’s my code:
https://github.com/Aetherus/advent-of-code/blob/master/2023/day-10.livemd
By the way, the starting position in my puzzle input is adjacent to up and down pipes, so in Part 2 I just treat it as a |.
Trending in Challenges
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
bjorng
I spent most of the time struggling with basic bugs in the flood fill routine. I would have saved a lot of time if I had implemented a routine to print out the pipes sooner rather than later.
My solution:
https://github.com/bjorng/advent-of-code-2023/blob/main/day10/lib/day10.ex
lud
Lost so much time with a wrong algorithm for part 1 …
And same for part 2
Anyway, it takes 200ms on average, so I am satisfied, but I feel it could be better.
https://github.com/lud/adventofcode/blob/main/lib/solutions/2023/day10.ex
igorb
My solution, runs in 8-10 ms: advent-of-code-2023/lib/advent_of_code/day_10.ex at main · ibarakaiev/advent-of-code-2023 · GitHub
The logic is as follows (spoilers incoming):
For part 1, just calculate how many steps it took to reach S again and divide by 2.
Part 2 was obviously a lot trickier, so I did the following:
The “opener” part was the tricky part for me to figure out: suppose you start from outside and you find “L-J”, then at the end of it you end up outside again. However, if you find “L-7” then you end up inside. If you find “|” then it’s just trivially flipping the value of whether you’re inside or outside.
lud
I did the exact same horizontal casting ray for part 2. Where it is slow is because I used the map as if the symbols could be wrong. Like if you could see
-|, and just the loop would be correct.When I understood all the pipes are properly connected I refactored a bit but it was too late to change everything.
But now you make me want to fix it XD
midouest
For part 2, I added a space between every existing space in the grid and filled it in with either an empty space or a path segment. Then I did a flood fill from the top-left and counted the even coordinates that weren’t discovered.
Part 1
Part 2
EDIT: For part 1, I also remembered the
Kernel.--/2trick from earlier this month.EDITEDIT: Part 2 took 0.1 seconds according to Livebook.
lud
Alright so now that I know that the pipes connections are always valid, I can just select one and go straight for the answers.
This is much more clear and indeed runs in 10ms (11 on my machine
)
https://github.com/lud/adventofcode/blob/main/lib/solutions/2023/day10.ex
@midouest Nice one ! Expanding the map is fun
igorb
Nice, very clean! And I like how others approach it with a flood fill, which I learned about thanks to their solutions.
trnasistor
My beginner’s solution, Day 10 part 1. Pipe Maze
My first attempt was a mess so I decided to start from scratch using :digraph module.
I already attempted to use it in a previous day (forgot which one lol) until I realized a handcrafted solution would be more straightforward.
This time it felt very suited for the part 1 of the problem.
It was very satisfying to seamlessly integrate Erlang Standard Library successfully.
pehbehbeh
Part 1: Used libgraph to construct the loop.
Part 2: Went the lazy route and used topo to count all coordinates that are contained inside the loop. Runs around 7-8 seconds in Livebook…
but worked on first try.
https://github.com/pehbehbeh/adventofcode/blob/main/2023/10.livemd
stevensonmt
Haven’t tried pt 2 yet. Not even sure how I would start, but here’s part 1 with a gratuitous use of
:digraphb/c I thought that would be useful even though any number of better models would have been easier.