Winner solution, (but you didn't submit it at 12:18 :P)
using complex encoding for pairs should probably always be done? It makes your part 2 especially elegant. ----- Original Message ----- From: Alex Shroyer <ashro...@gmail.com> To: programm...@jsoftware.com Sent: Thursday, December 3, 2015 11:25 AM Subject: Re: [Jprogramming] advent of code - day 3 I was stuck at '^v<>'i.s , but came up with these after I peeked at someone else's solution: part1=:#~.,+/\0,0j1 0j_1 _1 1{~'^v<>'i.s part2=:#~.,+/\0,0j1 0j_1 _1 1{~'^v<>'i._2]\s On Thu, Dec 3, 2015 at 8:59 AM, Joe Bogner <joebog...@gmail.com> wrote: > Mine: > > data=:fread 'advent2015/day3.txt' > getMoves=: ((0,1),(0,_1),(1,0),:(_1,0)) {~ ('^v><' i. ]) > addStart =: (1 2 $ 0) , ] > smoutput answer1 =: # ~. +/\ addStart @: getMoves data > smoutput answer2 =: # ~. _2[\ ; +/\"2 (((0,1) $~ #) addStart@,./. > getMoves) data > > > > > On Thu, Dec 3, 2015 at 7:00 AM, Ryan Eckbo <ec...@cim.mcgill.ca> wrote: > > Data=. }: freads'/tmp/input.txt' > > houses=: 3 : '+/\ (0 0), (4 2$0 1 1 0 0 _1 _1 0){~ ''^>v<'' i. y' > > > > # part 1 > > {. $ ~. houses Data > > > > # part 2 > > santa=. 2 | i. # Data > > robo=. -. santa > > {. $ ~. (santa&# ,&shouses robo&#) Data > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm