A company sells iPods online. There are 100 stocks maintained at Argentina and Brazil. A single iPod costs $100 in Brazil and $50 in Argentina. The cost of exporting stocks from one country to the other will cost $400 per 10 blocks. The transportation is always done in the multiples of 10. Calculate the minimum cost for purchasing the given no of units. Assume that for each transaction, the available stock in each country is maintained to be 100.
Input and output format:
- The country from which the order is being placed: No of units
- Minimum costs:No of stock left in Brazil: No of stock left at Argentina
Sample input and output:
Brazil:5 500:95:100 Brazil:50 4500:100:50
class Country:
shp=40
def country_details(self,numberofitems,sellingprice):
self.sp=sellingprice
self.no=numberofitems
def display(self):
print self.sp
print self.no
print self.shp
Brazil=Country()
Brazil.country_details(100,100)
Brazil.display()
Argentina=Country()
Argentina.country_details(100,50)
Argentina.display()
print "Enter the country from which you order from"
x=raw_input()
if x=="Brazil":
c=1
else:
c=2
print "Enter the amount of products needed"
y=raw_input()
y=int(y)
def profit(y):
if c==1:
if y%10==0:
P=orderfromArgentinafb(y);
else:
P=orderfromBrazil(y);
if c==2:
P=orderfromArgentina(y);
return P
def calculate(y):
if (y<101):
Pr=profit(y)
return Pr
else:
Pr=profit(y-(y%100))+orderfromBrazil(y-100)
return Pr
def orderfromBrazil(y):
Cost=y*Brazil.sp
if c==2:
Cost=Cost+y*Brazil.shp
Brazil.no=Brazil.no-y
return Cost
def orderfromArgentina(y):
Cost=y*Argentina.sp
Argentina.no=Argentina.no-y
return Cost
def orderfromArgentinafb(y):
Cost=y*Argentina.sp+(y*Argentina.shp)
Argentina.no=Argentina.no-y
if Argentina.no <0:
Argentina.no=0
return Cost
Pr=calculate(y)
print Pr
print "%d:%d:%d" %(Pr,Brazil.no,Argentina.no)