Ad
  • Custom User Avatar

    I thought that my solution which finds next_num(4028521680729008280092) is 5672520000485856186064 is quite optimal, its uses only about 78204 internal cycles (gap between polydivisible numbers is 1_643_998_319_756_847_905_972). But this is not enough.

    PS. It turns out to be enough, but in the description it is written that there is a limited number of them, and after the last one in the test, my algorithm falls into an infinite loop.

    PPS. I will not hide this hint under a spoiler, because I do not reveal the algorithm itself, but maybe I will save someone a lot of nerves and time.

  • Custom User Avatar

    when it seems you are doing the right thing and tests says no.
    then you make such hard code

    def sort_by_bit(arr):
        return [1, 2, 3, 4, 5, 6]
    

    and the tests say that they don't care what you return.

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    Python translation

    I don't know if it is possible in python not to create an instance of the class or the class itself to be able to address its attributes.

    therefore, you have to make the NumClass itself, and in the tests create instance Num = NumClass(), on which the tests are made.

    It is also possible to discuss the need to implement dunder methods for comparison (equality), arithmetic. because it wasn't in the original kata.

  • Custom User Avatar

    wow!
    I upvoted this as best pratices, but not because I think it's a best practice, but so that more people will see it.

  • Custom User Avatar
    ([2, 2],  0) False should equal True```
    
    I thought that the condition says about non-empty subsequences, both "in the center" and on the edges. Wierd.
    
  • Custom User Avatar

    Double check your code.
    I had false answer for this case too. Only because I compare correct addendums of checksum I found typo error in my code.

                     0   4   8   6   6   5   0   8   8    X
    position      x  1   2   3   4   5   6   7   8   9   10
    addendums are = [0,  8, 24, 24, 30, 30,  0, 64, 72, 100] 
    the sum is 352  = 11*  35
    
  • Custom User Avatar

    I spent some time to detect both growing (increasing) and falling (descending) arithmetic progressions to comply with the rule 1.
    But then spent more time to understand what needs to be detected only increasing (growing) arithmetic progression.

  • Custom User Avatar

    When I looked at the name of this kata, I thought that I would have to calculate the difference between bit arrays, not whole characters.

  • Custom User Avatar

    I think that the tests should have cases where the initial shift has such a value (near 26), that if you add the number of words, the result exceeds 26.

  • Custom User Avatar

    python random tests have \n endings, sample tests doesn`t.

  • Custom User Avatar

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

  • Custom User Avatar

    Author's python solution assume that arguments from diapason 84600 - 86399 (23 hours 30 minutes 00 seconds - 23 hours 59 minutes 59 seconds) must to return '0 days ago'

  • Custom User Avatar

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

  • Loading more items...