-
Notifications
You must be signed in to change notification settings - Fork 1
/
day3-1.prdc
25 lines (24 loc) · 914 Bytes
/
day3-1.prdc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
l{","/µ(17:)‡{|3%(}y\I°~}Ás}d&LwŠmŒ .. 35 bytes
{
l .. two lines please
{ .. process twice:
","/ .. divide into comma-separated tokens
µ .. map across each token:
( .. uncons to get a U/D/L/R letter
17:)‡ .. [17,18]
{ .. we'll do this with both elements against the U/D/L/R ascii:
| .. binary or
3% .. mod 3
( .. subtract 1
}y .. through brute force, this formula was found to produce a displacement vector
\I .. swap, convert to integer (this is the number after U/D/L/R)
° .. replicate
~ .. and expand onto the stack (so we're kind of flatmapping)
} .. done mapping
Ás .. scan with vectorizing addition; this is the list of points visited by the wire
}d .. do this twice, to get the two wire paths
& .. intersect them
Lw .. take the absolute value of everything
Šm .. map with summing, to compute manhattan distances
Œ .. minimum
};