mirror of
https://github.com/Xevion/exercism.git
synced 2025-12-06 09:14:59 -06:00
'init'
This commit is contained in:
17
python/robot-name/robot_name.py
Normal file
17
python/robot-name/robot_name.py
Normal file
@@ -0,0 +1,17 @@
|
||||
from random import choices
|
||||
from string import ascii_uppercase
|
||||
from itertools import product
|
||||
from random import shuffle
|
||||
|
||||
nums = (str(x).zfill(3) for x in range(1000))
|
||||
front = (''.join(fr) for fr in product(ascii_uppercase, ascii_uppercase))
|
||||
names = [l + n for l, n in product(front, nums)]
|
||||
shuffle(names)
|
||||
name_iter = iter(names)
|
||||
|
||||
class Robot(object):
|
||||
def __init__(self):
|
||||
self.reset()
|
||||
|
||||
def reset(self):
|
||||
self.name = next(name_iter)
|
||||
Reference in New Issue
Block a user