Ad
  • Custom User Avatar

    This thread was enough to clarify the description. The description has a bug in it in the example where it has '21' it should have '12'.

  • Custom User Avatar

    I'm also confused by the description. Even the example is helping me. I'd love to take a crack at this one but I don't even know what's being asked.

  • Custom User Avatar

    carry on repeating the operation in the description until all the numbers are equal.

  • Custom User Avatar

    You have an array :

    [a, b, c, ...]
    

    If one element is strictly greater than another, let's say a < b, then you subtract the smaller from the greater :

    [a, b-a, c, ...]
    

    And you repeat this again and again until it's not possible anymore. At this stage, you sum all the numbers left in the array and return that.

    The thing is (look at the Additional notes section), this method is really ineficient. The real task is to find a way to do the same calculation but much faster.

  • Custom User Avatar

    I'll agree with this, I believe the author needs to give a much better explanation

  • Custom User Avatar

    It's a problem with your code (yes, it is too slow), not a kata issue.

  • Custom User Avatar

    You're not supossed to multiply that last digit with anything. You should count how many times you need to multiply the number's digits to obtain a single digit number

    39 --> 3 (because 3*9 = 27, 2*7 = 14, 1*4 = 4 and 4 has only one digit)
                       1         2         3  
    

    The single digit value is not related to the expected value.

  • Custom User Avatar

    returns its multiplicative persistence, which is the number of times you must multiply the digits in num until you reach a single digit.

    You're returning the single digit number instead. Please mark your post as having spoiler content next time.