注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
Part one:
Given parts, bank_currency, transactions(“2023-01-05,USD,300”) do the exchange and subtract 2%stripe fee and print out the amount to pay for each currency. (USD,724)
Part two:
Chronological -> Alphabetical order, now print out date as well. Each currency has a certain delay
python大概思路,之后写的不太记得交的是什么了,参考就行
def transaction(parts, bank_currencies, transactions):
usd_to_cur_map = {"EUR": 1.02, "SGD": 1.43, "HKD": 7.85, "USD": 1}
if parts == "part_one":
#ans_map = defaultdict(int)
for t in transactions:
t_array = t.splival * 0.98))))
else:
exchanged_val = 0.98 * t_val * usd_to_cur_map[bank_currencies[0]] / usd_to_cur_map[t_cur]
ans.append((new_time + "," + bank_currencies[0] + "," + str(round(exchanged_val))))
s = sorted(ans, key = lambda x: (x[:10], x[11:14]))
print(s) |