Data update
This commit is contained in:
parent
0df55f9f24
commit
aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions
10
Task/Happy-numbers/Uiua/happy-numbers.uiua
Normal file
10
Task/Happy-numbers/Uiua/happy-numbers.uiua
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
HC ← /+ⁿ2≡⋕°⋕ # Happiness calc = sum of squares of digits
|
||||
IH ← |2 memo⟨IH ⊙⊂.|=1⟩∊,, HC # Apply HC until seen value recurs
|
||||
Happy ← ⟨0◌|∘⟩IH : [1] . # Pre-load `seen` with 1. Return start number or 0
|
||||
|
||||
# Brute force approach isn't too bad with memoisation even for high bounds.
|
||||
↙8⊚>0≡Happy⇡10000
|
||||
|
||||
# But iterative approach is still much faster
|
||||
NH ← |1 ⟨NH|∘⟩≠0Happy.+1 # Find next Happy number
|
||||
⇌[⍥(NH.) 7 1]
|
||||
Loading…
Add table
Add a link
Reference in a new issue