Created
April 18, 2019 14:02
-
-
Save davegotz/61c04741c7cf58b1e6aced38f3327b9f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Tower: | |
| def __init__(self): | |
| self.discs = [] | |
| def add_disc(self, disc_to_add): | |
| self.discs.append(disc_to_add) | |
| def remove_disc(self): | |
| return self.discs.pop() | |
| def __str__(self): | |
| return str(self.discs) | |
| class TowersOfHanoi: | |
| def __init__(self, num_of_discs): | |
| # Create towers. | |
| self.towers = {'left': Tower(), 'middle': Tower(), 'right': Tower()} | |
| # Create discs | |
| self.game_size = num_of_discs | |
| for disc in range(num_of_discs, 0, -1): | |
| self.towers['left'].add_disc(disc) | |
| def solve_game(self): | |
| print("To be implemented...") | |
| def __str__(self): | |
| tower_as_str = "LEFT: " + str(self.towers['left']) | |
| tower_as_str += "\nMIDDLE: " + str(self.towers['middle']) | |
| tower_as_str += "\nRIGHT: " + str(self.towers['right']) | |
| return tower_as_str | |
| def main(): | |
| game = TowersOfHanoi(5) | |
| print(game) | |
| main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment