Ad
  • Custom User Avatar

    description is clear enough :)

  • Custom User Avatar

    You showed how to do it, why even bother about the description ? Description is fine.

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

    Some reply about one part of your comment:

    The phrase "maximum element" seems really misleading. Does that mean the element in the array with the biggest index, or the element in the array with the biggest value (regardless of its index)?

    maximum element. Hmmmm... Generally speaking, that is the maximum value/number in the array. For [1,200,3], it should be 200. For [4,500,6], it should be 500. biggest index? Usually we call it by the last element.

    The biggest element (value-wise) is 0... well, it doesn't matter how many itterations you make applying the second operation to the array, 0 - a[i] doesn't alter the original array at all.

    0 - a[i] doesn't alter the original array? No, 0 - (-3) = 3, 0 - (+3) = -3 ;-)

  • Custom User Avatar

    A bad news to me. I'm not good at the English grammar ;-)
    If I am allowed to use Chinese, I think I will write a rigorous and detailed description ;-)
    69 guys passed the tests and submitted their solutions. It seems that my descrption is not SOOO bad, right?
    I made the following changes:

    1. changed A[i] to a[i]. Yes, A and a are the same ;-)
    2. changed "find M - maximum element of the array......" 
       to 
       "find the maximum element value of the array;
        replace each element a[i] with (maximum element value - a[i])"
    3. edit the examples, showing more details
    

    Hope this will be helpful ;-)
    Thank you for your feedback.

  • Custom User Avatar

    lol! this solution made me laugh! :)

  • Custom User Avatar
  • Custom User Avatar

    First, this is VERY nice. Learn something new every day. :)

  • Custom User Avatar

    I don't feel like this is worded very well.

    Is this supposed to be a coding puzzle, or a let's-see-if-we-can-correctly-interperate-the-author's-meaning puzzle?

    It mentions an array a, but then in the description of the two steps to be done each itteration of k, it mentions A. Am I to assume that a and A are the same thing? Maybe that's what people are assuming, but I don't like to assume. Programming requires an attention to detail that appears to be missing here, making me assume that a and A reference the same array. But assumptions about the initial array parameter, aside...

    Then the instructions state "find M - maxumum element of the array" does that mean that I subtract the value of the maximum element of the array from some unknown value M? Or that M is litterally the last element in the array? A minus sign is used twice in the instructions, but it's apparently (maybe? I'm still not really sure) to be a hyphen in the first case and an actual subtraction operator in the second.

    The phrase "maximum element" seems really misleading. Does that mean the element in the array with the biggest index, or the element in the array with the biggest value (regardless of its index)? Trying to follow the two given examples, doesn't help. The biggest element (value-wise) is 0... well, it doesn't matter how many itterations you make applying the second operation to the array, 0 - a[i] doesn't alter the original array at all. If you interperate "maxiumum element" to mean the last element in the array (the biggest or "maximum" one), you get the same 0 - a[i] since element 3 in the first example is 0.

    I even tried assuming (hate doing that...) that "maximum element" was talking about the values in the elements and not the indicies. Further, I tried assuming (again, grr...) that the author was from some planet where -4 > 0 == true (it's not... that's false just to be perfectly clear), and on a first itteration through the array initial array I get [0, -4, 3, -4].
    That's:

    -4 - -4 =  0 // for a[0] pass 1
    -4 -  0 = -4 // for a[1] pass 1
    -4 - -1 = -3 // for a[2] pass 1
    -4 -  0 = -4 // for a[3] pass 1
    

    but this is already flawed to me, because I had to assume that -4 was somehow the "maxumum element".

    Maybe I'm just stupid, or maybe this is less of an algorithmic challenge and more of a let's-see-if-we-can-correctly-interperate-the-instructions.

    I would prefer algorithmic challenges with precise and clearly stated goals. An algorithmic challenge should never start by giving you the algorithm (i.e. find the max value then perform this operation).

  • Custom User Avatar

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

  • Custom User Avatar

    Well... I feel stupid now. ;)

  • Custom User Avatar

    I specifically tried to find a purely mathmatical solution. Not converting to a string, or an array and back.
    Well, excpt when having to concatenate the squares together. :)

  • Custom User Avatar

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

  • Default User Avatar

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