bjorng
Erlang Core Team
My solution finishes both parts in 5 seconds on my computer. That time should be possible to reduce by optimizing my rather naive tilt/2 function, but I decided to instead optimize the use of my time and leave as is.
My solution:
https://github.com/bjorng/advent-of-code-2023/blob/main/day14/lib/day14.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 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
trnasistor
My beginner’s solution, Day 14 part 1. Parabolic Reflector Dish
lud
My solution completes part 2 in less than a second but I have the same feeling that the tilt could be improved.
I lost so much time with wrong scores until I decided to print all scores in the loop and see that
64was never coming. This was because my scoring function works with northbound rows but each cycle leaves the platform in eastbound rows.So I had to add that final
rotate()before scoring and it was fine:But before I lost like 30 minutes to re-learn the concepts of division, multiplication, remainders and all…
My 2nd grade teacher would be proud.
https://github.com/lud/adventofcode/blob/main/lib/solutions/2023/day14.ex
tywhisky
https://github.com/tywhisky/advent-of-code/blob/master/2023/day_14/solution.exs
Part 1
I use a queue to save the index of “.” each I saw when recursive.
If I met “#”, empty the queue.
If I met “O”, replace the position by List.replace/3
Part 2
I just use four times Enum.zip/1 for four directions, the rocks move as same as Part 1.
Regarding that loop of 1000000000 iterations, when encountering a number of this magnitude, I realized the need for a modulus operation. I located the starting point and the endpoint of the loop in the input, enabling me to skip redundant segments and calculate the final result directly. It’s worth noting the off-by-one issue.
sevenseacat
oh hey I didn’t know these threads were a thing!
I’ve been cataloging all my daily solutions on GitHub, today’s is here -
https://github.com/sevenseacat/advent_of_code/blob/main/lib/y2023/day14.ex
It can still probably be optimized a heap, because I rewrote big parts to get part 2 to work, so some of the old parts probably suck. But part 2 runs in 1.5 seconds so that’s good enough for me.
Notes:
rollandunstackrollignores the presence of other rollable rocks, and moves each rock as far as it can in the right directionunstacktakes each pile of rocks at the same coordinate, and unstacks them in the right directionwoojiahao
Not my proudest solve but it works:
https://github.com/woojiahao/aoc/blob/main/lib/aoc/2023/day_14.ex
Will look at the other solutions to see how to better tackle this
Aetherus
Input parsing
Here I map each rounded rock
?Oto1because each rounded rock generates1 * indexunit of load.I map each empty space
?.to0because it’s empty and thus generates no load.I map each square rock
?#to0.0because it also generates no load, but it’s different than a?.. Later we can see that when the dish is tilted, the integers can move around, while the float number0.0can’t.Function to rotate the dish
Rotating 90 degree clockwise is equivalent to vertically flipping 180 degree then transpose.
Function to tilt the dish to the north
line |> Stream.chunk_by(&is_integer/1)puts the rounded rocks (mapped to1) and empty spaces (mapped to0) to the same chunk so they can swap their positions, while square rocks (mapped to0.0) are grouped with no rounded rocks nor empty spaces, so they can’t move. Sorting each chunk moves the rounded stones to the right side (north) in their own chunks.Function to calculate the total load
Finally, we need to rotate the input once so that the north is on the right.
Part 1
Part 2
exists
Not proud of this solution, although runs under 3 seconds for part two.
A few comments:
code-shoily
I am not sure if I had fun doing it or I did not have fun doing it. Took way longer experimenting with the rotational logic than I should have.
Aetherus
I didn’t have fun cuz it was too late at night, and I really wanted to sleep
midouest
Started out generalizing part 1 cause I figured that would come up in part 2. I’m thinking I overcomplicated things a bit though after looking at some of y’all’s solutions.
Part 1
Part 2