Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # base_counter.py
- def base_counter(count, base=10):
- size = len(count)
- idx = size - 1
- while idx > -1:
- if count[idx] == base:
- if len(set(count)) == 1:
- return [0] * (size + 1)
- count[idx] = 0
- idx -= 1
- else:
- count[idx] += 1
- break
- return count
- # Example usage
- count = [0]
- for _ in range(100):
- print(count)
- count = base_counter(count, 3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement