Advent of Code 2023 - Day 1 - Solving with JavaScript

  Рет қаралды 18,902

Coding Garden

Coding Garden

Күн бұрын

Пікірлер: 39
@markboots_
@markboots_ Жыл бұрын
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 Жыл бұрын
Ah! I've never used a lookahead in a regex before...
@tapiwakundishora6195
@tapiwakundishora6195 Жыл бұрын
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 Жыл бұрын
I used /(one|two…)/g and didn’t need a lookahead.
@kerrykreiter445
@kerrykreiter445 Жыл бұрын
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!!!
@jurgentreep
@jurgentreep Жыл бұрын
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.
@Michael14634
@Michael14634 10 ай бұрын
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 Жыл бұрын
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. 😊
@sevenstars0711
@sevenstars0711 Жыл бұрын
I wonder why i got a different answer for part 1, and it's correct. Did they change the input file?
@bbbb12281
@bbbb12281 Жыл бұрын
Everyone get's different input, so you can't just copypaste the answer.
@sevenstars0711
@sevenstars0711 Жыл бұрын
@@bbbb12281ohhh, that's cool, thanks!
@mike-2342
@mike-2342 Жыл бұрын
I was not a fan how they added `oneight` etc, just seemed more annoying than it was worth. Especially since they didn't factor it in properly in their test cases. It had an example, but didn't actually use the numbers in the example result.
@dev_kame425
@dev_kame425 Жыл бұрын
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 Жыл бұрын
Return of the King! He's Back!
@willzin-da-esfiha
@willzin-da-esfiha Жыл бұрын
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 Жыл бұрын
Yo, Long time dude! Welcome back! Love your content
@nero3700
@nero3700 Жыл бұрын
Glad to see you back CJ! Does this mean we will be getting daily video's for the next 25 days? 😇
@7edim
@7edim Жыл бұрын
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 10 ай бұрын
same here what did you do to remove the error is was it even an error?
@ArtistFormallyKnownasMC
@ArtistFormallyKnownasMC Жыл бұрын
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 Жыл бұрын
We raided Mel (juiceboxhero)! www.twitch.tv/juiceboxhero
@ArtistFormallyKnownasMC
@ArtistFormallyKnownasMC Жыл бұрын
@@CodingGardenthank you so much!! 😊
@nomorelivin
@nomorelivin Жыл бұрын
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 Жыл бұрын
When you split it with just add a like this worked for me
@cornshed
@cornshed Жыл бұрын
Replace wouldn't work anyway
@CodingGarden
@CodingGarden Жыл бұрын
Yeah, I'm see from others that things like "twone" and "eightwo" make it tricky to just replace.
@martijnkunstman9971
@martijnkunstman9971 Жыл бұрын
@@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 Жыл бұрын
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 Жыл бұрын
@@martijnkunstman9971lmfao you kind of just made my day hahaha
@JonCurls
@JonCurls Жыл бұрын
@@martijnkunstman9971 praise!
@Operaatoors
@Operaatoors Жыл бұрын
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 Жыл бұрын
basically strtr (replacing words with numbers would never work), because of eightwo :) PS, creators most likely knew that!
@StephenSheridanOnline
@StephenSheridanOnline Жыл бұрын
It was painful to watch you make life so difficult for yourself. But fair play for sticking with it!!
@sebastienrodrigues8509
@sebastienrodrigues8509 Жыл бұрын
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
@joseisraeldiazzapata5179
@joseisraeldiazzapata5179 Жыл бұрын
Where were you Cj? u.u
@ArtistFormallyKnownasMC
@ArtistFormallyKnownasMC Жыл бұрын
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 Жыл бұрын
You can hear me chat about it in the livestream VOD here: kzbin.info/www/bejne/javWiX-pdpWkbrM
Advent of Code 2023 - Day 2 - Solving with JavaScript
22:26
Coding Garden
Рет қаралды 8 М.
Code Katas #9 - Solving Code Wars Katas and Talking through my process
1:29:24
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН
Арыстанның айқасы, Тәуіржанның шайқасы!
25:51
QosLike / ҚосЛайк / Косылайық
Рет қаралды 700 М.
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
Day 01 - Advent of Code 2023
38:14
chris biscardi
Рет қаралды 29 М.
Advent of Code 2024 Go - Day 1: Historian Hysteria
11:29
Josh Ackland
Рет қаралды 2,4 М.
going fast is about doing less
19:41
leddoo
Рет қаралды 175 М.
Coding in a Random Programming Language Everyday (Huge Mistake)
17:17
Advent of Code 2023 in Kotlin Day 1
1:21:22
Kotlin by JetBrains
Рет қаралды 17 М.
day 01 - advent of code 2024
17:14
chris biscardi
Рет қаралды 13 М.
Trying SolidStart v1.0.0
3:44:33
Coding Garden
Рет қаралды 6 М.
The Truth About HTMX | Prime Reacts
49:56
ThePrimeTime
Рет қаралды 384 М.
Advent of Code 2023 - Day 21
1:23:43
Jonathan Paulson
Рет қаралды 4,2 М.
VIP ACCESS
00:47
Natan por Aí
Рет қаралды 30 МЛН