Advent of Code 2023 - Day 1 - Solving with JavaScript

Поделиться
HTML-код
  • Опубликовано: 6 сен 2024

Комментарии • 38

  • @markboots_
    @markboots_ 9 месяцев назад +14

    First time Im doing the AoC. I thougt it was easy to just replace the words to numbers, but there are overlapping ones (such as 'twone' and 'eightwo'), so that made it a bit trickier than expected). Thanks to that now I do know a bit more of how to use lookahead in regex.

    • @CodingGarden
      @CodingGarden  9 месяцев назад +1

      Ah! I've never used a lookahead in a regex before...

    • @tapiwakundishora6195
      @tapiwakundishora6195 9 месяцев назад

      I ran into that issue too! i ended up abandoning regex lol. What did you end up doing? if you used regex what was your expression?

    • @ManjaroBlack
      @ManjaroBlack 9 месяцев назад

      I used /(one|two…)/g and didn’t need a lookahead.

  • @kerrykreiter445
    @kerrykreiter445 8 месяцев назад

    This is so helpful. I’m very grateful to watch in real time your thought process on solving these challenges. Your expertise is obvious and sharing it with us is very much appreciated! You are like a skilled surgeon looking for the exact right scalpel to use. So insightful and rewarding. Thank you!!!

  • @Michael14634
    @Michael14634 7 месяцев назад

    did this recently, hard as shit. I'm 17 and just started getting into javascript heavily. Been programming on and off for years.

  • @ArtistFormallyKnownasMC
    @ArtistFormallyKnownasMC 9 месяцев назад +1

    It was sooooo good being on a live and getting to “see” everyone. What a pleasant holiday surprise!! I was still working on my Network+ TestOut course, so I got bumped to two other streams after. Haha I remembered to follow one for them. 😊

  • @jurgentreep
    @jurgentreep 9 месяцев назад +1

    I’m impressed at how much complexity you can handle. Once my ternary expression goes 2 deep I’m out haha.
    I ended up finding all occurrences in the string and creating a tuple with index and the digit. Then just sort the array and pick the first and last and combine them.

  • @nero3700
    @nero3700 9 месяцев назад +4

    Glad to see you back CJ! Does this mean we will be getting daily video's for the next 25 days? 😇

  • @dev_kame425
    @dev_kame425 9 месяцев назад +1

    I'm on it since 3 hours. Bro is doing it in 5 minutes
    OMG I did the second part in the first part...

  • @paulallies
    @paulallies 9 месяцев назад +1

    Return of the King! He's Back!

  • @willzin-da-esfiha
    @willzin-da-esfiha 9 месяцев назад

    I generated an array of tuples with the number and the position that it appears, both full writen numbers and algarisms. Then sorted it and grabbed the first and last positions.
    To improve the memory handling I load one line per time in memory and perform the operations.
    It was hard man. I took about 2 hours to finish this one.

  • @smithshaw1151
    @smithshaw1151 9 месяцев назад

    Yo, Long time dude! Welcome back! Love your content

  •  9 месяцев назад +2

    I did it with regex and my example data is getting parsed correctly but the full dataset isn't correct. So yeah feel like I'm gonna spend hours on the first day since I have some stupid error. xD

    • @barunshrestha9425
      @barunshrestha9425 6 месяцев назад

      same here what did you do to remove the error is was it even an error?

  • @sevenstars0711
    @sevenstars0711 9 месяцев назад +3

    I wonder why i got a different answer for part 1, and it's correct. Did they change the input file?

    • @bbbb12281
      @bbbb12281 9 месяцев назад +5

      Everyone get's different input, so you can't just copypaste the answer.

    • @sevenstars0711
      @sevenstars0711 9 месяцев назад +1

      @@bbbb12281ohhh, that's cool, thanks!

  • @ArtistFormallyKnownasMC
    @ArtistFormallyKnownasMC 9 месяцев назад +2

    For someone who was there, could you tell me who we raided on Twitch so I can give them a follow? I was busy working and forgot. Then I got bumped to a second stream. 😊

    • @CodingGarden
      @CodingGarden  9 месяцев назад +1

      We raided Mel (juiceboxhero)! www.twitch.tv/juiceboxhero

    • @ArtistFormallyKnownasMC
      @ArtistFormallyKnownasMC 9 месяцев назад

      @@CodingGardenthank you so much!! 😊

  • @StephenSheridanOnline
    @StephenSheridanOnline 9 месяцев назад

    It was painful to watch you make life so difficult for yourself. But fair play for sticking with it!!

  • @nomorelivin
    @nomorelivin 9 месяцев назад +1

    IDK why my array is returning like this like having an extra '/r' ...so that's why my values can't be read from end
    [ '1abc2
    ', '# pqr3stu8vwx
    ', '# a1b2c3d4e5f
    ', '# treb7uchet' ]

    • @joynalmiah549
      @joynalmiah549 9 месяцев назад +2

      When you split it with
      just add a
      like this
      worked for me

  • @sebastienrodrigues8509
    @sebastienrodrigues8509 9 месяцев назад +1

    Your solution is so hard.
    Try. Replace « one » by « o1e » « two » by « t2w » … « seven » « s7n » …
    Next replace \D by empty string
    Take first take last
    2azrwone> 2azt2o1e> 221> 21
    That’s all

  • @Operaatoors
    @Operaatoors 9 месяцев назад

    I actually tried to replace all words with numbers and do the same as first part, but still fail :( On PHP with strtr

    • @Operaatoors
      @Operaatoors 9 месяцев назад

      basically strtr (replacing words with numbers would never work), because of eightwo :) PS, creators most likely knew that!

  • @marcusaureo
    @marcusaureo 9 месяцев назад +2

    Replace wouldn't work anyway

    • @CodingGarden
      @CodingGarden  9 месяцев назад +5

      Yeah, I'm see from others that things like "twone" and "eightwo" make it tricky to just replace.

    • @martijnkunstman9971
      @martijnkunstman9971 9 месяцев назад +3

      @@CodingGarden
      just do this:
      d = d.replaceAll("one", "o1e");
      d = d.replaceAll("two", "t2o");
      d = d.replaceAll("three", "t3e");
      d = d.replaceAll("four", "f4r");
      d = d.replaceAll("five", "f5e");
      d = d.replaceAll("six", "s6x");
      d = d.replaceAll("seven", "s7n");
      d = d.replaceAll("eight", "e8t");
      d = d.replaceAll("nine", "n9e");
      that works

    • @martijnkunstman9971
      @martijnkunstman9971 9 месяцев назад +2

      d = d.replaceAll("one", "o1e");
      d = d.replaceAll("two", "t2o");
      d = d.replaceAll("three", "t3e");
      d = d.replaceAll("four", "f4r");
      d = d.replaceAll("five", "f5e");
      d = d.replaceAll("six", "s6x");
      d = d.replaceAll("seven", "s7n");
      d = d.replaceAll("eight", "e8t");
      d = d.replaceAll("nine", "n9e");

    • @juanmacias5922
      @juanmacias5922 9 месяцев назад +1

      @@martijnkunstman9971lmfao you kind of just made my day hahaha

    • @JonCurls
      @JonCurls 9 месяцев назад

      @@martijnkunstman9971 praise!

  • @joseisraeldiazzapata5179
    @joseisraeldiazzapata5179 9 месяцев назад

    Where were you Cj? u.u

    • @ArtistFormallyKnownasMC
      @ArtistFormallyKnownasMC 9 месяцев назад

      He said during the live all was well, just busy with some things. Other than some 😢 family news that his wife had gotten laid off.
      The Twitch notification made my jaw drop and I opened it so fast hoping it was real!!

    • @CodingGarden
      @CodingGarden  9 месяцев назад

      You can hear me chat about it in the livestream VOD here: ruclips.net/video/WzsXLsA0q8Q/видео.html