This solution feels very un-BQN-esque, but I could not get it to work by doing arithmetic operations on an array of indices for any input but the example one. It's still decently fact considering that we create so many intermediate arrays at each step. Change-Id: I883409b4d99d4954312df9b9a9ffc568c39f7726 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7602 Reviewed-by: sterni <sternenseemann@systemli.org> Autosubmit: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
		
			
				
	
	
		
			13 lines
		
	
	
	
		
			469 B
		
	
	
	
		
			BQN
		
	
	
	
	
	
			
		
		
	
	
			13 lines
		
	
	
	
		
			469 B
		
	
	
	
		
			BQN
		
	
	
	
	
	
| ⟨ReadDec⟩ ← •Import "../../lib.bqn"
 | ||
| enc ← ReadDec¨ •FLines "input"
 | ||
| 
 | ||
| CoordSum ← +´∘(1000‿2000‿3000⊸((⊢≠⊸|+⟜(⊑∘(/=⟜0)∘⊢))⊏⊢))
 | ||
| Mix ← {
 | ||
|   M ← {m 𝕊 i:
 | ||
|     l ← ≠m
 | ||
|     i {n ← (l-1)|(𝕩⊑m)+⊑/𝕩=𝕨 ⋄ (n⊸↑(∾⟜𝕩)⊸∾n⊸↓) 𝕩(≠/⊢)𝕨}˜´ ⌽↕l
 | ||
|   }
 | ||
|   CoordSum ((⊢M⍟𝕨↕∘≠)⊏⊢) 𝕩
 | ||
| }
 | ||
| •Out "day20.1: "∾•Fmt 1 Mix enc
 | ||
| •Out "day20.2: "∾•Fmt 10 Mix 811589153×enc
 |