Answered step by step
Verified Expert Solution
Link Copied!

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 python3
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-1 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 1-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 gold-plated 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 wins(Le.. 'Steve' or "Harvey), or 'Draw if the game ends in a draw.
Constraints
1<= N. P. M <=106
Example #1
Input
4
1
2
4
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 4.
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 2.
After that Harvey will choose the first two keys again and reverse them back to put the gold plated key in position 1. On the other hand, he could have reversed the order of the 2nd and the 3rd keys, but on his next turn. Steve would be able to put the gold plated key from position 3 to position 4 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 #2:
Input
3
1
2
2
output
Steve
Explanation: There are three 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 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 2
Maximize
After that Harvey will choose the first two keys again and reverse them back to put the gold plated key in position 1. On the other hand, he could have reversed the order of the 2nd and the 3rd keys, but on his ext turn. Steve would be able to put the gold plated key from position: 3 to position 4 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

C++ Database Development

Authors: Al Stevens

1st Edition

1558283579, 978-1558283572

More Books

Students also viewed these Databases questions