Created
August 29, 2021 21:07
-
-
Save goish135/1950a9932d957400d50a0905b3cfa884 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
type 0 : -(origimnal*amount/100) | |
type 1 : = amount | |
type 2 : - amount | |
''' | |
products = [ | |
['10','sale','january-sale'], | |
['200','sale','EMPTY'] | |
] | |
discounts = [ | |
['sale','0','10'], | |
['january-sale','1','10'] | |
] | |
#print(products[0][0]) | |
#print(products[1][0]) | |
ans = 0 | |
for i in range(len(products)): | |
#print("ORI:",products[i][0]) | |
minTmp = int(products[i][0]) | |
for j in range(1,len(products[i])): | |
#print("tag:",products[i][j]) | |
for k in discounts: | |
#print(k[0]) | |
if products[i][j]==k[0]: | |
#print(k[1]) # type | |
#print(k[2]) # amount | |
if k[1] == '0': | |
tmp=int(k[2]) | |
#print("tmp:",tmp) | |
if minTmp > tmp: | |
minTmp = tmp | |
if k[1] == '1': | |
tmp=int(products[i][0])-(int(products[i][0])*int(k[2])/100) | |
#print("tmp:",tmp) | |
if minTmp > tmp: | |
minTmp = tmp | |
#print("minTmp:",minTmp) | |
ans+=minTmp | |
print("ans:",ans) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment