r/adventofcode • u/daggerdragon • Dec 03 '19
SOLUTION MEGATHREAD -🎄- 2019 Day 3 Solutions -🎄-
--- Day 3: Crossed Wires ---
Post your solution using /u/topaz2078's paste or other external repo.
- Please do NOT post your full code (unless it is very short)
- If you do, use old.reddit's four-spaces formatting, NOT new.reddit's triple backticks formatting.
(Full posting rules are HERE if you need a refresher).
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.
Advent of Code's Poems for Programmers
Note: If you submit a poem, please add [POEM] somewhere nearby to make it easier for us moderators to ensure that we include your poem for voting consideration.
Day 2's winner #1: "Attempted to draw a house" by /u/Unihedron!
Note: the poem looks better in monospace.
​ ​ ​​ ​ ​ ​​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ Code
​ ​ ​ ​ ​ ​​ ​ ​ ​ ​ ​​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ Has bug in it
​ ​ ​ ​ ​ ​​ ​ ​ ​ ​ ​ ​ ​ ​ ​ Can't find the problem
​ ​ ​ ​​ ​ ​ ​ Debug with the given test cases
​​ ​ ​ ​​ ​ ​ ​ ​ ​ ​​ ​ ​ ​ Oh it's something dumb
​​ ​ ​ ​​ ​ ​ ​ ​ ​ ​​ ​ ​ ​ Fixed instantly though
​ ​ ​ ​​ ​ ​ ​ ​ ​ ​ ​​ ​ ​ ​ Fell out from top 100s
​ ​ ​ ​​ ​ ​ ​ ​ ​ ​ ​​ ​ ​ ​ Still gonna write poem
Enjoy your Reddit Silver, and good luck with the rest of the Advent of Code!
View all comments
Show parent comment
2
u/ThiccChungus_92 Jan 04 '20
I haven't used python in a long time, I am understanding other python solutions to this problem, but this one gives me a blip for some reason. maybe some syntax I need to review, Can you explain this a little. I know other people say it's clear, but not to me atm...
Going to write my own using a brute force solution but I want to know why this solution is better
I am thinking the definition for L,R,U,D is arbitrary as long as it's consistent?
Instead of
{"L": (0, -1), "R": (0, 1), "U": (1, 1), "D": (1, -1)}I would think it would be,
{"L": (-1, 0), "R": (1, 0), "U": (0, 1), "D": (0, -1)}The diagonal move for up and down and the inverted x and y for L and R is what is getting me, but I think I'm misunderstanding something simple about this