Ad
  • Default User Avatar

    I've approved it, but there was a typo in sample tests which I oversaw (nil instead of None). :/ There's a fork with a fix, as the author disabled contribution. Can you please approve the fork?

    Feel free to fork and make other changes.

    Thanks,

    suic

  • Custom User Avatar

    Solved:
    just declare nil before function

  • Custom User Avatar

    Nil is not undefined, what might be the problem here?
    I tried to return None,empty list and 0

  • Custom User Avatar
  • Custom User Avatar

    correction: the issue is actually that the default version is set to py2 while other versions are available. So just select the good one in the edit panel.

  • Custom User Avatar

    python:

    • sample tests: test.assert_equals(find_2nd_largest([1,1,1,1,1,1,1]), nil, 'expected nil') (lol...)
    • python 3 should be enabled. Because...
    • requirement doesn't fit the implementation:

    rejecting non integers

    tho: 1 should equal 3333333333333333333334L -> except that in python 2, that's not an integer that's a long (ok,, I'm nitpicking, here. But what's the point of having this difference only because of the outdated opython version...?)

  • Default User Avatar

    My code seems to try to return 'nil' in all the right cases but "NameError: global name 'nil' is not defined" is generated. Not sure what to do about it.

  • Default User Avatar

    OK. I can see your comment now. I will refactor the solution. Thanks.

  • Default User Avatar

    Why doesn't the system let me see the solutions by other members? It does show my solution as valid in "My solutions". It's been about 18 hours now since I posted it.

  • Custom User Avatar

    because there were some typos in the snippet, sorry (I didn't check it before posting x) ).

    This one is working in py3.6:

    def assertFloatArrayEqual(actual, expected, epsilon=1e-9):
        try:
            test.assert_equals(len(actual), len(expected), "Expected and actual differ in length")
            test.expect(all(abs(a-b)<epsilon for a,b in zip(actual,expected)), f"{actual} should equal {expected} (margin={epsilon})")
        except Exception as e:
            test.fail("something went wrong")
            raise e
    

    tho, you'll still nee'd to implement the part that will handle the None case.

  • Default User Avatar

    Keep getting error with the exception handeling when trying to implement assertFloatArrayEqual into test cases. I just moved to 3.6 so not sure if it is something I am doing wrong or if I am just missing something.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    you talk about stuff that isn't written in there. I'm supposed to be in your head? How nice of you...

  • Custom User Avatar

    Initially the error message in my example was f"Wrong value at index {i}" (which is why there is was enumerate in my snippet) but such error message would be useless too, as the user would be notified of a single mismatch, but wouldn't see whether there're any more wrong values.

    At what index? What actually are those arrays? values? lengths?

    And this becomes insignificant because actual and expected arrays are shown together with the X should be approximately equal to Y... message.

  • Custom User Avatar
  • Loading more items...