• Custom User Avatar

    I'm not sure I follow the example given, or how it fits the description. We're told to basically repeatedly compare each value to all of the others and take action depending on this comparison. But then then the example seems to be foccusing on comparing the largest value with the largest of all other values instead.

    For instance :
    X_1 = [6, 9, 12] # -> X_1[2] = X[2] - X[1] = 21 - 9
    No care is given to x[1] being bigger than x[0]

    If I follow the "i,j" instruction, I would expect the process to look more like this :

    [6, 9, 21]

    (edit - note : I initialy misread the example so here I used 1 as first index instead of 0)
    First pass :
    x[1] < x[2] => .
    x[1] < x[3] => .
    x[2] > x[1] => x[2] = x[2]-x[1] = 9 - 6 = 3
    x[2] < x[3] => .
    x[3] > x[1] => x[3] = x[3]-x[1] = 21 - 6 = 15
    x[3] > x[2] => x[3] = x[3]-x[2] = 18 - 3 = 12
    => [6,3,12]

    Second pass :
    x1 > x2 => x1 = x1-x2 = 6 - 3 = 3
    x1 < x3
    x2 == x1
    x2 < x3
    x3 > x1 => x3 = x3-x1 = 12-3 = 9
    x3 > x2 => x3 = x3-x2 = 9-3 = 6
    => [3,3,6]

    Third
    x1==x2
    x1 < x3
    x2==x1
    x2 < x3
    x3 > x1 => x3 = x3-x1 = 6-3 = 3
    x3 == x2
    => [3,3,3] => 9

    The result is the same, but the process isn't (probably longer) => and my problem here is I don't see how to demonstrate that the method used in the example will always give that same result.

  • Custom User Avatar

    -edit-
    ah, no, I misread

  • Custom User Avatar

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

  • Custom User Avatar

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