Advent of Code 2023 - Day 1 in Typescript (solution explained)

แชร์
ฝัง
  • เผยแพร่เมื่อ 30 ม.ค. 2025

ความคิดเห็น • 6

  • @EMEKC
    @EMEKC ปีที่แล้ว +1

    Great video! I also love seeing all the approaches of handling the words in part 2, your approach looks pretty quick!
    A few points I'd like to address though:
    - Splitting with "
    " only makes sense if the file is encoded with that new line sequence (which as far as I know is just Windows). A recommendation of mine would be to either switch to "
    " (which in your IDE I think works by clicking on "CRLF" in the status bar), or perhaps the better solution: using .split(/
    ?
    /) which will support both both :)
    - When talking about the letter "i", pronouncing it as [i] (also known as the German "i") can easily be mistaken with the letter "e" in English ;) Your English seems really good though!
    - The magic (even though obvious in this code) numbers 3 and 5 could be stored in constants to give them names for descriptions, which might be overkill for Advent of Code, but I just felt like throwing that in the room :)
    - About 11:15 adding numbers, I'd highly recommend writing parseInt(`${numbersInString[0]}${numbersInString[numbersInString.length - 1]}`), note that I used backticks (`) and not an apostrophe!

    • @diehypotenuse4908
      @diehypotenuse4908  ปีที่แล้ว +1

      Hey, thanks for the kind words and your tips! You're absolutely right about linesplitting, I'll have to keep an eye on it in the future ;)
      Hopefully my English will improve, practice makes perfect! For readability and of course the fact that I don't have to insert an additional empty string at 11:15, template literals as you suggested are an elegant solution.
      I wish you happy holidays and of course lots of fun with the last AoC days!

    • @EMEKC
      @EMEKC ปีที่แล้ว

      ​@@diehypotenuse4908 Happy holidays to you too! :D

  • @JaredFL
    @JaredFL ปีที่แล้ว

    Thanks for the video. How are your types visually updating in realtime? 0:42

    • @diehypotenuse4908
      @diehypotenuse4908  ปีที่แล้ว

      Hey, thanks for your comment!
      The type updates you see are an IntelliJ feature. You can switch them on or off in the IntelliJ IDE under Settings > Editor > Inlay Hints > Types > Typescript.
      The typing works quite well in most cases, but it is not binding and can only be seen visually. To be type-safe, you still have to write it out! :)

  • @limitlesskode
    @limitlesskode 10 หลายเดือนก่อน

    Just use regex instead of the loop check