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

Sdílet
Vložit
  • čas přidán 3. 12. 2023
  • 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.
    🏫 COURSES 🏫 Learn to code in C at lowlevel.academy
    📰 NEWSLETTER 📰 Sign up for our newsletter at mailchi.mp/lowlevel/the-low-down
    🙌 SUPPORT THE CHANNEL 🙌 Become a Low Level Associate and support the channel at / lowlevellearning
    🔥🔥🔥 SOCIALS 🔥🔥🔥
    Low Level Merch!: lowlevel.store/
    Follow me on Twitter: / lowleveltweets
    Follow me on Twitch: / lowlevellearning
    Join me on Discord!: / discord
  • Věda a technologie

Komentáře • 104

  • @Codeaholic1
    @Codeaholic1 Před 6 měsíci +129

    The haskell can't hurt you.

    • @Pylo904
      @Pylo904 Před 6 měsíci +49

      But it can make a copy of you that is hurt.

    • @scheimong
      @scheimong Před 6 měsíci

      ​@@Pylo904🏆

    • @iatheman
      @iatheman Před 6 měsíci

      @@Pylo904 🤣

    • @Finkelfunk
      @Finkelfunk Před 6 měsíci +6

      Don't be silly. Hurting someone is a side effect. Unless you wrap the pain in a monad

    • @TheStuartstardust
      @TheStuartstardust Před 6 měsíci

      Fail fast is a valid strategy 😉

  • @everynametaken
    @everynametaken Před 6 měsíci +90

    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.

    • @konstantinsotov6251
      @konstantinsotov6251 Před 6 měsíci +11

      Yeah, since assembly is just easy this seems just about right

  • @Fernando-du5uj
    @Fernando-du5uj Před 6 měsíci +120

    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.

    • @aurele2989
      @aurele2989 Před 6 měsíci +4

      +1

    • @NithinJune
      @NithinJune Před 6 měsíci +10

      don’t do that; that reduces how many new viewers will watch. a lot of people won’t click on the video if it’s a “part 4”

    • @manateepink9100
      @manateepink9100 Před 6 měsíci

      Are Day 1 to Day 4 new additions to the titles?

    • @vlinden1
      @vlinden1 Před 6 měsíci +3

      Put "Advent of Code 2023 day 4" into your title at least. That what was i was searching for when I found your video, but it wasn't close to the top suggestions. Great content, keep it up!

    • @vei_bean
      @vei_bean Před 6 měsíci

      y'all realise he put day # in the title. It's at the end so most people don't see it, but it's there

  • @ferdynandkiepski5026
    @ferdynandkiepski5026 Před 6 měsíci +17

    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.

  • @torarinvik4920
    @torarinvik4920 Před 6 měsíci +17

    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.

    • @Finkelfunk
      @Finkelfunk Před 6 měsíci +2

      Let's be real: Everytime I go back to an imperative language I start missing things like infinite lists.

  • @Q-Ball.
    @Q-Ball. Před 6 měsíci +4

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

  • @Yupppi
    @Yupppi Před 6 měsíci +17

    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.

  • @m4rt_
    @m4rt_ Před 6 měsíci +3

    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.

    • @J-qak
      @J-qak Před 6 měsíci

      Cool, I came up with the same solution! Simple and elegant.

  • @chrishipple4419
    @chrishipple4419 Před 6 měsíci +8

    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.

  • @nicklewis8605
    @nicklewis8605 Před 6 měsíci +3

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

    • @jasondunken
      @jasondunken Před 6 měsíci

      I did an iterative solution for day 4 in Python and it runs in 0.00267 sec to calculate both answers. ASM would be fun.

  • @m1geo
    @m1geo Před 6 měsíci +5

    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!

    • @TheMasonX23
      @TheMasonX23 Před 6 měsíci

      I did this at first too and got part of the way through the video before I saw your comment and it inspired me to rethink the recursive nature of my "surprisingly" slow recursive solution (was surprised because it was a naive algorithm, but computers are fast and it's Rust). It went from ~10s to 0.8ms haha

  • @GordanCable
    @GordanCable Před 6 měsíci +1

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

  • @petertillemans2231
    @petertillemans2231 Před 6 měsíci +1

    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.

  • @billywang3829
    @billywang3829 Před 6 měsíci

    I literally fucking love these

  • @anon-fz2bo
    @anon-fz2bo Před 6 měsíci

    chill series, like it so far

  • @glennedgar5057
    @glennedgar5057 Před 6 měsíci

    Just a suggestion, could you cover embedded frame works like NASA VML and NASA F'Prime?

  • @lightningx10
    @lightningx10 Před 6 měsíci +3

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

    • @reed6514
      @reed6514 Před 6 měsíci +1

      My original solution used a stack, evaluating every copy & the stack just GREW and GREW.
      Then i changed & looped from last game toward first & cached the # of cards produced by any given card, so then each card only got evaluated once.
      Later, i made stack work by looping over the games in the reverse order. That way the stack size never grew by more than a few, so all that memory work didn't slow it to a halt.

    • @bamless95
      @bamless95 Před 6 měsíci

      that's a classic dynamic programming solution, pretty cool

  • @reed6514
    @reed6514 Před 6 měsíci

    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.

  • @einargs
    @einargs Před 6 měsíci

    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.

  • @AntonioZL
    @AntonioZL Před 6 měsíci

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

  • @michaelhart8928
    @michaelhart8928 Před 6 měsíci

    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.

    • @czerwonejakmleko401
      @czerwonejakmleko401 Před 6 měsíci

      Ye i also used a recursive solution and tbh im proud of it lol

  • @u.k.m.2929
    @u.k.m.2929 Před 6 měsíci

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

  • @m4rt_
    @m4rt_ Před 6 měsíci

    When I did it myself and read the "Island Island" part I think my brain just gave up. So I had to take a quick break and re-read it.

  • @TimBielawa
    @TimBielawa Před 6 měsíci +3

    Chat please get AWK on the list tomorrow

  • @perigord6281
    @perigord6281 Před 6 měsíci

    Got Uiua on day 4, it was, rather unique.

  • @maxturgeon89
    @maxturgeon89 Před 6 měsíci +1

    The hardest part of this puzzle was by far figuring out what the hell was going on in part 2 😆

  • @pyyrr
    @pyyrr Před 6 měsíci +1

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

  • @talonhackbarth7652
    @talonhackbarth7652 Před 6 měsíci

    I wound up trying a recursive solution as well before realizing I made a huge mistake using recursion and it ran way too slow, lol.

  • @DarnYeet
    @DarnYeet Před 6 měsíci +3

    I wanna see C# on the wheel.

  • @ekaylor4104
    @ekaylor4104 Před 4 měsíci

    I did the recursive solution 💀. Not a fun time lol. Good practice though!

  • @Ferrohh
    @Ferrohh Před 6 měsíci +5

    Python came out today for me... I can say it was insanely easy

    • @clementdato6328
      @clementdato6328 Před 6 měsíci +1

      At these fast solution moments, abstract factory proxy instance and monadic endo-functorial category will all perish into def solve(): # just solve it

    • @edgeman1135
      @edgeman1135 Před 6 měsíci

      For every other challenge I felt like my code was disgusting, I quite enjoyed it!

  • @L4Vo5
    @L4Vo5 Před 6 měsíci +1

    someone please suggest smalltalk next!

  • @HI-qz6yx
    @HI-qz6yx Před 6 měsíci

    I made the exact same mistake.. for some reason my brain said "yes, the union!" but indeed it is the intersection...

  • @crissdell
    @crissdell Před 6 měsíci +2

    Why excel is not in the list?

  • @Kapsyloffer
    @Kapsyloffer Před 6 měsíci +1

    Add prolog if you fail one

  • @prawnydagrate
    @prawnydagrate Před 6 měsíci

    What the actual fuck. I was stuck on part 2 of this problem for well over an hour, and my solution took 58 seconds to run

  • @Alexman208GR
    @Alexman208GR Před 6 měsíci

    Haha! You almost lanternfished yourself! XD

  • @mohammedsafki7564
    @mohammedsafki7564 Před 6 měsíci +1

    Guys propmpt him to add Malbolge❤❤❤

  • @reed6514
    @reed6514 Před 6 měsíci

    Speedrun timer, please!

  • @JakobKenda
    @JakobKenda Před 6 měsíci

    i did this in x86 asm, rust looks so easy lmao

  • @axevanced3233
    @axevanced3233 Před 6 měsíci

    Waiting for Prolog 😂

  • @chongyihyang616
    @chongyihyang616 Před 6 měsíci +1

    Use a dynamic programming table for part 2

    • @SVVV97
      @SVVV97 Před 6 měsíci

      What would you even DP here? It's a simple fold

    • @chongyihyang616
      @chongyihyang616 Před 6 měsíci +2

      @@SVVV97 I mean I thought that since recursion is the natural solution to this problem, I would build up the number of cards from the bottom. Basically what came to my mind first when I saw this question

    • @SVVV97
      @SVVV97 Před 6 měsíci +2

      @@chongyihyang616 Oh fair point - I didn't consider that solution / it doesn't feel like the most natural one to me. But that still feels overkill to me: you can simply fold the cards down the stack in constant space and linear time.

  • @ficolas2
    @ficolas2 Před 6 měsíci

    14 slots, 21 days, 78.7% of getting Haskel. That is, not considering the probably you fail again, and twitch gives you Haskel, again.

  • @m4rt_
    @m4rt_ Před 6 měsíci

    Somebody put Assembly on the wheel if he fails again.

  • @U20E0
    @U20E0 Před 6 měsíci +2

    where do you go to suggest Befunge-98 ( a 2D esoteric language that is not unusable )

  • @kenzostaelens1688
    @kenzostaelens1688 Před 6 měsíci

    me just throwing regex against day 4 (fix spacings & convert winning numbers to regex pattern)

  • @senoraraton
    @senoraraton Před 6 měsíci

    I'm confused. Aren't the Hash sets unique, so games with multiple numbers matching winning would create a bug here?

    • @agx1397
      @agx1397 Před 6 měsíci

      I don’t think so, because winning numbers will never have duplicates (doesn’t make sense to write a winning lottery ticket number twice) but our numbers can have duplicate and if they win (have a matching num in winnings numbers) it would still count as 1 win.

  • @gdkid
    @gdkid Před 6 měsíci

    I'll just say, I followed through with the recursion stuff and it took like 5 full seconds to run :/
    still got the right answer tho

  • @bhavyakukkar
    @bhavyakukkar Před 6 měsíci

    why do you use solarized

  • @max-mr5xf
    @max-mr5xf Před 6 měsíci

    Can someone please put Perl and Raku on the wheel?

  • @mikhailhyde565
    @mikhailhyde565 Před 6 měsíci

    Brain.exe stopped working for me when reading the instructions for part 2

  • @NithinJune
    @NithinJune Před 6 měsíci

    5:23 Can someone explain wtf is wrong with his line numbers?
    Why does it go from 10 to 0 then back to 10???

    • @StevenMartinGuitar
      @StevenMartinGuitar Před 6 měsíci

      Relative line numbers. So it's quick to go up 7 lines or down 9 lines.

  • @andreffrosa
    @andreffrosa Před 6 měsíci

    Why are you using rust again?

  • @glowiak3430
    @glowiak3430 Před 6 měsíci +1

    FreeBASIC please!!!!

  • @nate7803
    @nate7803 Před 6 měsíci

    MEMOIZE!!!

  • @AlLiberali
    @AlLiberali Před 6 měsíci +1

    Regex!

  • @AlLiberali
    @AlLiberali Před 6 měsíci +12

    This is fp disease for ya! Gotta be complicated; gotta recurse; gotta wrap shit in monads; gotta bend over backwards for the OCaml nerds' rusted minds.
    Embrace the state, tame the state! Using for loops, structs, classes and AbstractFactoryProxyBuilders

    • @aaronstark171
      @aaronstark171 Před 6 měsíci

      what is fp ?

    • @everynametaken
      @everynametaken Před 6 měsíci

      @@aaronstark171 Functional Programming, which is not just programming with functions

    • @_tsu_
      @_tsu_ Před 6 měsíci +1

      i relate to this so hard. Whenever the problem is easy brain says do fp. But when things get hard, i slip back into imperative lol. Today i got the first part in pure fp. Second part was an abomination of both styles.

    • @AlLiberali
      @AlLiberali Před 6 měsíci

      @@_tsu_ Both. Both is tov!

    • @MaybeADragon
      @MaybeADragon Před 6 měsíci

      @@_tsu_ That's the beauty of a language that can do both, not an abomination. Pick and choose which is best suited for the task.

  • @SjuneCBeats
    @SjuneCBeats Před 6 měsíci +3

    Html + css next time bro its turing complete

  • @verolyn8459
    @verolyn8459 Před 6 měsíci

    Add brainfudge

  • @m4rt_
    @m4rt_ Před 6 měsíci

    Haskell isn't that bad... you just have to rewire your brain first.

  • @MarshallLevin
    @MarshallLevin Před 6 měsíci

    int seems like a waste of memory for a 2 digit number 😮

  • @beauremus
    @beauremus Před 6 měsíci +1

    Has anyone requested Nix yet? 😏

  • @Pandorarl
    @Pandorarl Před 6 měsíci +1

    1157th

  • @Luca-gb1og
    @Luca-gb1og Před 6 měsíci

    Could you please make your videos longer? You cut away so much that I don’t understand where you’re at. At one point there was a cut and you had the whole recursive function

  • @SuMmErWaVer7
    @SuMmErWaVer7 Před 6 měsíci

    today was so much reading 🤢

  • @illegalsmirf
    @illegalsmirf Před 6 měsíci

    Instead of doing random crap in 25 languages why do something meaningful in one?

    • @StevenMartinGuitar
      @StevenMartinGuitar Před 6 měsíci

      It's advent of code. It's not about doing something 'useful'.

    • @illegalsmirf
      @illegalsmirf Před 6 měsíci

      @@StevenMartinGuitar I agree, it’s a corporate gimmick and not useful at all all