Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
27
Task/Self-describing-numbers/CLU/self-describing-numbers.clu
Normal file
27
Task/Self-describing-numbers/CLU/self-describing-numbers.clu
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
self_describing = proc (n: int) returns (bool)
|
||||
digits: array[int] := array[int]$predict(10, 10)
|
||||
counts: array[int] := array[int]$fill(0, 10, 0)
|
||||
|
||||
while n > 0 do
|
||||
digit: int := n // 10
|
||||
n := n/10
|
||||
array[int]$addl(digits, digit)
|
||||
counts[digit] := counts[digit] + 1
|
||||
end
|
||||
|
||||
array[int]$set_low(digits, 0)
|
||||
|
||||
for pos: int in array[int]$indexes(digits) do
|
||||
if counts[pos] ~= digits[pos] then return(false) end
|
||||
end
|
||||
return(true)
|
||||
end self_describing
|
||||
|
||||
start_up = proc ()
|
||||
po: stream := stream$primary_output()
|
||||
for n: int in int$from_to(1, 100000000) do
|
||||
if self_describing(n) then
|
||||
stream$putl(po, int$unparse(n))
|
||||
end
|
||||
end
|
||||
end start_up
|
||||
Loading…
Add table
Add a link
Reference in a new issue