shritesh
I mapped both the cards and every possible hand to numeric values and sorted them. In part 2 I could only think of replacing the jokers with all unique values in the hand. There’s probably a better way.
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)
Aetherus
I did almost the same thing. My code is still messy, so I’ll clean it up and post it later.
By the way, I’m sorting things like
[1, 1, 1, 1, 1]and[3, 2]directly instead of converting them to a number then sort.bjorng
Today’s puzzle was fun!
My solution:
https://github.com/bjorng/advent-of-code-2023/blob/main/day07/lib/day07.ex
Aetherus
I accidentally removed my code, so I wrote it again and didn’t bother to refactor it.
Prep
Part 1
Part 2
code-shoily
I loved doing this. The way I decided to calculate rank through pattern matching ended up being visual cue to compute the J assisted ranking.
advent_of_code/lib/2023/day_07.ex at master · code-shoily/advent_of_code (github.com)
This felt so natural!
One valuable lesson learned though.
My
smaller?function had@card_rank_1as default parameter. And it is recursive, so when I called it with@card_rank_2during part 2, I forgot to provide the second parameter on the recursive calls, so subsequent matches were lies! And to make it worse, sample data were immune to this ranking algorithm and kept giving me right answer so I spent some time in frustration.lud
I was struggling on part 1 and I don’t know why. I finally made it work with this
But (for whatever reason) I started by doing a custom sort and I don’t understand why it does not work:
It should be the same no ? The result I had with that was just
-1from the actual answer.Same result if I move the
{sameclauses on top, and it works with the example.Please help mee see what is wrong with that function
EDIT: Ah ! Found it. It was so obvious. all the
x, x, xare trying to match the same value. I am stupidGoing for part 2 now
seeplusplus
Heh, better than I did, I just brute forced and tried every card possible
/shrug
https://github.com/seeplusplus/aoc-elixir/blob/main/lib/2023/day7.ex
lud
Part 2 was easier than I thought at first, thanks to the rule of “first card wins” we do not have to compute which figure the joker should be, just the hand type.
So here is my solution, a bit ugly because of the big matching cases, but otherwise straightforward.
hauleth
Day 07
Setup:
Parse:
Part 1:
Part 2:
Part 2 is simple when you notice that you need to add jokers only to the most frequent card, so no need for testing all combinations and result is blazing fast.
pehbehbeh
I used DataFrames with Explorer for the first time today. May be overkill, but I learned a lot.
https://github.com/pehbehbeh/adventofcode/blob/main/2023/07.livemd
It was nice to be able to tinker directly in the results via LiveBook:
rugyoga
I got
Enum.frequenciesandEnum.sortto do all the heavy lifting: