Ad
  • Custom User Avatar

    I can't tell what language you are using. At first, I thought it may be JavaScript ( but I see you have a lower case "null". However, if it was JavaScript, when using the .sort() method, the array components are converted to strings. In that case, "1" will be followed by "10". To compare numbers, you need a call back comparison function within the method. Might be some case like this for the language you are using. Besides that error, did the message log out your returned result?

  • Custom User Avatar

    It also depends if a person solves it by scratch and not by using built-in or imported sorting functions or methods.

  • Custom User Avatar
  • Custom User Avatar

    I tried this in Csh and it failed the test cases, but unless I'm missing something, it passes the example cases in the terminal. Can you confirm that this will work with Csh?

  • Custom User Avatar

    This solution is time O(n), so a best practice solution. Many others, including my first attempt are O(n^2)

  • Custom User Avatar

    Groovy translation kumited. Please review and approve! Thanks, suic

  • Custom User Avatar

    I suggest rewording the description for JavaScript from: "Write a class function named repeat()" to "Write a function named repeat()", because even though the problem starts with function repeater(), someone may believe the solution was supposed to start with the class keyword, or take the form of a method under a class constructor.

  • Custom User Avatar

    In JavaScript, .join() is an Array method, not a String method.

    ["foo", "bar"].join('');    // "foobar"
    "foo".join("bar");          // VM910:2 Uncaught TypeError: "foo".join is not a function(…)
    

    To put two strings together, you would use the .concat() method, or use the "+" operator.

    "foo".concat("bar");        // "foobar"
    "foo" + "bar";              // "foobar"
    
  • Custom User Avatar

    Just curious, what is the danger in using for...in with arrays?

  • Custom User Avatar

    I think a new user should know how to create an object before they copy and paste one it, but this inspires me to make some Kata about objects. : ) Actually, looking at it again, it's just the key: value pairs that were given.

  • Custom User Avatar

    For students just starting to learn about objects, this is quite possibly the best kata to start with!

  • Custom User Avatar

    Ha yeah, actually it was a really good practice exercise for a shell one-liner...

    sed "s/^[ \t]*/\'/g" dictionary | sed "s/:/\' :/g"

    :)

  • Custom User Avatar

    C# translation submited. please approve :)

  • Custom User Avatar

    No problem, sometimes better to work it out on your own! Just popped into my head as I was walking home

  • Custom User Avatar

    Thanks!

  • Loading more items...