Andrea and Maria solution in python

In this article Iam going to told you guys, the solution of the Andrea and Maria problem, which is the problem of  hackerrank.This solution is solved in python programming language.

First of all, participate in this competition.

But guys first you have to know the basics of python, it is important to understand and solve small problems to execute the programming codes easily on the system.

If you want help and want to learn python basics and data structure click here :-

Question :-

Now let’s see the problem of andrea and maria problem, which is given below here :-

Andrea and Maria each have a deck of numbered cards in a pile face down. They play a game where they each alternately discard and fip the cards on the pile from top to bottom.
At the beginning of the game, some one will call out EVEN or ODD. The first move depends on which is called.

If Even is called, then the players top cards are flipped so they can see the face value. If ODD is called, the top card is removed form each deck and discarded, then each flips her next card.

Andrea subtracts the value of Maria's card from her own and adds the result to their score. Likewise, Maria subtracts the value of Andrea's card from her own and adds the result to her score.

From this point forward, each alternately discards then flips a card. Each time two cards are flipped, the players scores are computed as before. Once all the cards have been played, whoever hast he most points wins.

 Marias Card Andreas Card Maria's Score Andrea's Score 3 4 3-4 = -1 4-3 = 1 5 5 Discard Discard 6 7 6-7 = 1 7-6 = 1

Solution :-

create a  function Winner in python programming language.the main working is done by this python function.

Function must return a string denoting the outcome in the game.

This program atlast return some values for, given some outputs below :-

·        Return Anrea if Anrea has won
·        Return Maria if Maria has won
·        If there scores are tied, return x

def winner (andrea, maria, x) :
temp
print(temp)

count = func(func1(temp))

for i in range(0,count):
item
print(item)

item1 = func(func1(item))

andrea[i] = item1

temp1
print(temp1)

count1 = func(func1(temp1))

for i in range(0,count1):
item2
print(item2)

item3 = func(func1(item3))

maria[i] = item3

def func(*str):
x(str)

x.erase(x.begin(),find_if(x.begin(), x.end(), not1(ptr_fun(isspace)))
)

return x

def func1(*str):
x(str)

x.erase(
find_if(x.rbegin(), x.rend(), not1(ptr_fun(isspace))).base(),
x.end()
)

return x

print(x)
result = winner(andrea, maria, x)

print(result)

If you Guy’s like this article plz plz comment here or if you all want solutions of some problems then comment  . . . . .