June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -1,9 +1,14 @@
|
|||
function selfie(x)
|
||||
y = reverse(digits(x))
|
||||
len = length(y)
|
||||
sum(y) != len && return false
|
||||
for i = 1:len
|
||||
y[i] != sum(y .== i-1) && return false
|
||||
function selfie(x::Integer)
|
||||
ds = reverse(digits(x))
|
||||
if sum(ds) != length(ds) return false end
|
||||
for (i, d) in enumerate(ds)
|
||||
if d != sum(ds .== i - 1) return false end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
@show selfie(2020)
|
||||
@show selfie(2021)
|
||||
|
||||
selfies(x) = for i in 1:x selfie(i) && println(i) end
|
||||
@time selfies(4000000)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue