Closed muritz closed 1 year ago
Hello. Thanks for opening an issue on Exercism. We are currently in a phase of our journey where we have paused community contributions to allow us to take a breather and redesign our community model. You can learn more in this blog post. As such, all issues and PRs in this repository are being automatically closed.
That doesn't mean we're not interested in your ideas, or that if you're stuck on something we don't want to help. The best place to discuss things is with our community on the Exercism Community Forum. You can use this link%0D%0A%20%20%20%20%20%20%20%20#%20fails%20=%3E%20self.assertEqual(find(%5B1,%203,%204,%206,%208,%209,%2011%5D,%204),%202)%0D%0A%20%20%20%20%20%20%20%20#%20fails%20=%3E%20self.assertEqual(find(%5B1,%203,%204,%206,%208,%209,%2011%5D,%208),%204)%0D%0A%60%60%60%0D%0AI%20still%20don't%20understand,%20why%20my%20code%20behaves%20like%20that%20and%20I%20am%20not%20proficient%20enough,%20to%20help%20solve%20this%20issue%20in%20the%20testing.%0D%0A%0D%0AFor%20reference,%20here%20is%20my%20code,%20but%20I%20don't%20expect%20it%20to%20be%20solved%20here.%20I%20just%20want%20the%20test%20to%20catch%20errors%20in%20the%20code%0D%0A%0D%0AThanks%20Murat%0D%0A%0D%0A%0D%0A%60%60%60%0D%0Adef%20find(search_list:%20list%5Bint%5D,%20value:%20int)%20-%3E%20int:%0D%0A%20%20%20%20sorted_list%20=%20sorted(search_list)%0D%0A%0D%0A%20%20%20%20left,%20right%20=%200,%20len(search_list)%20-%201%0D%0A%0D%0A%20%20%20%20if%20not%20search_list:%0D%0A%20%20%20%20%20%20%20%20raise%20ValueError(%22value%20not%20in%20array%22)%0D%0A%20%20%20%20if%20search_list%5B0%5D%20==%20value:%0D%0A%20%20%20%20%20%20%20%20return%200%0D%0A%20%20%20%20elif%20search_list%5B-1%5D%20==%20value:%0D%0A%20%20%20%20%20%20%20%20return%20len(search_list)%20-%201%0D%0A%20%20%20%20while%20left%20%3C%20right:%0D%0A%20%20%20%20%20%20%20%20mid%20=%20left%20+%20(right%20-%20left)%20//%202%0D%0A%20%20%20%20%20%20%20%20if%20sorted_list%5Bmid%5D%20==%20value:%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20mid%0D%0A%20%20%20%20%20%20%20%20elif%20sorted_list%5Bmid%5D%20%3C%20value:%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20left%20=%20mid%20+%201%0D%0A%20%20%20%20%20%20%20%20else:%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20right%20=%20mid%20-%201%0D%0A%0D%0A%20%20%20%20raise%20ValueError(%22value%20not%20in%20array%22)%0D%0A%60%60%60%0D%0A&category=python) to copy this into a new topic there.
Note: If this issue has been pre-approved, please link back to this issue on the forum thread and a maintainer or staff member will reopen it.
Hi, this is my first issue, so be easy on me, if I make any formal mistake.
I successfully submitted my solution to binary search. However I came across a strange behaviour in my own dev environment. Although the values
4 and 8
are contained in the list[1, 3, 4, 6, 8, 9, 11]
, my code raisesValueError("value not in array")
only on these two values. Because these values are not tested explicitly, the code passes the test.I tested out the values by manually changing the
binary_search_test.py
values and as expected, the test didn't pass, see code.This is the test file on GitHub https://github.com/exercism/python/blob/main/exercises/practice/binary-search/binary_search_test.py Test starts at
line17
I still don't understand, why my code behaves like that and I am not proficient enough, to help solve this issue in the testing.
For reference, here is my code, but I don't expect it to be solved here. I just want the test to catch errors in the code
Thanks Murat