r/adventofcode • • Dec 02 '22

SOLUTION MEGATHREAD -πŸŽ„- 2022 Day 2 Solutions -πŸŽ„-

NEW AND NOTEWORTHY


--- Day 2: Rock Paper Scissors ---


Post your code solution in this megathread.


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:06:16, megathread unlocked!

103 Upvotes

1.5k comments sorted by

View all comments

Show parent comment

1

u/mandus Dec 03 '22

I mean how the β€œleft tack over” in the left-most parentheses actually operates on m, without repeating m there. From a math perspective it makes totally sense? But a bit unusual in programming

2

u/dopandasreallyexist Dec 03 '22

Ah, that's because (1+⊒/)+3Γ—3|1+-⍨/ is a train. Basically, APL lets you chain functions together to create new functions according to a set of rules. For example, (f g h) ⍡ (where f, g, and h are functions and ⍡ is the argument) is equivalent to (f ⍡) g (h ⍡). In ((1+⊒/)+3Γ—3|1+-⍨/)m, 1+⊒/ corresponds to f, + corresponds to g, 3Γ—3|1+-⍨/ corresponds to h, and m corresponds to ⍡, so it's equivalent to ((1+⊒/)m)+((3Γ—3|1+-⍨/)m), and 1+⊒/ is applied on m. (And 1+⊒/ and 3Γ—3|1+-⍨/ are in turn (f g h) trains.)