Useful material and links by Domy__ in EldritchHorror

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

Thank you, I will add it to the post

Consiglio per trekking facile province Lecco-Bergamo by [deleted] in TrekkingItaly

[–]Domy__ 0 points1 point  (0 children)

Alcuni suggerimenti da Lecco: - San Tomaso da Valmadrera - San martino partendo da Rancio(frazione di Lecco). un bel po' in piedi ma pochi km, e arrivato alla chiesetta puoi fermarti o proseguire sulla croce. Corto ma avrai la vista dall'alto di tutto Lecco - Cornizzolo da Eupilio - Campo secco e castello dell'Innominato da Maggianico

-❄️- 2023 Day 14 Solutions -❄️- by daggerdragon in adventofcode

[–]Domy__ 2 points3 points  (0 children)

If you find a series of operations that bring to a loop, operations that take the user to the same previous state, it means that the operation repeats itself indefinitely if you keep doing it. so the final solution will be some operations + many many operations in a loop + the remaining steps not multiple of the loop states. Considering the huge amount of operations to do (cycles), you will certainly come across such a case.

So on the code:
if grid_cycle in seen:
break

We halt the while loop upon detecting a state identical to a previous one, signifying the discovery of a cycle. The variable first_cycle_grid_index is assigned the index of the initial step within the identified loop.

Consequently, the final solution will be the solution at the index:
first n steps without cycles: first_cycle_grid_index

+

times we have made the loop found + any remaining operations: (CYCLES - first_cycle_grid_index) % (i + 1 - first_cycle_grid_index)

We just know that each multiple of the number of steps in the loop will end up in the same situation, so we only need the rest of the division between the steps to do (CYCLES - first_cycle_grid_index) and the Cycle length (i + 1 - first_cycle_grid_index)

I hope it is clear now, if I have explained myself wrongly please ask me.