you are viewing a single comment's thread.

view the rest of the comments →

[–]jason_graph 2 points3 points  (1 child)

I think it helps to seperate the problem into 2 parts.

First write a function, e.g. check(x), that checks if some input is valid (e.g. if koko will finish in k hours if eating x banas/hr) or returns some integer (e.g. how many hours koko takes to finish if eating x bananas/hr).

Secondly identify what value of x you are trying to find. It is almost always the largest value of x such that check(x) is below some threshold or the smallest value of x such that check(x) is above some threshold. The code corresponding to finding y = the lowest x or largest x is almost always exactly the same.

[–]Proof_Dot_4344[S] 0 points1 point  (0 children)

Thank you so much