Quant Memo
Coding/●●●●●

First bad build

Your nightly backtest passed on build 1 but fails on build n. Builds are cumulative: once a build is bad, every later build is also bad. You have a function is_bad(v) that runs the backtest against build v, but each call takes twenty minutes.

n = 10, builds:  G G G B B B B B B B
is_bad(4) -> True, is_bad(3) -> False
answer: 4

Find the first bad build using O(logn)O(\log n) calls to is_bad.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions