Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Also,
findIndex
is NOT the correct solution for the problem in the description.You're still solving the wrong problem.
Not a kata issue. Closing.
You can see the example tests. They're in the box under your solution, marked "Sample Tests". If you don't know which test you are failing, comment out all but one test at a time.
Yes, you are returning
Just 0
.Just 9
comes from that index. Any index that points to-4
would have been correct.Thanks for your reply.
I refreshed and retry, now there are more errors,
in example test:
Test Failed
expected: Just 3
but got: Just 1
cannot see the input so I don't know why this is failing
in random test:
Falsifiable (after 10 tests):
testing value at index Just 0
expected: Just (-4)
but got: Just 9
([9,-3,-3,2,-2,-8,-4,-2],5,Just (-4))
I am pretty sure my solution will return
Just 0
forleastLarger [9,-3,-3,2,-2,-8,-4,-2] 5
, I tried this onhttps://repl.it
, I am confused byexpected: Just (-4), but got: Just 9
, where does these numbers coming from..is any of these really the response from my solution?You are not returning "the least index of a number larger than the element at the given index," are you?
ETA: I have added an Example test for everybody who is doing this wrong ( you may have to refresh .. ). The existing tests did not fail on this. I now have added this to all languages.
ETA: Looks like you are. Also, it's called findIndex.
The
Just 1
you got in your own environment is the output from a function that delivers wrong results, so I cannot interpret that.I have updated the random tests to give an error message including the value solver returned ( you may have to refresh something(s) to see that ).
Keep in mind that multiple answers may be correct, so I can't test against a reference solution, I have to test that THE returned index points to A correct value in the array. Which is what is being tested.
Just 3
is the value at your returned index.Just (-1)
is the value at any correct index.Does this answer your questions?
As I understand it, in simple terms, Prolog is about searching for values that satisfy predicates. So the result is always something like
Alternative f => f Int
and the caller decides if it needs all results or any result. The Prolog way would probably be to require "returning" all results in the first place because it's up to the caller to get only one result when needed. So I'm not sure how this should be addressed in katas in general in this kind of cases.-1
looks as bad to me as it would be in Haskell, at the same time the possibility of having an empty set of solutions is directly linked with the possibility of having multiple solutions. So I just don't know...Falsifiable (after 6 tests):
expected: Just (-1)
but got: Just 3
([-2,3,0,-1,1],0,Just (-1))
I ran this
leastLarger [-2,3,0,-1,1] 0
in my environment and I gotJust(1)
, the error message is non-sense to me, where does thisgot Just 3
came form? and also I don't understand the expectationJust (-1)
mean?implementing mergesort using quicksort, seems legit.
Yep, if anyone else is stumped just reading the unit tests remember that the arrays are columns going down from left to right, for example:
The following mine:
mine = [[1,2,3], [4,5,6],[7,8,9]]
would not look likebut rather like:
This makes the right/left/up/down directions easier to visualise although it doesn't really affect the problem.
I have the same issue
moving to Right is D, it's not intuitive at all.
pageIndex [0] 1 -1 = Just 0
makes nonsense to me, I reckon nagative page number should getNothing