MCPcopy Create free account
hub / github.com/asweigart/PythonStdioGames / isValidTowerConfiguration

Function isValidTowerConfiguration

tests/test_towerofhanoi.py:133–144  ·  view source on GitHub ↗
(towers)

Source from the content-addressed store, hash-verified

131 ' A B C\n\n'
132
133def isValidTowerConfiguration(towers):
134 # Make sure there are exactly 5 disks:
135 assert len(towers['A'] + towers['B'] + towers['C']) == 5
136
137 # Make sure there's only one disk of each size:
138 assert len(towers['A'] + towers['B'] + towers['C']) == len(set(towers['A'] + towers['B'] + towers['C']))
139 assert set(towers['A'] + towers['B'] + towers['C']) == set([1, 2, 3, 4, 5])
140
141 # Make sure a larger disk is not on a smaller disk:
142 for label in ('A', 'B', 'C'):
143 for i in range(len(towers[label]) - 1):
144 assert towers[label][i] > towers[label][i + 1]
145
146
147def test_randomMoves():

Callers 1

test_randomMovesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected