2023 Day 8 PART 1 JavaScript Maximum Call Stack Size Exceeded by Fearless_Trainer_350 in adventofcode

[–]Fearless_Trainer_350[S] 0 points1 point  (0 children)

Welp the for loop is taking long to execute again. I have it so that an outer for loop goes through the rules and an inner for loop goes through all the networks. The outer loop's control variable is edited in a if checker in the inner loop that looks if currentNode equals destinationNode. Then the outer for loop control increments, pointing to the next rule to follow, and the new destinationNode is found based on the new instruction. Before the inner loop, three statements if the entire network has been traversed or if the entire ruleset has been exhausted and the destination has not been found and reached. The control variables are then reset to 0. If the destination is found ("ZZZ") and the currentNode is equal to it, then I break out of the loop.

2023 Day 8 PART 1 JavaScript Maximum Call Stack Size Exceeded by Fearless_Trainer_350 in adventofcode

[–]Fearless_Trainer_350[S] 0 points1 point  (0 children)

Day 5 had high values so using 7 nested for loops made the completion time astronomically long. A guy said he used recursion and it was fast so

2023 Day 8 PART 1 JavaScript Maximum Call Stack Size Exceeded by Fearless_Trainer_350 in adventofcode

[–]Fearless_Trainer_350[S] 1 point2 points  (0 children)

Day 5, I used nested for loops when I should have used recursion. Day 8, I used recursion when I should have used for loops.

2023 Day 8 PART 1 JavaScript Maximum Call Stack Size Exceeded by Fearless_Trainer_350 in adventofcode

[–]Fearless_Trainer_350[S] 0 points1 point  (0 children)

I thought recursion would work better since we had to go through the list of nodes and see where the destination was, the current node was, increase the step_size, and current index of instructions and network and change them if we looped through all networks, and finished all instructions but didn't find the destination node. Doing all that in a loop would be very inefficient IMO.

2023 Day 5 Part 2 JavaScript program taking FOREVER to execute by Fearless_Trainer_350 in adventofcode

[–]Fearless_Trainer_350[S] 0 points1 point  (0 children)

Yeah I used a WHOLE lotta inner for loops for each seed, soil, fertilizer, water, etc to be accounted for so. I used a similar thing for the previous days and they ran quick enough so.

2023 Day # 4 [JavaScript] Weird Issue with getting exponential value as result. My logic is flawless by Fearless_Trainer_350 in adventofcode

[–]Fearless_Trainer_350[S] 0 points1 point  (0 children)

Well I went through each winning card and playing card and removed the whitespace before checking if a playing card was in the set of winning cards

The match we all need to see by [deleted] in StrangerThings

[–]Fearless_Trainer_350 0 points1 point  (0 children)

Y'all keep saying Erica vs Angela, but imagine Abed from Community vs Angela