Skip to content

Commit 999b3d5

Browse files
authored
Update sum-of-k-mirror-numbers.py
1 parent 61ba594 commit 999b3d5

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

Python/sum-of-k-mirror-numbers.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ def mirror(n, base, odd):
1818
return result
1919

2020
def num_gen(base):
21-
prefix_num, cnt, total = [1]*2, [0]*2, [base-1]*2
21+
prefix_num, total = [1]*2, [base]*2
2222
odd = 1
2323
while True:
2424
x = mirror(prefix_num[odd], base, odd)
2525
prefix_num[odd] += 1
26-
cnt[odd] += 1
27-
if cnt[odd] == total[odd]:
28-
cnt[odd] = 0
26+
if prefix_num[odd] == total[odd]:
2927
total[odd] *= base
3028
odd ^= 1
3129
yield x

0 commit comments

Comments
 (0)