#Advent of Code 2023

1 messages Β· Page 4 of 1

bold coral
#

When there's only one face, it's five of a kind

#

Which is indeed an error there, too

hazy abyss
#

I fixed this yet i think the change might've been undoed

#

still incorrect though

bold coral
#

158 should be a fiveofakind

hazy abyss
#

I think through debugging it I have made it worseeee

slate zephyr
#

r

bold coral
#

eats the code

hazy abyss
bold coral
#

1 => HandType::FullHouse,

#

That's still wrong

#

FiveOfAKind
Full house is two groups, one 3 one 2

slate zephyr
#

I'm on mobile, can you ss?

hazy abyss
#

I'm gonna bang my head on a wall

slate zephyr
#

Cocaaaa

bold coral
#

Just open in html text editor

#

Like me

slate zephyr
bold coral
#

Html viewer*

#

I'm also on mobile

hazy abyss
slate zephyr
bold coral
slate zephyr
hazy abyss
#

new tool

slate zephyr
#

I stole it from Tris' list a couple days ago

#

So pretty

#

It's Carbon but locally and in rust

hazy abyss
#

whoop]s

#

wrong day anyways

slate zephyr
#

Whoops

hazy abyss
bold coral
#

Hm yes thank you Discord

hazy abyss
#

crunchy

bold coral
#

I eated the resolution

slate zephyr
#

istg discord

hazy abyss
bold coral
#

(open original)

slate zephyr
slate zephyr
hazy abyss
#

yeah into your browser

#

also soon enough I'm also going to have to be on mobile so that's gonna be useful

slate zephyr
#

What is cards.values()?

bold coral
#

Huh
You definitely could until the UI rework

#

Can't find the button anymore

#

Woop

hazy abyss
#

it's just the sums of the cards

slate zephyr
#

Shouldn't you dedupe that?

bold coral
#

That's my groups.len()

hazy abyss
#

no need

bold coral
#

2 of X, 1 of Y, etc

#

2 1 1 1 is One Pair

hazy abyss
#

also it's a iterator and dedupping that would allocate for no reasons

slate zephyr
#

Hmm
I'm getting confused at how you're checking if the len is 4 but then the value is 2 in the match

hazy abyss
#

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

slate zephyr
#

Oh hey I sent my day 7
Neat

hazy abyss
#

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)

slate zephyr
#

So what's the issue again?

hazy abyss
#

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

slate zephyr
#

Then it feels like the evaluator is still wrong?

hazy abyss
#

which is?

slate zephyr
#

The hand one

hazy abyss
#

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

slate zephyr
#

I don't see a full house here, did you add it?

#

I meant to reply to the code, fml

hazy abyss
#

no, fMl

slate zephyr
#

oh

#

Look at my hand evaluator code when you get it right and contrast how readable it is

hazy abyss
bold coral
#

Why is it 1 | 3

hazy abyss
#

wait that doesn't makes sense

bold coral
#

Shouldn't it be 2 | 3

hazy abyss
#

so it wasn't that case

#

so it's just FullHouse??

#

argh]

bold coral
#

And shouldn't four of a kind be 1 | 4

slate zephyr
#

Frankly, I still don't understand your code

hazy abyss
#

yes yes toby

#

4 | 1 => HandType::FourOfAKind
3 | 2 => HandType::FullHouse

slate zephyr
#

Rubber duck it to me πŸ”«

hazy abyss
#

the duck is dead

#

I don't get ittttt

slate zephyr
#

Now I am the duck then

slate zephyr
hazy abyss
#

AAAAAA I HATE THIS SO MUCH

#

Psychological terror istg

#

I'm going home

slate zephyr
#

yoooo

#

:D

winter ether
#

wohoooo!!

slate zephyr
#

I blame your struct layout

bold coral
#

Coca just couldn't think

slate zephyr
#

Look at mine πŸ”«

bold coral
#

But also now I'm sad cuz I had the exact same solution as Coca and I fixed his but mine still borked

#

:')

slate zephyr
#

Send yours

#

i'm procrastinating hw on this and I do not regret it

winter ether
#

pls do

bold coral
#

My GitHub is linked

#

In Discord

slate zephyr
#

Just send ss of evaluator code

bold coral
#

I'm not at PC and I need to wash dishes πŸ˜”

hazy abyss
#

casenc I can send you over my codebase if you wanna look at my nom stuff

slate zephyr
#

Oh you're on mobile too

#

:0 yesyes

#

Give here/DMs

hazy abyss
#

I'm going on metro

slate zephyr
#

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

hazy abyss
#

Quite imperative of you

slate zephyr
#

πŸ˜”
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]

hazy abyss
#

Learnt it from the best

#

(Jon Gjengset)

slate zephyr
#

Hell yeah

hazy abyss
#

then

#

Or something like that

#

Like with bools

#

But cooler

#

Monad even

slate zephyr
# bold coral 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

hazy abyss
#

been a while since this happened, it finally got me again

bold coral
#

Card::iter()?

#

Like
An iterator over all different faces?

spiral zinc
#

i have time to work on this problem now, very excited to do math to it

hazy abyss
#

strum'ed it because I can't be bothered

bold coral
#

Cring

hazy abyss
#

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

bold coral
#

Lol

bold coral
hazy abyss
#

i can GET THROUGH THIS

#

It's FINE

bold coral
#

Fart

hazy abyss
winter ether
#

oh my day 7

#

there's so many rules to keep track of

hazy abyss
#

up and down

#

oh my god it's so close

#

i hate this

spiral zinc
#

day 11 done!

#

i think it was the most fun so far

hazy abyss
stray violet
#

Day 11 was fun yeah

#

I think day 10 is still my fave tho

hazy abyss
#

i am going to

#

rewrite all my code

#

I have discovered a less stupid solution

spiral zinc
#

rewrite it in rust uiua

hazy abyss
#

I need that goofy ah crate which had type system based numbers rn

spiral zinc
#

typenum?

hazy abyss
#

I wonder if I am imagining it or not

spiral zinc
#

(why typenum and not const generics?)

hazy abyss
#

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

spiral zinc
#

...wait why?

hazy abyss
#

it's slightly dumb anyways

#

I'll live without it

hazy abyss
#

day 7 part 1 but awesome

bold coral
#

oh hey that's what I wanted to do but then I did it badly

hazy abyss
#

time to butcher it for the second star

stray violet
#

I did something similar yeah

hazy abyss
#

COME ON

#

AAAAAAA

bold coral
#

horrifying

bold coral
#

and 1 2 2

#

I'd think that's ThreeOfAKind and TwoPair respectively?

hazy abyss
#

the code got completely changed but yes

#

true means it's J

bold coral
#

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 😎

hazy abyss
#

makes sense

#

this is truly desperate stuff here

bold coral
#

J1233 is a OnePair here, no?

#

cuz that'd be (1,_),(1,_),(1,_),(2,false)?

hazy abyss
#

this is sorted

#

J always ends up at the bottom of it's freq

#

for example

spiral zinc
#

...this is one of the approaches to this problem of all time

bold coral
#

then how would (2, true), (3, false) happen?

#

wait

#

oh I see

hazy abyss
#

tuples sort lexicographically

hazy abyss
bold coral
#

same problem

hazy abyss
#

false false true false false

bold coral
#

yes
that matches to OnePair tho

#

even tho it's 3 of a kind

hazy abyss
#

how

bold coral
#

how what?

#

how does it match OnePair, or how is it 3 of a kind?

hazy abyss
#

actually i can test it this way

#

ah

#

it was being matched to TwoPair

#

not ThreeOfAKind

bold coral
#

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

hazy abyss
#

fixed?

spiral zinc
#

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

hazy abyss
#

I literally cannot handle the logic of this

#

brute forcing all the routes is at least iterative somewhat

bold coral
#

12233 is being matched as FourOfAKind

#

I like how I'm effectively a fuzzer rn

spiral zinc
hazy abyss
#

[(1, false), (2, _), (2, true)] no?

spiral zinc
bold coral
#

oh wait

#

I misread true as false

#

😎

slate zephyr
bold coral
#

yes

quiet frigate
hazy abyss
#

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."

quiet frigate
#

I would help, but my last solution is day 3. And I decided to read rust books instead of AoC

hazy abyss
#

yeah it's fine lol

quiet frigate
#

I feel bad tbh

hazy abyss
#

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

stray violet
hazy abyss
#

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

hazy abyss
#

ok ok

#

I am back

#

however

#

it's complicated

hazy abyss
#

ah I'm stoopid

#

bed time

slate zephyr
#

Hell yeah!

hazy abyss
stray violet
#

ok this one looks kinda goofy ahh

stray violet
#

||I hate dp||

stray violet
#

god this part b is super hard

#

I've kinda reverse engineered an algorithm but I need to figure out the moving parts

stray violet
#

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||

spiral zinc
#

oh god i'm ||so bad at dp||

quiet frigate
#

|| my brain is in the gutter, please help||

spiral zinc
#

||i've got a dp algorithm (that is almost certainly wrong)||

hazy abyss
hazy abyss
#

day 8 part 2 my behated

#

I don't know how much I'm supposed to wait but the proper dataset is taking forever

hazy abyss
#

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 >:(
winter ether
#

oh no that approach ||will take way too much time it's not the intended way||

hazy abyss
#

grrrrrr

#

computational limits can't stop meee

#

the other way is so much nerdness

spiral zinc
#

embrace the nerdery

hazy abyss
#

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

stray violet
#

I'm way too low for 12b noooooooo

#

there are so many cases I'm not hitting

#

which probably means my base cases are too strict?

stray violet
#

bruh

#

hours later, my thing is finally valid, but it's still really slow on the main input

stray violet
#

OH MY

#

the good news: my code is now super fast
the bad news: it's still wrong

hazy abyss
#

literally me with day 8 part 2 lol

stray violet
#

there has to be some edge case

#

I'm passing the small input

spiral zinc
#

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

stray violet
#

DONE

#

so it seems the small input's test cases were not comprehensive

#

only 20 minutes to rest until the next day

hazy abyss
ripe lance
#

i have an overly complicated idea to mutlithread day 8 part 2

#

with likely a lot of pointer shenanigans

stray violet
#

please be doable today πŸ™

#

yesterday was pretty easy though, my confidence is not high

spiral zinc
#

hmm how the hell do i do this without ||iterating a billion times||

stray violet
#

||I found a cycle and used mods||

winter ether
#

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

stray violet
#

finally something I could do in 15 minutes

#

(reading aside)

winter ether
#

oh my day 15 completely rewrote how i will read ||hash|| and ||hashmap|| from now on

stray violet
#

I hate my solution but it's done
(theme of aoc)

spiral zinc
#

lol that was me for day 14

spiral zinc
#

i may have hit that point where i miss a couple days of aoc and the motivation really starts to dwindle

stray violet
#

I'm currently on a long flight that lands just minutes before the next day drops, so I hope I don't miss it

ripe lance
#

having more fun making utils than actually solving puzzles

stray violet
#

I feel like I'm getting somewhere today but implementation is ehh

stray violet
#

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

quiet frigate
#

That's adorable

stray violet
#

ok now to catch up on 17, it looks like ||dijkstra's with a ton of extra steps||

bold coral
#

oh no

stray violet
#

I tried ||dp and greedy|| at first but ||too much recursion||

ripe lance
#

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)

bold coral
#

if I use nightly Rust, I can solve this in one line

#

FP win

ripe lance
#

tehe

bold coral
#

||input.group_by(|a,b|a<=b).map(|a|a.len()).max()||

#

assuming I read that correctly

ripe lance
#

not quite

#

i was hoping you actually just solved my actual problem lmfao

bold coral
#

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()||

stray violet
#

god part 2 looks terrible

stray violet
#

we are MASSIVE

#

6 days to go, I can do this!!

winter ether
#

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

winter ether
#

i changed every HashSet to a vector and it resolved the issue

winter ether
#

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

gray bramble
bold coral
#

That just maps everything to how often it occurs, no?

#

Missing all the lower numbers

gray bramble
#

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

stray violet
#

why so much flavortext today

bold coral
stray violet
#

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!

stray violet
#

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

stray violet
#

FIVE LEFT

slate zephyr
#

aw man, I dropped off :(

#

(10 i tried to do but couldn't, the rest are that Uni Happened ℒ️ )

bold coral
#

mood

spiral zinc
bold coral
#

same

stray violet
#

that moment when your code is super fast but generates an answer on the order of 10^37

quiet frigate
stray violet
#

god today's is actually impossible

tired belfry
#

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

slate zephyr
#

Hell yeah!

tired belfry
#

there should be a way to factor out the "is number" part though since its used twice

slate zephyr
#

you should share in the uiua server :3

bold coral
#

nerd