You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We instruct students to return a range (like searchsorted does), but also we guarantee that there is only zero or one instance of the target value in the array unless the student enables the bonus tests. This is confusing.
IMHO, we should have the student provide their own implementations of searchsortedfirst (returns the index of the first value >= to the target, which is also the insertion index if you want to insert the target value in the array).
We can test the current behaviour (searchsorted-alike) in bonus tests or another exercise.
Students often come up with complicated solutions because they're doing too much work in the loop. We may want to provide a hint about that and/or link to a resource. Here's something I've posted a few times now to students:
Anyway, the key simplifying observation here is to simplify the body of your while loop so that you never return from it. Instead, arrange things so that you can always return low:high after the while loop and have it be correct.
You can read this article for details on how to do that.
The text was updated successfully, but these errors were encountered:
We instruct students to return a range (like
searchsorted
does), but also we guarantee that there is only zero or one instance of the target value in the array unless the student enables the bonus tests. This is confusing.IMHO, we should have the student provide their own implementations of
searchsortedfirst
(returns the index of the first value >= to the target, which is also the insertion index if you want to insert the target value in the array).We can test the current behaviour (
searchsorted
-alike) in bonus tests or another exercise.Students often come up with complicated solutions because they're doing too much work in the loop. We may want to provide a hint about that and/or link to a resource. Here's something I've posted a few times now to students:
The text was updated successfully, but these errors were encountered: