Floating-point equality check
Review this Python reconciliation check that a list of per-strategy allocation fractions sums to 1.0 before placing orders.
`weights` are fractions like `[0.1, 0.2, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]` that mathematically total 1.0.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.
0:00 of about 20 min
Mark a line and say what kind of problem it is.0 findings
1def is_fully_allocated(weights):
2 total = 0.0
3 for w in weights:
4 total += w
5 return total == 1.0
6
7def place_book(weights, orders):
8 if not is_fully_allocated(weights):
9 raise ValueError("allocation must sum to 100%")
10 for w, o in zip(weights, orders):
11 submit(o, size=w)
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.