Advent of Code 2023 - Day 3 - Dyalog APL

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

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

  • @anon_y_mousse
    @anon_y_mousse Год назад

    I finally got around to doing day 3. For part one I read the input into a matrix and added a border around the entire thing so I could go backwards or forwards in any direction by one space and not have to worry about where I was reading. The first part was easy, but life intruded and slowed me down. I doubt my solution is all that optimal either, but it works, so whatever. For part two, I made another matrix and stored the value of each number in every position it occupied, then scanned through a second time for each asterisk and where it touched two numbers. It took me far too long to think of that solution and it's even less optimal since I scan the input twice, but it works. I don't know if I'll be able to make time to work on any other days, but I'll give it a shot. I don't know what the deal is lately, but the amount of time I have to do anything fun is a dwindling supply.

  • @minghaoliang4311
    @minghaoliang4311 Год назад +1

    The code may break if one line ends with number while the next line starts with number. It seems not to be the case for all input lines. Maybe adding a "." before flatten the inputs would be a good precaution.

    • @yernab
      @yernab  Год назад +1

      That’s a really elegant way to handle that case!

  • @philstark9716
    @philstark9716 Год назад

    Can you show this in ngn/k please.

  • @KrzysztofSzeruga
    @KrzysztofSzeruga Год назад +1

    Impressive, but when you create a flat vector of inputs, how come you don't concatenate the number at the very end of the line with the number at the very beginning of the next line?

    • @yernab
      @yernab  Год назад +1

      Surprisingly, that doesn't happen in the input! I think there's a few tricks in there to make solving it somewhat more easy (for example, no number is in contact with two symbols).
      If that did happen, I would need to do something like pad zeroes on the left of the matrix, flatten into a vector and do the parsing, then mix it back into a matrix and remove the first zero from every row. A few extra characters, but not too bad.

  • @luishenriqueandradepellizz680
    @luishenriqueandradepellizz680 Год назад +1

    I just dropped in here and..WTF is all this symbols and language

    • @0LoneTech
      @0LoneTech Год назад

      As the title says, APL.