Thanks for catching this. But this doesn't explain why the code passes the Test Sets all but once.
On Monday, 20 April 2020 18:09:47 UTC-4, porker2008 wrote: > > Also, your *binary_search_right()* is incorrect, it fails when *left = > 10**9 - 1* and *func(10**9)* is *HIT* > In this case, it returns *10**9 - 1* instead of *10**9* > > Wrong implementation: > *def binary_search_right(self, left, func):* > * right = 10**9* > * while left < right:* > * m = (left + right) // 2* > * f = func(m)* > * if f == 'HIT':* > * left = m + 1* > * elif f == 'MISS':* > * right = m* > * else:* > * return None* > * return right - 1* > > > Correct implementation: > *def binary_search_right(self, left, func):* > * right = 10**9* > * while left < right:* > * m = (left + right + 1) // 2* > * f = func(m)* > * if f == 'HIT':* > * left = m* > * elif f == 'MISS':* > * right = m - 1* > * else:* > * return None* > * return right* > -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-code+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/9192fce1-d37c-4471-8931-7cefb228f94c%40googlegroups.com.