r/adventofcode • • Dec 03 '15

SOLUTION MEGATHREAD --- Day 3 Solutions ---

--- Day 3: Perfectly Spherical Houses in a Vacuum ---

Post your solution as a comment. Structure your post like the Day One thread in /r/programming.

24 Upvotes

228 comments sorted by

View all comments

Show parent comment

4

u/hoosierEE Dec 03 '15

I was stuck trying to track a path on a complex plane until I saw your approach of mapping the directions into a 4x2 grid.

1:

#~.,+/\0,0j1 0j_1 _1 1{~'^v<>'i.s 

2:

#~.,+/\0,0j1 0j_1 _1 1{~'^v<>'i._2]\s

2

u/Godspiral Dec 03 '15

complex numbers are a cool way to map any pair in J. Faster too I think, and with special functions. They are just too scary to use :P, even if its as simple as pair coding, so I stay away.

Very neat trick for splitting up the stream too. Much easier to do and visualize with complex pairs than "floating 2 item lists"