Eod.
This commit is contained in:
27
coloring/magic_series.py
Normal file
27
coloring/magic_series.py
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
|
||||
def is_magic_series(xs):
|
||||
counts = {i: 0 for i in range(0, 10)}
|
||||
for x in xs:
|
||||
counts[x] += 1
|
||||
for i, x in enumerate(xs):
|
||||
if not x == counts[i]:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def get_max_series(length):
|
||||
|
||||
def to_list(n):
|
||||
r = list(map(int, str(n)))
|
||||
return [0] * (length - len(r)) + r
|
||||
|
||||
cs = [to_list(i)
|
||||
for i in range(0, 10 ** length)
|
||||
if is_magic_series(to_list(i))]
|
||||
|
||||
return cs
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(get_max_series(5))
|
||||
Reference in New Issue
Block a user