stevensonmt
Advent of Code 2022 - Day 17
Couldn’t find a thread for this day so sorry if it already exists. I’m stumped. I’ve got a solution that works for the sample data but is off by one for the real data. Anyone mind looking at the code and suggesting where that bug comes from? I just can’t find it. The render and pattern finding functions are not relevant to this error as they are not called, but if you have suggestions for improving those I’m open for that feedback as well.
https://github.com/stevensonmt/advent_of_code/blob/2022/2022/day17/lib/day17.ex
Marked As Solved
stevensonmt
I don’t seem to be able to edit posts any more for some reason. The issue I have is that the 1712th block is a J shape that comes to rest atop a cross shape. For some reason mine is resting atop the vertical bit of the cross rather than the horizontal bit. I must have an issue in my shift calculation or my placement of pieces on the board but I can’t find it.
+++++
Nope. Problem is in parsing the input apparently. The horizontal block that lands before the cross is supposed to go R->L->L->L, but for some reason mine is trying to go R->R->R->L. This leads to the following cross block landing on top of that horizontal piece rather than nesting alongside it. Debugging continues.
+++++
Oh for crying out loud. I didn’t trim the input. I thought I’d be clever and convert the “<” and “>” to -1 and 1 by taking their codepoint value (60 and 62) and subtracting 61. But passing the “\n” character created a shift by -51 (which does nothing but throws the cycle out of phase). Trimming the input and my solution now works. Crikey.
Popular in Challenges
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








