Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def all_turns():
- turns = []
- for a in ashots:
- for b in ashots:
- for c in ashots:
- turns.append([a, b, c])
- turns.remove([0, 0, 0]) # avoid inf. scenarios
- return turns
- def end_turns():
- turns = []
- for a in ashots:
- for b in ashots:
- for c in eshots:
- turns.append([a, b, c])
- for b in eshots:
- turns.append([a, b])
- for a in eshots:
- turns.append([a])
- return turns
- def end_shots():
- shots = {50}
- for i in range(1, 21):
- shots.add(i)
- return shots
- def all_shots():
- shots = {0, 25, 50}
- for i in range(1, 21):
- shots.add(i)
- shots.add(i*2)
- shots.add(i*3)
- return shots
- ashots = all_shots()
- eshots = end_shots()
- aturns = all_turns()
- eturns = end_turns()
- max_score = 300
- def find_backtrack():
- from_turn([])
- def from_turn(turn):
- for et in eturns:
- if max_score == sum(turn) + sum(et):
- print(turn)
- break
- for at in aturns:
- if max_score > sum(turn) + sum(at):
- from_turn(turn+at)
- if __name__ == '__main__':
- find_backtrack()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement