|
|
@ -2,9 +2,9 @@ MappedIndices ← +⊃(\+×≡/×=@.)(⇡⧻): -1
|
|
|
|
|
|
|
|
|
|
|
|
Input ← &fras "../day_11.txt"
|
|
|
|
Input ← &fras "../day_11.txt"
|
|
|
|
⊜∘≠, @\n Input # split on newlines
|
|
|
|
⊜∘≠, @\n Input # split on newlines
|
|
|
|
↯¯1_2⊞⊂ ∩(MappedIndices 1000000) ⊃∘⍉ # map indices
|
|
|
|
↯¯1_2⊞⊂ ∩(MappedIndices 1000000) ⊃∘⍉ . # mapped indices
|
|
|
|
=@#▽≠@\n. Input # find galaxies
|
|
|
|
▽=@#♭: # galaxy indices
|
|
|
|
▽ # keep galaxies
|
|
|
|
↯¯1_2_2⊠⊟. # pairs of galaxies
|
|
|
|
↯¯1_2_2⊠⊟. # galaxy pairs
|
|
|
|
⊝≡(⊏⍏.) # unique pairs
|
|
|
|
/+≡(/+⌵-°⊟) # distances
|
|
|
|
≡(/+⌵-°⊟) # distances between pairs
|
|
|
|
÷2 # account for reversed pairs
|
|
|
|
/+ # sum
|
|
|
|