Ad
  • Custom User Avatar

    I see it now, thanks to your comment I was able to come up with a solution that solved this kata, it is probably not the best solution but I will try to refactor and improve it. Thanks a lot!

  • Custom User Avatar
    @lazy(-2)
    def f():
        return 56
    
    print([f() for _ in range(10)])
    

    I think you agree it shouldn't do this:

    [56, None, 56, 56, 56, 56, 56, 56, 56, 56]

  • Custom User Avatar

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

  • Custom User Avatar

    For i=2, j=5 it should be a normal function (ie. 56). And the test case should support that. The asserted value is found with val = 56 if j%i else None, which evaluates to 56.

    Could you post the solution you are trying to make work?

  • Custom User Avatar

    Aside from a small bit of syntax sugar, it's not very specific to python:

    @lazy(2)
    def f(): pass
    

    is equivalent to:

    def f(): pass
    f = lazy(2)(f)
    
  • Custom User Avatar

    Hello, I've been trying to pass the test cases however I'm facing some errors in the negative number situation.

    For the input with @lazy(-2) and i = 2 and j = 5 (that is the 5th call) it is saying that it should be None.
    However, the following calls passed:

    • 2 1 56
    • 2 2 None
    • 2 3 56
    • 2 4 None

    The next is the one that I described before, should it really be None? Since it the 1st call after a lazy call and n == -2