Write A Python Program, Using Circular Array Suppose You Have Been Hired To Develop A Musical Chair Game. In This Game There....


Statement: 
Write a python program, using circular array
Suppose you have been hired to develop a musical chair game. In this game there will be 7 participants and all of them will be moving clockwise around a set of 7 chairs organized in a circular manner while a music will be played in the background. You will control the music using random numbers between 0-3.If the generated random number is 1, you will stop the music and if the number of participants who are still in the game is n, the participant at position (n/2) will be eliminated. Each time a participant is eliminated, a chair will be removed and you have to print the player names who are still in the game. The game will end when there will be only one participant left. At the end of the game, display the name of the winner.
[Hint: You will need to invoke a method to generate a random number between 0 (inclusive) to 3 (inclusive)]

Solution:
def get_max_circ_sarray(arr):
warr = arr * 2

items = []
csum = msum = 0

for num in warr:
while len(items) >= len(arr) or (items and items[0] < 1):
csum -= items[0]
items = items[1:]

items.append(num)
csum += num

msum = max(msum, csum)

return msum


# Tests
assert get_max_circ_sarray([8, -1, 3, 4]) == 15
assert get_max_circ_sarray([-4, 5, 1, 0]) == 6

2 Comments

  1. Great job, this is essential information that is shared by you. This information is meaningful and very important for us to increase our knowledge about it. Always keep sharing this type of information. Thanks once again for sharing it.

    Casino Game Development Company.

    ReplyDelete
Previous Post Next Post