From 68555896de3510c560587433acec3470e289c999 Mon Sep 17 00:00:00 2001 From: sterni Date: Tue, 20 Dec 2022 19:51:21 +0100 Subject: feat(sterni/aoc/2022): day20 BQN solution 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 Autosubmit: sterni Tested-by: BuildkiteCI --- users/sterni/exercises/aoc/2022/20/20.bqn | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 users/sterni/exercises/aoc/2022/20/20.bqn diff --git a/users/sterni/exercises/aoc/2022/20/20.bqn b/users/sterni/exercises/aoc/2022/20/20.bqn new file mode 100644 index 000000000000..8d4c905e8749 --- /dev/null +++ b/users/sterni/exercises/aoc/2022/20/20.bqn @@ -0,0 +1,13 @@ +⟨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 -- cgit 1.4.1