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

    The purpose of this kata is to disallow tampering with instance attributes, so you can forget about removing those tests.

  • Custom User Avatar

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

  • Default User Avatar

    i think you can simple calculate the quotient of (score / debt), sort by that as first criteria, sort by debt as second criteria and use the result as stack, of which you pick items as long as you are below the max debt. At least thats what i did :)

  • Custom User Avatar

    Now you can find them

  • Custom User Avatar

    The run-time of a solution could be updated when you select "compare with my solution" so that you could at least compare the speed of one solution versus your own. I agree that creating a global score would be challenging. Perhaps they could semi-regularly check run times on the top 10 up-voted solutions.

  • Default User Avatar

    Could you replace n != 0 with n?

  • Custom User Avatar

    Thank you, for feedback.
    Of course, for real task it's more logical to use objects, not arrays. But the aim of this kata is to show how to use arrays where content have different types. Later I will try to do this idea using normal objects. I'll try to add more test-cases

  • Custom User Avatar

    I'm glad you liked it! :D

    I'm planning on making more katas soon so look out for 'em!

  • Default User Avatar

    Well this is a bug fixing kata so other solutions aren't exactly following in the spirit of things.

  • Custom User Avatar

    Thank you! This was my first time looking at React myself to be honest. I'm hoping that other developers will be able to come up with even better React Katas! =)

  • Default User Avatar

    In case you're interested and haven't already heard of it: Programming challenges with the goal of achieving a functionality with the least possible number of characters are called "code golf". Stack Exchange has an exclusive site just for code golf challenges. You will find some brilliant and brain racking solutions every day, and of course are able to sumbit your own ones.

  • Default User Avatar

    Admittedly, I had to think about that one myself since it wasn't yesterday when i wrote it.
    Using f as an argument is just a lazy and space saving alternative to declaring it within the function body (see Balkoth's solution for the "clean way"); I really wanted to do this in a compact one-liner ;D
    The rest is exactly as you said: f starts out as a falsy value and gets negated/toggled every time, so the first zero will be kept, the second zero will be omitted, the third will be kept and so on...
    Of course, I wasn't smart enough to invent that trick (at least I didn't). This is where I first saw it: Sudoku Solver in 140bytes

    function R(a,i,j,m,g){for(i=80;a[i];i--||+a);for(m=10;g=a[i]=--m;g&&R(a))for(j in a)g*=a[j^i==j]^m||i/9^j/9&&i%9^j%9&&i/27^j/27|i%9/3^j%9/3}

    Talking about unreadable?

  • Custom User Avatar

    Thanks, man, but let's give credit to debri too for the cool idea :)

  • Loading more items...