1class RunewordsCalculator:
2 def __init__(self, runeword_recipes):
3 self.runeword_recipes = dict(runeword_recipes)
4 self.runes = []
5
6 def __iter__(self):
7 return self
8
9 def __next__(self):
10 if not self.runeword_recipes:
11 raise StopIteration
12 for runeword, recipe in self.runeword_recipes.items():
13 runes_iter = iter(self.runes)
14 if all(any(current_rune == needed_rune for current_rune in runes_iter) for needed_rune in recipe):
15 self.runeword_recipes.pop(runeword)
16 return runeword
17
18 def add_runes(self, runes):
19 self.runes.extend(runes)
.......
----------------------------------------------------------------------
Ran 7 tests in 0.000s
OK