Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Crack the Lock in python 3 Steve and Harvey have participated in a reality show and both of them are qualified for the final and
Crack the Lock in python
Steve and Harvey have participated in a reality show and both of them are qualified for the final and playing a game against each other for the prize. In the game, they are given with N keys. where N keys are silver coated and one is gold plated. P is the position of the gold plated key which is the correct key. While playing the game, Steve and Harvey have to take turns and in each turn, they have to choose consecutive M keys which should include the gold key, and reverse their order. To win the game, one has to put the gold plated key in the position of X Steve starts the game.
Your task is to determine the winner of the game. The game may end in a draw. Assume that Steve and Harvey play optimally.
Note: Indexing is based.
The first line of input contains an integer N representing the number of keys.
The second line of input contains an integer P representing the position of the goldplated key.
The third line of input contains an integer M representing the number of consecutive keys that need to be reversed
The fourth line of input contains an integer X representing the winning position.
Output
Print the name of the player who winsLe 'Steve' or "Harvey or 'Draw if the game ends in a draw.
Constraints
N P M
Example #
Input
Output expected
Draw
Explanation: There are four keys in total. The first one is a gold plated key. On each turn, players must choose two consecutive keys and reverse their order. The winning position is
Steve starts playing the game and the only move he is able to make is to take the first two keys and reverse their order. The gold plated key will be in position
After that Harvey will choose the first two keys again and reverse them back to put the gold plated key in position On the other hand, he could have reversed the order of the nd and the rd keys, but on his next turn. Steve would be able to put the gold plated key from position to position and win the game.
The previous two moves will be played infinitely in an optimal game so neither Steve nor Harvey will be able to win the game.
Example #:
Input
output
Steve
Explanation: There are three keys in total. The first one is a goldplated key. On each turn, players must choose two consecutive keys and reverse their order. The winning position is two. Steve starts playing the game, so he can just choose the first two keys and reverse their order. In this turn, he will be able to put a gold key on the winning position. The answer is Steve.
Steve starts playing the game and the only move he is able to make is to take the first two keys and reverse their order. The gold plated key will be in position
Maximize
After that Harvey will choose the first two keys again and reverse them back to put the gold plated key in position On the other hand, he could have reversed the order of the nd and the rd keys, but on his ext turn. Steve would be able to put the gold plated key from position: to position and win the game.
The previous two moves will be played infinitely in an optimal game so neither Steve nor Harvey will be able to win the game.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started