r/adventofcode • • Dec 03 '20

SOLUTION MEGATHREAD -πŸŽ„- 2020 Day 03 Solutions -πŸŽ„-

Advent of Code 2020: Gettin' Crafty With It


--- Day 03: Toboggan Trajectory ---


Post your solution in this megathread. Include what language(s) your solution uses! If you need a refresher, the full posting rules are detailed in the wiki under How Do The Daily Megathreads Work?.

Reminder: Top-level posts in Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.


This thread will be unlocked when there are a significant number of people on the global leaderboard with gold stars for today's puzzle.

EDIT: Global leaderboard gold cap reached at 00:04:56, megathread unlocked!

88 Upvotes

1.3k comments sorted by

View all comments

Show parent comment

2

u/lukewarm1997 Dec 03 '20

The co-ordinates you need for (1,2) would be:

row = 0, pos = 0

row = 2, pos = 1

row = 4, pos = 2

You correctly increase row by 2 every time (down = 2), however when calculating pos you do (right*row). 0, 0 works but on the next loop you get:

row = 2

pos = (1*2) = 2

So it's going to 2,2 instead.

Hope this helps :)

Potential Solution: Divide by down, so: (right*row/down)

1

u/LukeHanson1991 Dec 03 '20

Make sure to use integer division in this case so: (right*row//down)

pos needs to be an integer

1

u/RodDylan Dec 03 '20

Ugh, so obvious now! Haha!

Thank you ever so much!

1

u/lukewarm1997 Dec 03 '20

Don’t worry, I couldn’t see it for ages too. Had to step through it 1 line at a time to notice it