Ad
  • Default User Avatar

    to be honest the most part of that algorythm was found on the net. I just modified it a bit to improve the performance. But it's like life , you start from known bases and you improve it ;).

  • Custom User Avatar

    I love the performance on this! It's really efficient, and inspiring!

  • Default User Avatar

    the prob is that you gave code not only definition. That code mislead me because I naively think you wanted we used that code. Perhaps just give only definition and not code or precise that the code you give is not efficient on CW web site (btw that code is perfectively fine on my computer even with very big number)

  • Default User Avatar

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

  • Default User Avatar

    @hobovsky : when i say i use python 3.8 it was on my computer not on teh web site. I also think you have misunderstood me : I had the timeout message on the 'Test' when you obviously show me the 'Attempt' result.
    Test use 17 tests : CWtest .

    @ecolban : you are a naughty boy. I finally understand where come the message of 'Times out' = that comes from your code to caculate totients (G = {i for i in range(1, m) if gcd(i, m) == 1}). If i used anotehr method all is good

  • Default User Avatar

    FYI, I just reran one of my past solutions, which completed the 200 tests in less than a second on the server.

  • Custom User Avatar

    I wonder what we two do differently, because first of all, Python 3.8 version is unavailable for me here on CW, I can select only 3.6. When I do so, I submit following dummy solution:

    def tower(base, h, m):
        return 1
    

    what obviously makes all tests fail, but it gives some potentially useful output which I pasted here. It's not really interesting except last ~30 cases with big numbers, which you could use for benchmarking.

    Unfortunately I haven't solved the kata yet so I won't ask you for your code, but if your benchmarks run locally on above inputs efficiently but still timeout on CW, you might want to ask for help on kata solving channel.

  • Default User Avatar

    Sadly your tips do not work.
    when i return 1 and print the args i have only the test case shown in the "'sample test" (around 16 tests) windows and i have already test tehm with success
    %%timeit
    tower(3,4,1001)
    tower(729, 0, 1)
    tower(729, 0, 2)
    tower(1, 897, 8934279)
    tower(3, 3, 25)
    tower(2, 2, 1000)
    tower(2, 3, 100000)
    tower(2, 4, 100000000)
    tower(4, 2, 10000000)
    tower(4, 3, 10)
    tower(7, 1, 5)
    tower(28, 3, 25)
    tower(28 % 25, 3, 25)
    tower(13, 3, 31)
    pow(13, tower(13, 2, 31), 31)
    tower(13, 3, 31)
    pow(13, tower(13, 2, 30), 31)
    tower(13, 3, 31)
    pow(13, 30 + tower(13, 2, 30), 31)
    m = 1001
    t_3_3 = 3 ** 3 ** 3
    t_3_4 = pow(3, t_3_3, m)
    tower(3, 4, m)
    t_2_4 = pow(2, 2 ** 2 ** 2)
    t_2_5 = pow(2, t_2_4, 720)
    t_2_6 = pow(2, 720 + t_2_5, m)
    tower(2, 6, m)
    =>
    10 µs ± 765 ns per loop (mean ± std. dev. of 7 runs, 1 loop each)

  • Custom User Avatar

    I have not solved the kata in Python, but you could try following things:

    • first, return some dummy value from your function (for example, return 1 should do). All tests will fail, but you will see how many of them is there and what are parameters used. As far as I see, there's 200 test cases.
    • check your solution locally for similar amount of tests with similar parameters. Measuring your solution only once is not very relevant, your solution might be fast for this one particular input, but could be sloooow for other inputs.
    • If test title does not show parameters, you can print them, and then recreate problematic cases locally to see if your solution handles them efficiently.
  • Default User Avatar

    Hi everybody,
    I do not understand why I have an "Execution Time Out" when I do the tests on the server since all is fine at home.
    I do not use brute force.
    when I use the maximum value allowed by the instructions :

    tower(int(1e20),int(1e20),10000000)

    the result is obtained in 703 ns ± 6.63 ns

    When I do all the tests shown in the SampleTests part, the tests are ended in 10 µs ± 765 ns

    any idea that can help me solve that Time prob?

    I use python 3.8

  • Custom User Avatar

    because in that kata, the restriction aren't the same, that's all. Those are "anti-cheat" measures (not powerful ones...). So what's allowed or not depends on who implemented the restrictions.

  • Default User Avatar

    I m curious about the effect of "code" as a string on a code. Have you an idea?
    BTW the "code" comment was in a solution for another calculator kata's solution I submitted and I did ont have a prob at that time.
    thanks for all your answers

  • Custom User Avatar

    Because it's not easy to find out if it's in a comment or not, so it's forbidden everywhere.

  • Default User Avatar

    it was that. It s really strange condition but its not in instruction. I do not understand why writting "code" in a acommetn is forbidden.

  • Custom User Avatar

    that's because you wrote "code" somewhere in your solution. Possibly in a comment or as part of something else. And that's forbidden by the restrictions.

  • Loading more items...