• Custom User Avatar

    I see X_5[1] = X_4[0] - X_4[1] here as well as in the description, but it is X_5[0] being changed from X_4[0].

  • Custom User Avatar

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

  • Custom User Avatar

    It will take more iterations, though ..

    .. but that's not an issue. :D

  • Custom User Avatar

    Whilst I have no experience on what an issue is considered here, the problem can be solved without assuming that. It will take more iterations, though...

    PS: To clarify and not saturate the comments section, the above means that that is not required to solve the problem and thus not an issue.

  • Custom User Avatar

    It's not required that X[i] must be the largest or X[j] must be the smallest one.

    Why? Well, people familiar with competitive coding will instantly recognize what this kata is doing...

  • Custom User Avatar

    @notliam That also confused me, indeed.
    In the description (original & current), each row shows the current stage: on the left, the modified array; on the right, the processing and its relation with the above array.

    You propose to show the original array on the left and the modified one on the right. I think your suggestion would require changing the steps as well like this (plus some verbosity added):

    X   = [6, 9, 21] # -> X_1[2] = X[2]   - X[1]   = 21 - 9 = 12
    X_1 = [6, 9, 12] # -> X_2[2] = X_1[2] - X_1[0] = 12 - 6 = 6
    X_2 = [6, 9, 6]  # -> X_3[1] = X_2[1] - X_2[0] = 9 - 6  = 3
    X_3 = [6, 3, 6]  # -> X_4[2] = X_3[2] - X_3[1] = 6 - 3  = 3
    X_4 = [6, 3, 3]  # -> X_5[1] = X_4[0] - X_4[1] = 6 - 3  = 3
    X_5 = [3, 3, 3]
    

    Maybe it is more clear that way, I do not know.

  • Custom User Avatar

    Incomplete description:
    Explain that X[i] is the largest element of X and X[j] is the smallest one.

  • Custom User Avatar

    Aha, this is where the typo in the description comes from ;) It should be

    X_1 = [6, 9, 21] # -> X_1[2] = X[2] - X[1] = 21 - 9

  • Custom User Avatar

    I have updated the proposed Haskell translation with this as well.

  • Custom User Avatar

    Thanks for better detailed description, just updated kata

  • Custom User Avatar

    Haskell translation kumited.

    Please review, and comment or approve.

  • Custom User Avatar

    The instructions are way more complicated than the problem itself. In case it sheds some light to prospective trainees:

    Given an array X of positive integers, its elements are to be transformed by running the following operation on them as many times as required:
    
    if X[i] > X[j] then X[i] = X[i] - X[j]
    
    When no more transformations are possible, return its sum ("smallest possible sum").
    
    For instance, the successive transformation of the elements of input X = [6, 9, 21] is detailed below:
    
    X_1 = [6, 9, 12] # -> X_1[2] = X[2] - X[1] = 21 - 9
    X_2 = [6, 9, 6]  # -> X_2[2] = X_1[2] - X_1[0] = 12 - 6
    X_3 = [6, 3, 6]  # -> X_3[1] = X_2[1] - X_2[0] = 9 - 6
    X_4 = [6, 3, 3]  # -> X_4[2] = X_3[2] - X_3[1] = 6 - 3
    X_5 = [3, 3, 3]  # -> X_5[1] = X_4[0] - X_4[1] = 6 - 3
    
    The returning output is the sum of the final transformation (here 9).