but im not expecting the value to check to be in the array, i find the index of the first element in the array which the value to search for is less than. the 1st solution should work.
edit- unless the 2 remaining cases should be at end of arr. in which case I am an idiot. Will check when on pc later
Your code being wrong is not a kata issue, see the sample test it fails and you'll see why it fails. The value to insert is not always already contained in the array that's why your code returns -1. About your second solution, it now fails 100% of the time.
About the edit, you're right, the value should be inserted at the end, and that's why it fails.
but im not expecting the value to check to be in the array, i find the index of the first element in the array which the value to search for is less than. the 1st solution should work.
edit- unless the 2 remaining cases should be at end of arr. in which case I am an idiot. Will check when on pc later
Fix for Julia
Your code being wrong is not a kata issue, see the sample test it fails and you'll see why it fails. The value to insert is not always already contained in the array that's why your code returns -1. About your second solution, it now fails 100% of the time.
This comment is hidden because it contains spoiler information about the solution
Needs random tests.
Also, I've seen something like this before. It may or may not be an exact duplicate ( ISTR indices in the other's
{}
templates ).