solve 44 in uiua (fast)

This commit is contained in:
2025-10-04 08:26:46 +02:00
parent f7af716e7e
commit c582670d23

View File

@@ -1,10 +1,8 @@
# Experimental!
# project euler 44
p ← ÷2×⊸(-1×3)
c ← =0-⊸⌊°p
# ⧈₂/(↧∩c⊃+-) p +1⇡100
# ⍢+₁/(¬↥∩c⊃+-∩p) 1_2
# &p⟜/-p
⌊▽⊸(c∂p) +1.5⇡100000000
≡(p⊂⟜+₁)
▽⊸(c≡/+)
# pentagonal(n) ? n
P ← ÷2×⊸(-1×3)
# is_pentagonal(n) ? n
IsP ← =⌊°P
⧅<2 P+1⇡3000 # pentagonal number pairs
▽⊸(/(↧∩IsP⊃+-)⍉) # sum and diff are pent
/-⊢ # get first such (which is minimal)