r/adventofcode • • Dec 02 '15

Spoilers Day 2 solutions

Hi! I would like to structure posts like the first one in r/programming, please post solutions in comments.

15 Upvotes

161 comments sorted by

View all comments

Show parent comment

3

u/hoosierEE Dec 02 '15 edited Dec 02 '15

Nice to see another J-er. One-liners like these seem to increase my ability to comprehend tacit J. Well, writing it anyway. Reading someone else's is still very slow. Here are mine, where S is the input string. Part one:

+/({."1+([:+/"1@:+:]))(2*/\(],{.))"1/:~"1]".&>'x'cut&>cutLF S

Part two:

+/((+:@+/@}:)+(*/))"1/:~"1]".&>'x'cut&>cutLF S

1

u/Godspiral Dec 02 '15

nice code, and cute trick for the pairwise mult.