In [ ]:
function isallodd(n)
str = dec(n)
for i=1:length(str)
if iseven(Int(str[i]))
return false
end
end
return true
end
function s(n, nset)
str = dec(n)
if str[end] == "0" # Reverse with LZ not allowed
return 0
end
n2 = n + parse(Int, reverse(str))
push!(nset, n)
push!(nset, n2)
return isallodd(n2)
end
function dos(n)
cnt = 0
nset = Set()
for i=10:n
if in(i, nset)
continue # Ignore
end
if s(i, nset)
cnt += 1
end
end
return cnt
end
In [ ]:
dos(999)
In [ ]:
in(36, nset)
In [ ]: