Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,8 @@
|
|||
>>> def isSelfDescribing(n):
|
||||
s = str(n)
|
||||
return all(s.count(str(i)) == int(ch) for i, ch in enumerate(s))
|
||||
|
||||
>>> [x for x in range(4000000) if isSelfDescribing(x)]
|
||||
[1210, 2020, 21200, 3211000]
|
||||
>>> [(x, isSelfDescribing(x)) for x in (1210, 2020, 21200, 3211000, 42101000, 521001000, 6210001000)]
|
||||
[(1210, True), (2020, True), (21200, True), (3211000, True), (42101000, True), (521001000, True), (6210001000, True)]
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
def impl(d, c, m):
|
||||
if m < 0: return
|
||||
if d == c[:len(d)]: print d
|
||||
for i in range(c[len(d)],m+1):
|
||||
dd = d+[i]
|
||||
if i<len(dd) and c[i]==dd[i]: continue
|
||||
impl(dd,c[:i]+[c[i]+1]+c[i+1:],m-i)
|
||||
|
||||
def self(n): impl([], [0]*(n+1), n)
|
||||
|
||||
self(10)
|
||||
Loading…
Add table
Add a link
Reference in a new issue