chiark / gitweb /
20a done
authorBen Harris <bjh21@bjh21.me.uk>
Thu, 30 May 2024 19:45:16 +0000 (20:45 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Thu, 30 May 2024 19:45:16 +0000 (20:45 +0100)
Thanks to cardboard Verity for providing the answer, which is that it
doesn't matter where the start of the list is: everything treats it as
circular.

20/20a.bqn

index a7686ae7c76684c9e83a1e5a03fbb7f41048098e..26218d9dc27296238ea65ff456838c798d642065 100644 (file)
@@ -1,14 +1,8 @@
 Prep←•ParseFloat¨
 
 Main←{ 𝕊 orig:
-  Wrap←{1+(𝕨-1)|𝕩-1}
-  Jump←{
-    from ← ⊑𝕩⊐𝕨
-    to ← (≠𝕩) Wrap 𝕨+from
-    len ← to-from
-    ((×len)⊸⌽) ⌾ ((1+|len)⊸↑∘((to⌊from)⊸↓)) 𝕩
-  }
-  cur ← orig Jump´ ⌽orig
+  Twiddle←{ (1⊸⌽)⌾((1+(¯1+≠𝕩)|𝕨)⊸↑) (⊑𝕩⊐𝕨)⌽𝕩 }
+  cur ← orig Twiddle´ ⌽orig
   +´((≠cur)|(cur⊐0)+⟨1000,2000,3000⟩)⊏cur
 }