6 kyu

Simple Fun #110: Array Operations

145 of 373myjinxin2015
Description
Loading description...
Puzzles
  • Please sign in or sign up to leave a comment.
  • ahmet_popaj Avatar

    Very nice kata, not that easy to figure out as it seems at first.

  • danik00111 Avatar

    too many tests are ran, and it times out, and it fails me even though my function is working perfectly fine (python)

  • ejini战神 Avatar

    C# tests generate warnings --> tests/Fixture.cs(102,15): warning CS0219: The variable 'passed' is assigned but its value is never used

  • ejini战神 Avatar

    More fixed or random test coverage should be added (to invalidate wrong solution of mine)

    One of such case being

    a = [15, 63, 17]
    k = 23424
    correct result should be [0, 48, 2]
    
    Your result is: [30, 78, 32] should equal [0, 48, 2]
    
  • akar-0 Avatar

    Python, C#, Javascript: test cases are a mess full of unused stuff, needs serious cleaning.

  • uttumuttu Avatar

    The case k = 0 is only being tested in the random tests, where it's very unlikely to occur. A lot of the top solutions won't work for k = 0, so adding this case to fixed tests would break too many solutions. I suggest removing its possibility from the random tests, and changing the description to reflect this (i.e., k > 0 instead of k >= 0).

  • FArekkusu Avatar

    Description formatting is broken.

  • toferj 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).

  • Rimplstilckin Avatar

    What is the purpose of 100 000 tests?

    Here should be the point to find solution, right?

    BTW, Kata is very good, but I can't understand limited time.

  • micos7 Avatar

    Can you set a limit on the solve time when creating a kata?I manged to brute force it the stupid way with 2 loops.Or I got lucky in the random tests.

  • ekailia Avatar

    Thanks for this kata

  • JohanWiltink Avatar

    Is this a puzzle or an efficiency test?

    Honest question. I can write a more efficient solution, but I'm not interested in that. I do not see the puzzle, but maybe I'm missing something.

  • NedDevine Avatar

    This is a good kata, I had to try several approaches before I got it to complete within the allotted time. It exposes that I should pay more attention to efficiency than I normally do. Thanks!