Ad
  • Custom User Avatar

    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.

  • Custom User Avatar
      it "random tests" $ do
        forAll gen $ \ (xs,i,expected) -> do
          -- print $ (xs,i,expected)
          let actual = leastLarger xs i
          (xs !!) <$> actual `shouldBe` expected $ "testing value at index " ++ show actual
    
  • Custom User Avatar

    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.

    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.

  • Custom User Avatar

    the index of the least number larger than the element at the given index

    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.

  • Custom User Avatar

    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?

  • Custom User Avatar

    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 like

      x0 x1 x2
    y0 1 2 3
    y1 4 5 6
    y2 7 8 9

    but rather like:

      x0 x1 x2
    y0 1 4 7
    y1 2 5 8
    y2 3 6 9

    This makes the right/left/up/down directions easier to visualise although it doesn't really affect the problem.