#Advent of Code 2023
1 messages Β· Page 4 of 1
158 should be a fiveofakind
I think through debugging it I have made it worseeee
Send code
eats the code
it's such a mess
1 => HandType::FullHouse,
That's still wrong
FiveOfAKind
Full house is two groups, one 3 one 2
I'm on mobile, can you ss?
I'm gonna bang my head on a wall
Cocaaaa
I'm at uni >:(
i don't have a monitor which would facilitate the creation of a high quaility screenshot due to the ength of the codebase
I'm opening them with Chrome
It's awful
I meant just the card generation bit
And also, you can cargo install silicon && silicon code.rs -o code.png
new tool
I stole it from Tris' list a couple days ago
So pretty
It's Carbon but locally and in rust
Whoops
Hm yes thank you Discord
crunchy
I eated the resolution
istg discord
fixed
(open original)
Damn it you were faster
You can do that on mobile? :o
yeah into your browser
also soon enough I'm also going to have to be on mobile so that's gonna be useful
What is cards.values()?
... Yes?
Huh
You definitely could until the UI rework
Can't find the button anymore
Woop
so if I have [5 4 3 4 T] it's gonna be in a unordered way [2, 1, 1, 1]
it's just the sums of the cards
Shouldn't you dedupe that?
That's my groups.len()
no need
No, it's the count of different card faces
2 of X, 1 of Y, etc
2 1 1 1 is One Pair
also it's a iterator and dedupping that would allocate for no reasons
Hmm
I'm getting confused at how you're checking if the len is 4 but then the value is 2 in the match
so hashmap, it has length of how many entries there are
if there is 2 entries I get the closest entry and see if it's a number that matches to a number a hand type must have
Oh hey I sent my day 7
Neat
if there is 3 entries you do the same thing, but if one of the numbers overlap I make sure to get another entry and check on it since I know it can't overlap then (TwoPair can only have 1 non-pair)
So what's the issue again?
the number is wrong
too low
well
it's actually close enough to not tell me if it's too low or not
the example is correct
Then it feels like the evaluator is still wrong?
which is?
The hand one
there is nothing to indicate it being wrong
the example has these cases
it would fail if they weren't checked
0 OnePair [3 2 T 3K] 765
1 TwoPair [K T J JT] 220
2 TwoPair [K K 6 77] 28
3 ThreeOfAKind [T 5 5 J5] 684
4 ThreeOfAKind [Q Q Q JA] 483
6440
clearly it can handle ThreeOfAKind and TwoPair correctly
ah there might be something
there is overlap with 1
no, fMl
oh
Look at my hand evaluator code when you get it right and contrast how readable it is
Why is it 1 | 3
wait that doesn't makes sense
Shouldn't it be 2 | 3
And shouldn't four of a kind be 1 | 4
Frankly, I still don't understand your code
Rubber duck it to me π«
Now I am the duck then
Duck me, I say
wohoooo!!
I blame your struct layout
Coca just couldn't think
Look at mine π«
But also now I'm sad cuz I had the exact same solution as Coca and I fixed his but mine still borked
:')
pls do
Just send ss of evaluator code
I'm not at PC and I need to wash dishes π
casenc I can send you over my codebase if you wanna look at my nom stuff
https://github.com/Coca162/advent-of-code-2023 day 6 and day 5 (for nom)
I'm going on metro
They look almost identical to mine, but with a couple neat lil nuggets
Like preceded
I do so much let (input, _) = tag(..)(input) it's unreal
Quite imperative of you
π
I really liked how you compared hands in your code from earlier
I learnt about [function whose name I forgot now but it only works on Ordering::Equal]
Hell yeah
Huh?
It was at the top of the file
I don't remember and I am not checking rn because mobile and it takes like 10seconds to load the file on Chrome
been a while since this happened, it finally got me again
i have time to work on this problem now, very excited to do math to it
yes
strum'ed it because I can't be bothered
Cring
this solution is non optimal anyways
there feels like there is a better way to do it
does this solution even work
probably not
AAAAA
I can think my way out of this I just need to touch some grass
oh my gods there is a edge case here which actually ruins everything
time to go back to the previous idea
the previous idea also does not handle the edge case
is this where most people dropped out
this feels like the part that killed everybody
Lol
It killed me
Fart
pain
rewrite it in rust uiua
I need that goofy ah crate which had type system based numbers rn
typenum?
I wonder if I am imagining it or not
(why typenum and not const generics?)
i was thinking of typenum
I'll make it myself if I have to but I want something that's basically just a enum of 0, 1, 2 and 3
...wait why?
day 7 part 1 but awesome
oh hey that's what I wanted to do but then I did it badly
time to butcher it for the second star
I did something similar yeah
horrifying
why is 1 1 3 a FourOfAKind
and 1 2 2
I'd think that's ThreeOfAKind and TwoPair respectively?
ye I figured based off of someone else's solution I used to get my answer without submitting so I didn't have to keep spamming the API π
...this is one of the approaches to this problem of all time
tuples sort lexicographically
I'm desperate okay
false false true false false
how
actually i can test it this way
ah
it was being matched to TwoPair
not ThreeOfAKind
you're only matchin XYZ JJ for 1 1 1 2, and then you fall back to OnePair assuming that none of the first three are J if the pair isn't
fixed?
i want to give you a hint for how to avoid *gestures broadly* so badly but i imagine you want to use your own approach
I literally cannot handle the logic of this
brute forcing all the routes is at least iterative somewhat
is it?
[(1, false), (2, _), (2, true)] no?
fuzzes you
yes
and that's in FourOfAKind
oh wait
I misread true as false
π
Now that is a great match statement
Wipes tear it came such a long way
yes
major cs grad energy
I stare at the code, it stares back
I look at my reflection, but all I see is "That's not the right answer. If you're stuck, make sure you're using the full input data; there are some general tips on the about page, or you can ask for hints on the subreddit. Because you have guessed incorrectly 5 times on this puzzle, please wait 5 minutes before trying again."
I would help, but my last solution is day 3. And I decided to read rust books instead of AoC
yeah it's fine lol
I feel bad tbh
I'll simply sleep it over
||yknow I actually had a idea to make something like a frequency of frequencies, but I think I found a better way to do it now||
I will code it and report back
me (I'm the cs grad (soon) who is already forgetting everything)
part 1
okay, I rewrote it
and it's wrong with the exact same number
is it something else?? ugh
I individually went through each error message and grabbed the pattern from there to make sure I didn't mess up
welp time to try another tactic
250019693 just so I don't forget
this works
I tried to do this and it's wrong though probably the right way to go about this
ah I'm stoopid
fixed
bed time
Hell yeah!
Day 7 Finale:
ok this one looks kinda goofy ahh
||I hate dp||
god this part b is super hard
I've kinda reverse engineered an algorithm but I need to figure out the moving parts
my whole thing up until now was consider the case for only 2 repetitions then generalize to 5, but I realized that there are some edge cases like
?????????????????????? 1,1
(or some arbitrarily large number of ?s)
||I'm going to have to do dp am I not||
oh god i'm ||so bad at dp||
|| my brain is in the gutter, please help||
||i've got a dp algorithm (that is almost certainly wrong)||
day 8, my fav parsing yet
day 8 part 2 my behated
I don't know how much I'm supposed to wait but the proper dataset is taking forever
okay as far as I understood this way should should for day 8 part 2:
||- make a infinite iterator of directions
- get all nodes ending with A
- iterate over direction and apply it to all nodes
- check if all nodes currently end with Z and stop
- return steps iterated through||
However when I do this i never get a result, I've rewritten it a couple of times now and keep getting the same thing over and over again >:(
oh no that approach ||will take way too much time it's not the intended way||
embrace the nerdery
I guess I'll do the (what I believe is only slightly smarter) way of ||recording the entire loop for each path, and then just looping on that instead to find the one||
if that i too slow then it's just gonna be thinking about math which I don't want to do
I'm way too low for 12b 
there are so many cases I'm not hitting
which probably means my base cases are too strict?
bruh
hours later, my thing is finally valid, but it's still really slow on the main input
literally me with day 8 part 2 lol
i didn't have time to do it today, i'll probably just have to come back to it over the weekend or smth like that
DONE

so it seems the small input's test cases were not comprehensive
only 20 minutes to rest until the next day
I am absolutely fucking done with day 8
oof
i have an overly complicated idea to mutlithread day 8 part 2
with likely a lot of pointer shenanigans
please be doable today π
yesterday was pretty easy though, my confidence is not high
hmm how the hell do i do this without ||iterating a billion times||
||I found a cycle and used mods||
i definitely felt like that if today's part two didn't go well first try i would not have been smart enough to debug my own code
oh my day 15 completely rewrote how i will read ||hash|| and ||hashmap|| from now on
I hate my solution but it's done
(theme of aoc)
lol that was me for day 14
i may have hit that point where i miss a couple days of aoc and the motivation really starts to dwindle
I'm currently on a long flight that lands just minutes before the next day drops, so I hope I don't miss it
having more fun making utils than actually solving puzzles
I feel like I'm getting somewhere today but implementation is ehh
this was another one that took me the entire day
but we did it!
it involved 3 separate drawings and even building the problem in minecraft
That's adorable
ok now to catch up on 17, it looks like ||dijkstra's with a ton of extra steps||
oh no
I tried ||dp and greedy|| at first but ||too much recursion||
i thought it would be fun to make my own christmas themed puzzle based on a problem im currently working on :) (no input or anything)
*lower than or equal to
tehe
oh it doesn't have to be contiguous
zamn
||input.map(|v| v.iter().filter(|other| other <= v).count()).max()||?
might be borrow checker problems
ah wait no
||input.iter().enumerate().map(|(lhs, idx)| input.iter().skip(idx).filter(|rhs| lhs > rhs).count()).max()||
god part 2 looks terrible
somehow i managed to make a solution for day 17 that is single threaded non deterministic
i'm assuming it has something to do with how i'm abusing HashSet
idk how to even fix this
i changed every HashSet to a vector and it resolved the issue
don't do it like me I'll have to rethink the approach because i forgot about it for 2hrs and it still isn't done
I think this is fairly close; my solution to this would be:
||```js
// assuming input: [0,1,1,2,2,1,3,5]
input.groupby(a=>a).map(a=>a.length).max()
// (elf's number) (arr len)
For the example of 8 elves:
||[0,1,1,2,2,1,3,5] -> [[1,1,1],[2,2],[0],[3],[5]] -> [3,2,1,1,1] -> 3||, which is the example soln
why so much flavortext today
That's just coincidence and wouldn't work if the input was reversed
part 2 usually does require some thought, but I think for the first time I genuinely have no idea where to start on today's part 2
it is not obvious to me at all how you would start this one
solution: leave a bad solution running and go outside!
I have something now, but I'm not sure it's accurate and even if it was coding it is going to be really difficult
FIVE LEFT
aw man, I dropped off :(
(10 i tried to do but couldn't, the rest are that Uni Happened β’οΈ )
mood
yeah i ended up losing motivation after missing some days too :(
same
that moment when your code is super fast but generates an answer on the order of 10^37
god today's is actually impossible
decided to learn uiua and prepare for this year's aoc by trying my hand at last year
Day 3 part A
||```uiua
&rs β &fo "input.txt"
ββ βΈβ @\n # split by lines
β‘(-β(Β¬β₯β(Γββ₯β€@0,@9)(=@.))(Γββ₯β€@0,@9) . # label numbers with 1, symbols with Β―1
βββ‘β₯ βΈ>0 β(β£β[]) βββ‘ # then convert numbers from 1
) # into their real value
βΈ=Β―1
ββ(
[Β―1_Β―1 Β―1_0 Β―1_1
0_Β―1 0_1
1_Β―1 1_0 1_1]
β― β_2 β+
) # find all cells adjacent to symbols
Γβ 0 # remove non-adjacent numbers
β¬0β‘(βββ‘β‘ββ΄ βΈβ 0) # remove duplicates (this doesnt cover ALL edge cases but im tired)
/+/+
@slate zephyr might be a bit overcomplicated but i cleaned it up as much as i could
Hell yeah!
there should be a way to factor out the "is number" part though since its used twice
nerd