Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • Profile-pic

    guidelines are generally useless. They are not up to date at all.

  • 23709795?v=4

    I really liked the problem stated in this kata. Luckily I managed to overcome the rounding problems without any 'hacks', and anyway all problems I had were a result of not reading the desciption carefully enough (or maybe description was updated in the meantime? IDK).
    I am just not sure how to rate the difficulty - CodeWars guidelines say 7 kyu, but my effort says 6 kyu. I think I'll go with 6.5 :)

  • 538615?v=3

    Not at all, feel free to rewrite.

  • 4643230?v=3

    I misread the problem, and my first solution had an additional restriction in that it required each of the golfers to play with each of the other golfers exactly once.

    Obviously that was the wrong solution and I had to rewrite it. But I thought the initial problem was interesting. Would you mind if I used this Kata and rewrote it to include the additional restriction?

  • Profile-pic
  • 17317792?v=3

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

  • 14909989?v=3

    JS.

    Also it's the random tests, not fixed tests.

  • 538615?v=3

    For which language? I just clicked on "Show Test Cases" and the code that people complained about is commented out:

    # Possible nasty rounding issues around 4:24:59 vs 4:25:00
    # Test.expect(clock_hands(17.5) == ["12:03:10", "01:08:38", 
    #   "02:14:05", "03:19:32", "04:25:00", "05:30:27", "06:35:54", 
    #   "07:41:21", "08:46:49", "09:52:16", "10:57:43"])
    

    What rounding problem do you see?

  • 14909989?v=3

    The rounding issue below still exists in the random tests.

  • 15963419?v=3

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

  • 538615?v=3

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

  • 18488395?v=3

    Python's three tests seems wrong, my code is right but can't pass :)

  • Profile-pic

    So unnefficient for large values of n1 or n2 :/

  • Profile-pic

    Hi, can someone help me figure out why my code fails the 7th test?

    The test expects the output [3,1,2] and my code returns [3,2,1]. I don't know what kind of data the 7th test is sending, therefore I am having a hard time optimizing my code to handle given case.

    (SPOILER) Here is my code in JavaScript:

    function ranks(a) {
        var sorted = []; // The array "a" in decreasing order
        var rank = []; // Copy of original array to be converted to a rank
    
        // Loops to copy each element of "a" into "sorted" and "rank"
        for (var j = 0; j < a.length; j++){
            rank.push(a[j]);
            sorted.push(a[j]);
        }
    
        // Sorts in increasing order and then reverse to get decreasing order
        sorted.sort().reverse();
    
      // Loops through elements of "rank" and replaces each element with the rank (indexOf sorted)
      for (var i = 0; i<rank.length; i++){
        rank[i] = sorted.indexOf(rank[i]) + 1;
      }
    
      // Return the ranked array
      return rank;
    }
    
  • Profile-pic

    Same here! I knew it didn't look quite right, and your correction put me on the correct path. Thanks!

  • Loading more items...