Coding in a Random Programming Language Everyday (Huge Mistake)

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ธ.ค. 2024

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

  • @Oler-yx7xj
    @Oler-yx7xj ปีที่แล้ว +594

    A normal youtuber uses an online wheel of fortune, an embedded programmer builds on themself

    • @jeremygee972
      @jeremygee972 ปีที่แล้ว +19

      No array languages on the wheel. Hoping for some APL or BQN

    • @liamkearn
      @liamkearn ปีที่แล้ว +4

      “Formally verified”, they said

    • @gamesshuffler-v8n
      @gamesshuffler-v8n 10 หลายเดือนก่อน +1

      Statement 1: "A normal youtuber uses an online wheel of fortune"
      Statement 2: "An embedded programmer builds on themself"
      These statements don't directly connect and lack context. Here's a breakdown of possibilities for each statement:
      Statement 1:
      Online wheel of fortune: Many TH-camrs use online tools or websites that offer virtual "wheel of fortune" games. These tools allow them to select random options, challenges, or topics to incorporate into their videos, adding an element of chance and audience engagement.
      Normal TH-camr: This is a subjective term. Defining what constitutes a "normal" TH-camr is difficult as the platform hosts a vast variety of content creators with diverse styles and approaches.
      Statement 2:
      Embedded programmer: This could refer to a programmer who focuses on developing software components designed to be integrated into other applications or systems.
      Builds on themself: This phrase is unclear and grammatically incorrect. It's likely meant to convey an idea of personal growth, self-improvement, or continuously building upon one's skills and knowledge.

  • @oserodal2702
    @oserodal2702 ปีที่แล้ว +458

    "C++ is trying to be a Rust clone" is probably one of the most scathing remarks on the language.

    • @LowLevelTV
      @LowLevelTV  ปีที่แล้ว +104

      i meeeeeeeeeeeean

    • @gagagero
      @gagagero ปีที่แล้ว +27

      Not to mention wrong.

    • @sacredgeometry
      @sacredgeometry ปีที่แล้ว +52

      @@LowLevelTV It's a circular dependancy.

    • @makebreakrepeat
      @makebreakrepeat ปีที่แล้ว +11

      Fitting. C++ is development tetanus.

    • @eps-nx8zg
      @eps-nx8zg ปีที่แล้ว +24

      Idk to me it seems like rust is trying to be the c++ clone with where it's going at this rate. They are both taking inspiration from each other though.

  • @samtonetto3294
    @samtonetto3294 ปีที่แล้ว +200

    I think the "two-pass" solution is actually more efficient, since you can break as soon as you hit the first and last numbers. Whereas the other solution has to go through the entire string every time.

    • @luisf7
      @luisf7 ปีที่แล้ว +37

      I thought the same thing. And considering that there is at least one number on each string, the two pass solution would in the worst case scenario read 1 more character then the one-pass solution, so it would be O(n+1) in the worst case scenario, not O(2n). And as you said, it would most times be more efficient than the single pass solution if there are two digits or more

    • @EduardoDeMedeirosDaSilveira
      @EduardoDeMedeirosDaSilveira ปีที่แล้ว +8

      It would be more efficient if you knew the size of each string beforehand. If you were to implement it in C, you would have to first calculate the size of the string (that's one pass) so you don't access invalid memory, and then do the "two-pass" solution. Doing the "one-pass" solution, you wouldn't need to know the size of the string.

    • @hullukana214
      @hullukana214 ปีที่แล้ว +5

      Definitely. I originally solved it with practically the exact same 1 pass algorithm. Then I made a 2 pass and got about 3x performance boost.

    • @chri-k
      @chri-k ปีที่แล้ว +1

      It's actually not ( i think ), and the reason is that the 2-pass solution actually has 3 passes, of which one is done by std::getline().
      If you use getchar instead you can do (the first part) in that same pass you find the newline in, and without allocating any memory too.
      The second part you can also do in that same pass, but i'm not sure of the effect that has on performance:
      ( this solution is untested. It merges strcmp's internal loop into the getchar loop, eliminating a lot of duplicate comparisons, but as a result it will fail if a number string overlaps with itself. fortunately that can't happen for 0-9 in English )
      uint indices[sizeof numbers] = {0}
      for c in input:
      (EOF/null/newline check)
      (check against literal number)
      for i in 0 to sizeof(numbers)-1
      if !numbers[i][indices[i]]
      handle match
      if numbers[i][indices[i]] == c
      indices[i]++
      continue
      indices[i] = 0

    • @someonespotatohmm9513
      @someonespotatohmm9513 ปีที่แล้ว +6

      The one pass is always O(n) with n being the length of the string. While the 2 sided is at MOST O(n), but likely less as you can early stop once you encountered a digit.

  • @IlyaKanis
    @IlyaKanis ปีที่แล้ว +108

    My dude says that c++ was intended to be c with classes, but casually proceeds to use typedef struct😂😂

    • @1337Kupo
      @1337Kupo ปีที่แล้ว +18

      he doesn't know C++. Let him stay ignorant

    • @comradepeter87
      @comradepeter87 ปีที่แล้ว +4

      @@1337Kupo Doesn't know it for a reason lol. Not worth knowing (unless absolutely required)

    • @simonhrabec9973
      @simonhrabec9973 ปีที่แล้ว +15

      @@comradepeter87 It is worth knowing if you wanna make statements about it

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

      Braindead take@@comradepeter87

  • @elbardo_lux
    @elbardo_lux ปีที่แล้ว +155

    You don't need to close the file because the destructor closes it.
    Some programming languages that I would love to see on the wheel of (mis)fortune:
    - Java: because it's very popular, i was surprised it wasn't on the wheel at the start
    - Lua: because it's used for multiple video games
    - Smalltalk: this was the language they used at my university when we started learnong OOP, sounds fun for a challenge
    - Pascal: first language i saw at university, probably torture at this point
    - Scratch: it has colours.

    • @JoaoCarlos-df1zw
      @JoaoCarlos-df1zw ปีที่แล้ว +12

      I thing some lisp would be torture part 2

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

      How about Brainfuck?

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

      C#, specifically using COSMOSOS to make an OS, or maybe some esolangs.

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

      As a java developer I can say that I was quite disappointed to not see it on the wheel...

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

      you don't need to close the file at the end of the program cause the OS will do that for you, along with any other resources used by your program will be freed as well

  • @not_ever
    @not_ever ปีที่แล้ว +17

    "good programmers close your files". Good programming languages, like C++, close your files for you so you don't have to remember to do it manually. Also good programming languages have standard libraries that find the first number and last number in a string like C++'s std::find_if. std::atoi does exist in C++ in the header, so you could have used it since you were basically writing C with fstreams anyway. This was fun to watch, I'm looking forward to Zig.

  • @matt-xq1xv
    @matt-xq1xv ปีที่แล้ว +51

    This is such a cool series idea! Keep up the great content!

  • @ghostsssssss4884
    @ghostsssssss4884 ปีที่แล้ว +39

    Seeing you, a C dev, throw around -1 in uint32s caused irreparable emotional damage😢
    Since halloween is already over probably better to compile with -Wall

    • @Nitiiii11
      @Nitiiii11 ปีที่แล้ว +6

      "-1 in uint32s" Yeah that hurt me.

    • @ghostsssssss4884
      @ghostsssssss4884 ปีที่แล้ว +2

      @@bb-sky yes it does exactly that, the compiler allows it because you need to explicitly enable warnings during compilation ( -Wall, -Wextra)

  • @beepiss
    @beepiss ปีที่แล้ว +18

    using C++ but writing it like its C 😂

  • @lucast2212
    @lucast2212 ปีที่แล้ว +11

    Nitty picky detail: Should O(n) and O(2n) not be the same? Afaik there is a scalar in the definition of Landau big-O that captures any positive scalar, as the only requirement is that it is real and positive. I think the correct terminology would be scales like n, scales like 2n.

  • @Meyoutoo2222
    @Meyoutoo2222 ปีที่แล้ว +13

    Fantastic series idea! I had never heard of AOC before. We are doing it at work as a contest and I'm hooked!

  • @williamouyang9629
    @williamouyang9629 ปีที่แล้ว +18

    Let's get some Fortran in here!

  • @evoboy67
    @evoboy67 ปีที่แล้ว +6

    I’m quite curious about your thoughts on Swift, that’s why I was a little bit saddened by not seeing Swift on the wheel. 😅
    People tend to overlook Swift because of misconceptions like it’s only Apple platforms etc etc. Basically if you like the philosophy of Rust, Swift maybe for you. Swift was created by Chris Lattner and he along with few other brilliant minds laid pretty impressive foundations for the language, compiler and philosophy

  • @nyssc
    @nyssc ปีที่แล้ว +3

    Bro literally said C++ is trying to be a rust clone, As the proposal of type traits in C++ was made in 2004 and the concept of owner ship(smart pointers) was made in 1990s, when rust is not even a thing💀

  • @theminecraftscorpython6958
    @theminecraftscorpython6958 ปีที่แล้ว +5

    I did earlier aoc today (day 1) in c and I came up with a solution that was just a translation of what you did (at least I think so). It's always fascinating how on these easier problems a lot of solution end up looking and working similarly !

  • @BobGoldfield
    @BobGoldfield ปีที่แล้ว +4

    Please finish this series. Don’t stop half way through

  • @totto164
    @totto164 ปีที่แล้ว +3

    It is funny, that you use an uint32_t to store -1 aka 0xFFFFFFFF since it unsigned, than you compare it to an int literal of -1, you are really lucky, that the underlying bytes are exactly the same, since no real conversion happens, but the result just happens to be correct xD

  • @nothappyz
    @nothappyz ปีที่แล้ว +16

    🙏🏻 CHRISTMAS IS ABOUT GOD 🙏🏻
    🙏🏻 VOTE FOR HOLY C 🙏🏻

    • @LowLevelTV
      @LowLevelTV  ปีที่แล้ว +4

      literally never gonna happen 🤣

  • @ISKLEMMI
    @ISKLEMMI ปีที่แล้ว +2

    This was fun to watch!
    Some folks have mentioned grabbing the last digit by iterating backwards, but I don't think that would work if you had a line ending in, say, "oneight." Single pass is just easier and more reliable.
    I can tell you're not the most comfortable writing C++, but I appreciate that you stuck it out and made it work. Hopefully you enjoy the next language you land on! 😂

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

      As someone who implemented a backwards lookup, it does work. My testing function for both forward & backward took a char*. If it was a digit, it returned the int value of that digit and I stopped iterating. If it wasn't a digit, I compared the substring starting at that char*, returning an integer based on which string it matched if any. I stopped iterating as soon as I found an answer, so as soon as the char* walked backwards to the `e` in eight, I stopped looking backwards, and the fact that the `one` was also part of it didn't matter. Same with forward iterator: as soon as it saw `one`, it stopped looking

  • @amr3162
    @amr3162 ปีที่แล้ว +2

    this is the most C looking C++ I've seen

  • @priyaranjankumar_
    @priyaranjankumar_ ปีที่แล้ว +16

    Let’s do COBOL :)

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

      I tried cobol once, I think I'm still recovering from the experience lol

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

      some fortran would be fun too

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

      @@woofcaptain8212 try handling abends everyone will become sober

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

      More like COOLbol, right guys? 😂

  • @orbesty
    @orbesty ปีที่แล้ว +8

    Agree about cout. Its a torture to use it if you want pretty formatted output. In my personal programs switched to libfmt, or just using C prints.

    • @sledgex9
      @sledgex9 ปีที่แล้ว +3

      FYI, in C++20 introduced std::format which is inspired by libfmt. It formats the string the same way as libfmt does and then you use cout/printf to output it.
      EDIT: And in C++23 we get std::print which equivalent to libfmt's print!!! Hooray.

    • @orbesty
      @orbesty ปีที่แล้ว +2

      @@sledgex9 Ik, However, if u need to compile it for old platform (debian buster as example), you better go with additional 3rd party dependency, that trying to use c++20.
      Btw, it is not inspired, but it is actually proposed by the author of libfmt to add it to the standard library.

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

    10:33 the redundant else killed me

  • @kuhluhOG
    @kuhluhOG ปีที่แล้ว +6

    6:37 Yes, iostreams aren't nice to use (or rather the opposite).
    But at least use _std::format_ for formatting (C++20 needed).
    If compilers would have implemented it already, you could do _std::print("x = {}
    ", x);_ instead of _std::cout

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

      Why not std::print on 23?

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

      @@heavymetalmixer91 I wrote that, but some compilers didn't implement it yet.

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

      no way they got the rust println, that's awesome

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

      @@comradepeter87 technically it's from Python

  • @Archbtw_
    @Archbtw_ ปีที่แล้ว +7

    Chat is definitely gonna force you to use eso langs like IuseArchbtw or Brainfuck

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

      this is what im afraid of

    • @jacksonmagas9698
      @jacksonmagas9698 ปีที่แล้ว +4

      @@LowLevelTV someone is going to make you learn APL syntax

  • @Faimyn
    @Faimyn ปีที่แล้ว +8

    This mans out here setting a uint32_t = -1 smh

  • @oraqlle
    @oraqlle ปีที่แล้ว +2

    C++ finally got its own `std::print()` and `std::println()` functions in C++23 and are based on {fmt}. Also, you not using the standard algorithms hurts me as a C++ dev. In part 1 you could've use `std::accumulate()` and put your (inner for) loop logic in a lambda (probably a named one to make it easier to read) saving values in a `std::pair`. This would return the pair at the end which can be destructured to more easily do the sum calculation.

  • @georgehelyar
    @georgehelyar ปีที่แล้ว +4

    C# is actually a really nice language

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

      Not nearly as nice as F# though.

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

      @@Akronymus_ Both are good

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

    Entered to see what language you got, left to do those exercises myself, and came back to finish the video.

  • @Vancha112
    @Vancha112 ปีที่แล้ว +2

    Hah, saying c++ gone a "little overboard" is probably the understatement of the year :p

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

    Might as well do a pass from either end. Still n and not 2n since in the worst case the number is in the middle and has to approach it from both ends (assuming you break once you find it). It will actually be faster since if they are different numbers you didn't need to iterate over the whole line.

  • @LittleIVIara
    @LittleIVIara ปีที่แล้ว +7

    I suggest you add TI-basic to your list, could be fun

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

    I always love dreaming of the python solution that takes 3 lines and then coming back to reality where im writing a 100 line program in c++ to solve the same problem

  • @DaveAxiom
    @DaveAxiom ปีที่แล้ว +4

    Where's Haskell on that wheel? Erase PHP and write in Haskell!

  • @bigboland6160
    @bigboland6160 ปีที่แล้ว +2

    i was doing this with the exact same approach as you but in c, but was getting an answer too big and I could not figure it out. I finally caved and watch this video and then at 10:23 when you mentioned atoi i realised i had been adding the ascii values and not the integer values.

  • @makebreakrepeat
    @makebreakrepeat ปีที่แล้ว +7

    I teach c++ and completely agree. cout/cin drives me nuts. There are just lots of weird and unintuitive things that obfuscate what the code is really doing, and the lack of safety always makes the pointer section fun to teach. I hope we move to rust or golang soon.
    Anyway, good work! Excited for this series. I'm learning game development so I'm doing this year's AOC in Godot.
    I'm already having regrets 😂

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

      If you have access to C++20/C++23 take a look at std::format and std::print. If not, then take a look at "fmtlib".

    • @MoolsDogTwoOfficial
      @MoolsDogTwoOfficial ปีที่แล้ว +4

      C++23 is bringing std::print and std::println which I'm going to use in a heartbeat over std::cout

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

      The lack of safety? Isn't it safer than printf, though?!

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

      @@assyyn4139 Yup cout is safer than printf. I have no idea what is obfuscated by cout that isn't obfuscated by printf, other than the fact that you don't dangerously use the wrong type specifier anymore. However I think the C++ teacher above is refering to pointer safety. Perhaps they are not teaching their students to use smart pointers over raw owning pointers.

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

      iostream is a pain to use (cin/cout), but it does one C++ thing - it is generic. You can change the type and it will work, there is no need to change the format string.

  • @madduxv
    @madduxv ปีที่แล้ว +2

    oh hes definitely writing in dreambird this month

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

    I was thinking that going just one "pass" from left to right would _always_ be n operations, while going from left to right to find first number, then right to left to find last number would be n _or less,_ since if the numbers are at the first and last index you avoid dealing with the rest of the input. So the average case for "two passes" would be n/2 instead of the average of one pass that is n.

  • @MeeBilt
    @MeeBilt ปีที่แล้ว +2

    Great video and a great idea!
    In case you feel a bit adventurous, maybe Forth is something you want to try if you haven't done it already ?

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

      There are dozens of us!

  • @abhinavk0929
    @abhinavk0929 ปีที่แล้ว +18

    "C++ is trying to be a rust clone" lmao

    • @Faimyn
      @Faimyn ปีที่แล้ว +9

      This is like saying a modern young celebrity popularized a fashion style that's been around, and in and out of style, since the 80's haha

  • @ag88301
    @ag88301 ปีที่แล้ว +9

    For part 1, wouldn't the 2 pass be slightly more efficient in some cases..?
    if you consider the line 1aaaaa:
    you'd get to 1 in 1 unit of time
    when you work backwards you'd get to 1 in 5 units of time.
    the total time in O(n) = 6 (worst case)
    best case is e.g. 1aaaaa2
    you'd get to 1 from the front in 1 unit and 2 from the back in 1 unit so it's much quicker.
    with 1 pass you'd always have to check all n elements, so wouldn't it be slower..?

    • @LowLevelTV
      @LowLevelTV  ปีที่แล้ว +5

      thats actually fivehead.

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

      I thought the same thing. My idea was to do it in one pass at first, but then when you mentioned walking forward and back I realized it would be faster.

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

      In 2 passes, the worst case would be only one digit in the string -> walking from the front takes you d characters, walking from the right takes you N-d + 1 characters -> worst case, you walk the whole line only once in total. I don't think there were lines without digits (those would be 2N, but who cares anyways). In the end, who cares, because it's still linear, as is the reading of the input.

  • @dolorsitametblue
    @dolorsitametblue ปีที่แล้ว +3

    Ooh boy, finally! The above zero chance of seeing Nim code on this channel.

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

    I watched a video yesterday that had me deciding to do AoC this year, and then as I'm catching up on my subs feed I see you doing it too. You make me feel so much better about the off by one error I had that stumped me for half an hour as I did part two. I ended up going with C because it's my favorite language, but I used a trie for the second part with the reversed strings of the numbers to do the last numbers backwards. Your attempts at doing C++ are funny, but I hope that wasn't a genuine struggle. Also, K&R bracing is disgusting, consider Allman next time.

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

    "I got the first part done on C++ guys, I don't feel bad doing it this way" Last famous words before doing it in C-style way

  • @BenStoneking
    @BenStoneking ปีที่แล้ว +5

    Nicely done. I liked your solution for the two star. I don’t dislike C++ but I’m with you. C is the GOAT. I hope you do a challenge in ZIG. I’m curious about it but have been too lazy to try it yet.
    Also if you fail on a challenge, I’ll vote for you to do your solution in Java 😈😈😈
    Brainfuck, white space or chicken lang would be fun as well

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

      Zig is cool, you can embed the input file at compile time so a lot of the input processing is done before you even run. Not sure how flexible the standard library is though.

  • @re.liable
    @re.liable ปีที่แล้ว

    Wow. I remember doing the 2022 puzzles, haven't completed them yet, but now the 2023 ones are here...

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

    You could have had gTable be a string array, and returned i + 1 in the match function. The index of the string in the array corresponds to the contents of the string! :)

  • @MichaelBattaglia
    @MichaelBattaglia 5 หลายเดือนก่อน

    Fyi, 0(2N) simplifies O(N). So two pass methods is just as good as one pass in the long run. This is because the location of the numbers is random.

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

    I think you will be of good if chat decides just sometime like VB and such. It’s the internet, you will end up with more and more esoteric programming language.

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

      my first thought was Brainf*ck :D

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

    personally what i did (in Go) is just made a slice of all the digits in the line and then simply `sum := digits[0]*10 + digits[len(digits)-1]`

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

    I like to think of this as "25 days of random programming language crash course"

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

    Imagine the chat selecting malbolge or brainf*ck as programming language.

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

    I hope one of these days he lands on Odin. I love it. It would be cool to see what he'd think of it

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

    1:49 Nahhhhhh no way he did statans favorite language just like that 💯💯🗣🗣

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

    One really weird language I would like to see, just because: Prolog

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

    Please consider explaining the logic behind your code. I saw your video after finishing the puzzle myself and couldnt for the life of me figure out what you did

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

    Loving this! Can't wait to see more.

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

    The one pass approach smells like premature optimization and putting too much weight on O-notation. Searching from the left AND right will both abort when they find a digit, so they are sure to never look at more than N elements (in case there is only one digit). Otherwise depending on how close to the edge the digits are, they might both abort much sooner.
    Of course we could then start worrying about how bad a reverse search is for the cache and other low level considerations. But purely on an "algorithmic" level, the one pass approach is always worse and equal at best.

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

    should include prolog on that list.

    • @musicalneptunian
      @musicalneptunian 4 หลายเดือนก่อน

      and Logo too! Turtle power!

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

    The second solution truly was a C++ is C with classes solution.

  • @ЯрославСвиридов-в7б
    @ЯрославСвиридов-в7б ปีที่แล้ว +1

    By defenition O(2n) = O(n)

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

    If this man calls himself a beginner I have never written a line of code in my life

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

    How would you handle a scenario like "oneight"? Are all valid subsets supposed to be numbers, or are you supposed to interpret that as one number and some nonsense letters?

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

      This is supposed to be interpreted as one and eight. I solved the problem using a Trie and the edge case was “seight”, “ninine” And things like that. I solved it by adding all those corner cases to the trie.

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

    Wow, you went so much complicated than I using the same language. I just abused the C++23 ranges, most of my code is oneliner predicates and pipes

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

    I know for a fact the first language Chat is going to pick will be brainf*ck

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

    Love your part 2 solution!

  • @Airatgl
    @Airatgl ปีที่แล้ว +2

    Hope chat votes for Haskell

  • @StevenHodder
    @StevenHodder ปีที่แล้ว +2

    Regex replace to replace the set of strings with digits, then run your other algorithm as-is?

    • @GordanCable
      @GordanCable ปีที่แล้ว +5

      The problem with that approach was the string 'eightwo' in the test data. Replacing the 'eight' with '8' will remove the 'two' and yield an incorrect solution. It's tricky to use a find/replace algorithm because it has to be done separately over two copies of the string.

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

      @@tyoda A good workaround! You can then use the code from part one to find the solution. I found the problem to be much trickier then past first nights and I was glad to finish as well, and I went to bed a little late that night.

  • @swapstar
    @swapstar ปีที่แล้ว +2

    Are the inputs different for everyone? I got a different answer and passed the test.

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

    Wow a different language every day, was just the idea this game me lol.

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

    he actually meowed for us

  • @jomy10-games
    @jomy10-games ปีที่แล้ว

    I did this last year, it was a lot of fun!

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

    Love this! Great Series

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

    "something a little more spicy - maybe it's COBOL, maybe brainf*ck, maybe elixir..."
    Uh... what's so spicy about elixir? (having this time chosen to learn elixir through aoc...)

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

    I get not liking C++, but if you explicitly opt out of C++ features to use C features, it makes me wonder what the point of the challenge is in the first place.
    It's like using Rust and wrapping your entire program logic in `unsafe` blocks and throwing around a bunch of raw pointers. That's not Rust-like, in the same way your C++ code isn't C++-like.

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

    LOLCODE sounds like a good one to add to the wheel. 😜

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

    9:00 O(n) and O(2n) are the same complexity

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

    Very cool! I hope you'll be able to do all days!

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

    I definitely want to see you write a solution in Brainfuck.

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

    woah you really don't know much of C++! (I am writing this in a friendly manner). Typing the struct as a typedef made me chuckle.

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

    9:36 why not just extract all digits and check if count > 1. If so the take index 0 and highest index, otherwise take index 0 twice?

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

    8:34 At this moment I was seriously confused.
    The following words are wrong:
    > That's a fallacy. The two-pass approach is not O(2n) because we're guaranteed to have a number and in the worst case scenario both passes will finish at this number without traversing the string twice.
    Why? Read the comments.

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

      You need to know the length of the string for the two-pass approach, which by itself is O(n). Two pass would be O(2n+1) in the worst case.

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

      @@flflflflflfl If you read a file from a disk, you get to read the metadata (size). With size known, it's O(n).

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

      @@dmitriidemenev5258 You get the file size, sure, but you won't get the length of every line in the file.

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

      @@flflflflflfl Thank you for correcting me!

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

    Xcode X-STEP MACHINA LANG U A G E

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

    I have a doubt, isn't the complexity O(n) even if you do the iterate from the left and then iterate from the right method, because, think about it, the longer it takes for the left iteration the lesser it will take for right iteration.

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

    we want more the dog

  • @oakley6889
    @oakley6889 ปีที่แล้ว +3

    Cpp is what happens when you refuse to remove something from a language.
    There are 17 ways to copy a string and only one is memory safe (only mildly sarcastic)

    • @sledgex9
      @sledgex9 ปีที่แล้ว +2

      On the other hand, you don't break stuff* and are able to be a preferred language for decades on end. Oh and also you can compile C programs as valid C++. Talk about compatibility!
      *looking at you python2 -> python3

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

      @@sledgex9 C is no longer a subset of C++. Compilers might have extensions to support some C features (VLA) but then you are relying on a particular compiler.

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

      @@simonhrabec9973 citation?

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

    P2 was brutal for this one

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

    I love this idea

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

    I really hope someone puts ATS and / or lean on the wheel :D

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

    why did you not do index + 1 as the word value instead of using a struct and specifying it manually?

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

    Did I hear functional programming on day 24? Jelly, bqn, apl, ... have fun :)

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

    Day one of waiting for the chat to put INTERCAL on the wheel.

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

    shouldn't that be

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

    btw you can also write value = c-'0'. No need to know ASCII.

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

    I can't wait to suggest Verilog.

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

    I’m actually doing it in C++ this year. For this one I had it read input.txt to a vector of strings. Then I walked through every line, left than right. To get the numbers I just had a check function that used a switch statement to convert a char to an int. It returned zero if it was not an integer. So if it returned zero I went to the next position. For part two I just tacked on a part that would go through line by line beforehand, replacing every occurrence of “one” with “o1e”.

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

    I need to force myself to use C++ for one project instead of C

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

    Newbie here, is there any benefit to subtracting 0x30 vs subtracting 48 at 11:09?

    • @LowLevelTV
      @LowLevelTV  ปีที่แล้ว +2

      nope!

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

      well for me its easier to remember the hex numbers.
      Its easier to remember tha numbers go from 0x30 to 0x39
      0x20 is space, and the difference between big and small leters is 0x20
      0x41 should be a big 'A', but im not sure on that

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

      You can also simply substract the character '0', no need for any numbers in your code!
      Something like this:
      int num = c - '0';

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

      @@ConfuSomu yeah I feel like that’s the better option, is the type implicitly converted when you do that though?

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

      @@austinbachurski7906 Yes, chars are implicitly promoted to ints (note that character literals are chars in C++) which is also required as arithmetic operators don't accept types smaller than int as arguments. (Checked all the details on cppreference)
      Sorry for this very late reply as my earlier replies were deleted by the TH-cam anti-spam system due to featuring a hint of a hyperlink 🫤

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

    VALID C IS VALID C++*!!
    *minus the areas where interoperability is not complete

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

    Love the idea - put Perl on there. You won’t. 👀💯💯