diff options
Diffstat (limited to 'challenge-044/lubos-kolouch/python/ch-2.py')
| -rw-r--r-- | challenge-044/lubos-kolouch/python/ch-2.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/challenge-044/lubos-kolouch/python/ch-2.py b/challenge-044/lubos-kolouch/python/ch-2.py new file mode 100644 index 0000000000..4ad8efde17 --- /dev/null +++ b/challenge-044/lubos-kolouch/python/ch-2.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +goal = 200 # Target amount +current = 1 # Current amount +moves = 0 # Number of moves + +while current < goal: + # Check if doubling the current amount gets us closer to the goal + if current * 2 <= goal - current - 1: + current *= 2 + else: + current += 1 + moves += 1 + +print("To reach $", goal, ", you need", moves, "moves.") |
