26 lines
599 B
Plaintext
26 lines
599 B
Plaintext
numbers = [12, 1210, 1300, 2020, 21200, 5]
|
|
|
|
occurrences = function(test, values)
|
|
count = 0
|
|
for i in values
|
|
if i.val == test then count = count + 1
|
|
end for
|
|
return count
|
|
end function
|
|
|
|
for number in numbers
|
|
check = "" + number
|
|
digits = check.values
|
|
describing = true
|
|
for digit in digits.indexes
|
|
if digits[digit].val != occurrences(digit, digits) then
|
|
describing = false
|
|
end if
|
|
end for
|
|
if describing then
|
|
print number + " is self describing"
|
|
else
|
|
print number + " is not self describing"
|
|
end if
|
|
end for
|