DEV Community


Discussion on: Advent of Code 2020 Solution Megathread - Day 3: Toboggan Trajectory

pzfrenchy profile image
Dan French

Hi Rabbi, you have a short string that repeats indefinitely. As you move right you quickly hit the end of the string. It was a very simple way to repeat the pattern otherwise you get an index out of range error when you exceed the original string length.
Its not very efficient as it repeats every line but it works in this instance. If you had to create longer strings you might want to refactor to check if you've hit end of string and only repeat then.

Thread Thread
rabbiyos profile image
Rabbi Yosef Baruch Fromer

Great! That helped me understand my mistake (Thous that end of line leads to the next line) :)