-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2020-02-25.py
31 lines (26 loc) · 864 Bytes
/
2020-02-25.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
Suppose you are given a table of currency exchange rates, represented as a 2D array.
Determine whether there is a possible arbitrage: that is, whether there is some sequence of
trades you can make, starting with some amount A of any currency, so that you can end up
with some amount greater than A of that currency.
There are no transaction costs and you can trade fractional quantities.
"""
import sys
from typing import List
Matrix = List[List[int]]
def arbitrage(costs: Matrix) -> int:
"""
st A B C A
:param costs:
:return:
"""
rows = len(costs)
cols = len(costs[0])
distance: Matrix = [[sys.maxsize for _ in range(cols)] for _ in range(rows)]
for st in range(rows):
queue = [st]
while len(queue) > 0:
pass
pass
if __name__ == "__main__":
assert arbitrage([[1, 2], [0.3, 1]]) > 0