Hackerrank Taum and B'day Solution

This is the solution for the Taum and B'day problem in python 2, which can be found in the implementation section of the Algorithm domain. In this problem you will have T test cases,There are two types of gifts that Diksha wants from Taum: one is black and the other is white. To make her happy, Taum has to buy B number of black gifts and W number of white gifts.
  • The cost of each black gift is X units.
  • The cost of every white gift is Y units.
  • The cost of converting each black gift into white gift or vice versa is Z units.
You need to help Taum by deducing the minimum amount he needs to spend on Diksha's gifts.

Screenshots[Demo]


The Code:

def bday(x,y):
 if(y[2]+y[1]<y[0]):
  print (x[0]*(y[2]+y[1]))+(x[1]*y[1])
 elif(y[2]+y[0]<y[1]):
  print (x[1]*(y[2]+y[0]))+(x[0]*y[0])
 else:
  print (x[0]*y[0])+(x[1]*y[1])
for i in range(0,input()):
 x=map(int,raw_input().split())
 y=map(int,raw_input().split());
 bday(x,y)


Found Bugs, Please Report !
We will be glad to fix them ! ;)

Comments

Popular posts from this blog

Non Restoring Division Algorithm Implementation in C

Hackerrank Modified Kaprekar Numbers Solution

Bit Stuffing Code Implementation in Java