We Made Up. (Coding in a Random Language Every Day - Day 4)

preview_player
Показать описание
Advent of Code 2023 is UPON US! What better way to spend the holiday season, learn to program, and test your skills against your friends. This year, I've decided to try something kind of insane. I'll be choosing a language off the wheel every day.... let's see what happens.

🔥🔥🔥 SOCIALS 🔥🔥🔥
Рекомендации по теме
Комментарии
Автор

Why not play a wonderful language known as INTERCAL (specifically the C-INTERCAL dialect)? You can learn to be more polite in your coding, the wonders of non-standard operators such as unary XOR and Mingle, and flow control via COME FROM.

everynametaken
Автор

When is assembly coming onto the wheel? Or maybe to make it cross platform it could even be LLVM IR. That should be fun to write with single static assignment.

ferdynandkiepski
Автор

It'd be cool if you put some numeric label into the title of the video indicating which one comes first, something like "#1", "#2" and so on.

Fernando-duuj
Автор

Haskell is not nearly as bad as you think. It took me just a week to learn the syntax properly. I did take me however, 1.5 years to become comfortable programming in this functional style. Haskell shares many features of Rust, particularly the enums and pattern matching which is a huge part of FP. I do find F# to be a much more practical and enjoyable language to code in though.

torarinvik
Автор

Coding is cool and fun, but can we get more of the dog?

How do you know Santa is a Linux user? He has a lot of elfs.

Yupppi
Автор

This series is the best. I’ve been doing my best to get through the challenges each day so far

Q-Ball.
Автор

I went down the same road as you for part 2 except I didn't have chat to reel me in and I got to the end of that recursive road. Saw some guys 5 line JavaScript solution afterwards and felt like a real dummy for creating such a "smart" answer.

ycombine
Автор

Better to get the haskell done sooner rather than later, before the problems get really hard and you've gotta really implement a lot to solve the problem.

chrishipple
Автор

Did an iterative python solution today it took over ten seconds to finish running. Would be fun to see assembly on the wheel

nictheregulardude
Автор

for part 2 I just had an array of integers, and I just incremented the index of the cards by the value for the current card, and in the end just summed them up.
(I made sure that each card started at 1 instead of 0 by incrementing the current card by one at the start of the loop).
O(n) solution.

mrt_
Автор

10:11 Don't feel so bad. The Reddit thread is full of people still waiting for their recursive solutions to halt.

GordanCable
Автор

I fell into the same recursion trap that you did with my solution. I even tried giving a tonne of memory and letting it run (that didn't work either! Don't hate, I'm a hardware engineer!) I ended up doing the same as you!

mgeo
Автор

My algo for this question just used a lookup table to count how many copies of each card I had, rather than running the code multiple times you can just multiply how many subsequent copies of other cards you make.

I also had an amazing off by one error that would cause my answer to balloon over the u128 max int limit for the full problem ;)

lightningx
Автор

I can't wait for Haskell. The syntax really isn't that strange -- the weirdest part is the where and do. Once you learn haskell, it changes the way you think about code. Not just monads, but stuff like GADTs, DataKinds, and lenses.

einargs
Автор

Interesting, I actually ended up doing the recursive solution which wasn't that bad either. You do that same iteration over the vector at first for the original cards, then the copies you just check three conditions: if we run out of cards return 0, if we don't have any matching numbers return 1 (we have to add the current card), else we iterate over the slice from the current index + 1 to the number of matching numbers and recurse.

Definitely not the fastest solution, but it was pretty interesting.

michaelhart
Автор

Why the fear for Haskell? IME it is a more elegant simple version of Rust. The big issue is that each function has to be a single expression but that is hardly an issue.

petertillemans
Автор

I used a stack & added copied cards to it, and evaluated every card. Stack was GROWING and slowing. So i then went in reverse & cached solutions, so each card would only be evaluated once.

So for card 37, i would have cached how many cards 38 & 39 produced, but I wouldn't know 36 yet.

reed
Автор

yesterdays challenge was so much tougher than todays, today is actually free

pyyrr
Автор

The elf in the story is probably a junior. Dude is doing everything by himself.

AntonioZL
Автор

Hey, having done AoC so far with C++ and seeing how beautifully concise Rust can be, are there any good resources for learning Rust?

u.k.m.