LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Advent of code 2022 day 5

Anyone doing the advent of code?

 

I am stuck on day 5. I manually checked 5 steps and it looked right to me. Any edge cases I am not seeing?

 

https://adventofcode.com/ 

 

 

0 Kudos
Message 1 of 6
(2,022 Views)

LV people are doing the AoC, I've pointed them to this thread.

0 Kudos
Message 2 of 6
(1,936 Views)

Hi Steve,

 

there is indeed a Advent of Code leaderboard for LabVIEW developers and also a Discord server were we discuss the problems and solutions.

Feel free to join. You can find all the info here :

https://forums.ni.com/t5/Chicago-LabVIEW-User-Group/Advent-of-Code-Come-join-the-LV-community/m-p/42...

 

Best Regards,

Stefan

0 Kudos
Message 3 of 6
(1,911 Views)

I quickly looked at your "solution" and it seems convoluted mostly due to the poor choice of data structures.

 

  • A cluster of 1D arrays is not scalable. Imagine how the code would look like if you have 1000 stacks in the next problem! To do ragged arrays, you could do a 1D array (index=stack#) of clusters, where each cluster contains a 1D array (of crates). No case structures needed.
  • In this case where each crate is a single uppercase character, we could even do 1D array of strings, one string for each stack and one character for each crate. Even simpler!
  • It is not clear why you have two FOR loops. one is sufficient.
  • ...

In any case, I think your result is correct for your input, assuming element 0 is at the bottom. Could it be you parsed the original stacks in reverse order?

(Unfortunately, you did not include the code where you parse the raw input. Maybe the problem is there!)

0 Kudos
Message 4 of 6
(1,858 Views)

The cluster of 1D arrays was just a quick and easy way to get the data I wanted. If it was a lot more than 9 stacks I probably would have done an array of clusters of arrays. I could have done a string, but then I would have to futz with string subsets and keeping track of string index. I though array might be better scalable for the next section. I used two for loops because it was easier to keep track of data in my head. Less optimized, but for me easier to read. In the end I guess I was just not typing in the answer correctly. I tried a few hours later and it was accepted. 

0 Kudos
Message 5 of 6
(1,852 Views)

@StevenD wrote:

The cluster of 1D arrays was just a quick and easy way to get the data I wanted.


So did you type the stack inputs in manually. Too many places to introduce mistakes.

I fully parsed the problem input string verbatim..

 

I used a simple array of strings. The only case structure is to select the part 2 code

 

Spoiler

altenbach_2-1671230753107.png

 


 

 

 

 

 

 

0 Kudos
Message 6 of 6
(1,837 Views)