Advertisement
here2share

# base_counter.py

Jan 12th, 2025
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. # base_counter.py
  2.  
  3. def base_counter(count, base=10):
  4.     size = len(count)
  5.     idx = size - 1
  6.     while idx > -1:
  7.         if count[idx] == base:
  8.             if len(set(count)) == 1:
  9.                 return [0] * (size + 1)
  10.             count[idx] = 0
  11.             idx -= 1
  12.         else:
  13.             count[idx] += 1
  14.             break
  15.     return count
  16.  
  17. # Example usage
  18. count = [0]
  19. for _ in range(100):
  20.     print(count)
  21.     count = base_counter(count, 3)
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement