stevensonmt
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
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 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
al2o3cr
Hard to say for sure without the input file, but the logic in
fallseems slightly incorrect: it checks if the block can fall before shifting it. It’s possible to shift a block that can’t move downwards - for instance, the very first shape in the example.I resorted to squinting at multiple buffers in my editor to find the leader length and cycle length for part 2, but here’s my part 1:
stevensonmt
Thanks for taking a look. I don’t think that’s it b/c the first call for each new rock is to shift and it always tries to fall whether it can shift or not. But if it cannot fall it comes to rest. From the prompt:
I might run your code and mine on my data set and see where they diverge when I get a chance. Thanks again for looking.
ADDENDUM:
So checking our output side by side they are equivalent for the first 1712 rocks and then mine gets off and sort of jumps around a bit. Going to have to rethink the whole logic. Your solution is so nicely organized and easy to read I’m going to see if just improving my organization makes the logical error pop out.
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.
stevensonmt
Okay, last time I reply to myself, I promise. Finally got this working but took some time to refactor, polish, and document since I was 10 days late anyway.