From: Ben Harris Date: Wed, 29 May 2024 12:59:41 +0000 (+0100) Subject: 20a closer X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=f6ed13b0776d19af1064e1e83dcea1471428cad2;p=aoc-2022.git 20a closer Now the only problem is when a number lands precisely on the boundary. --- diff --git a/20/20a.bqn b/20/20a.bqn index 897c8ce..be328ad 100644 --- a/20/20a.bqn +++ b/20/20a.bqn @@ -3,8 +3,16 @@ Prep←•ParseFloat¨ Main←{ 𝕊 orig: •Show orig cur←orig - JumpFwd←{(1⊸⌽)⌾(((1+|𝕨)⊸↑)∘((⊑𝕩⊐𝕨)⊸⌽)) 𝕩} - Jump←{𝕨≥0 ? 𝕨 JumpFwd 𝕩; ⌽ 𝕨 JumpFwd ⌽𝕩} + #JumpFwd←{(1⊸⌽)⌾(((1+|𝕨)⊸↑)∘((⊑𝕩⊐𝕨)⊸⌽)) 𝕩} + #Jump←{𝕨≥0 ? 𝕨 JumpFwd 𝕩; ⌽ 𝕨 JumpFwd ⌽𝕩} + Jump←{ + from ← ⊑𝕩⊐𝕨 + to ← (¯1+≠𝕩)|𝕨+from + len ← to-from + •Show from‿to‿len + •Show ((1+|len)⊸↑∘((to⌊from)⊸↓)) 𝕩 + ((×len)⊸⌽) ⌾ ((1+|len)⊸↑∘((to⌊from)⊸↓)) 𝕩 + } { •Show cur ↩ 𝕩 Jump cur }¨orig