Advertisement
here2share

# increment_smallest_digit.py

Jun 20th, 2024
475
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. # increment_smallest_digit.py
  2.  
  3. def increment_smallest_digit(chars):
  4.     chars = list(chars)
  5.     smallest_digit = min(chars)
  6.     smallest_digit_index = chars.index(smallest_digit)
  7.     incremented_digit = chr(ord(smallest_digit) + 1)
  8.     chars[smallest_digit_index] = incremented_digit
  9.     return ''.join(chars)
  10.  
  11. import random
  12.  
  13. sss = list('00112233445566778899')
  14. for i in '.'*20:
  15.     random.shuffle(sss)
  16.     s = ''.join(sss[:4])
  17.     print(s, increment_smallest_digit(s))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement