Ad
  • Custom User Avatar

    Why are the results so truncated? I can't debug my code with something like:

    With k = 1, arr = 47,81,43,130,32,107,311: expected 'Rearrangement: 107, 130, 311, 32, 43,…' to equal 'Rearrangement: 107, 130, 311, 32, 43,…'

  • Custom User Avatar

    Cool kata! First tried the brute force approach and timed out. Then realized this is a puzzle and not a plotting exercise. Gave it some thought away from the computer and came up with a solution.

  • Custom User Avatar

    Fun to solve. Thanks. Good graphics in the description - very helpful.

  • Custom User Avatar

    I'd suggest adding a test case for when the mean is equal to one of the found numbers. I was passing the random tests most of the time until this scenario occured.

  • Custom User Avatar

    link to the trainer of the other kata

    I meant that a direct link to the trainer should never be used. Sorry for not being clear.

    The description still is very convoluted. Second part of point 2 is useless. Point 3 looks useless and/or doubtful:

    aba001...aba999,
    bba001...bba999,
    

    Are you sure you don't mean aba999 -> abb001... ? If the descriptino is currently right, the problem is that you're litterally flooding the user writting a lot of times examples that are not making obvious what they want to demonstrate. Ex: in the code block I pasted just above, there are 4 infos. the important one at this point is the link when changing of line. Except that any user reading this will normally associate "one line == one idea". That's the natural way to like at this.

    About the tests:

    • don't use var
    • the createRandomTests function is useless: just build all the tests inside the it block, using a first loop (and so, you won't need var)
    • the random int generator is not balanced properly: it has close to 0 chances to generate a or a 0 (use floor, not ceil. Beware of the upperbound, doing so)
    • the random tests are actually testing nothing, since they tests the user's function against itself...

    Cheers

  • Custom User Avatar

    I made changes based on your comments. Does it look any better?

  • Custom User Avatar

    I tried to paste my solution into the index.js file on the linked website but it seems to be read only. I even logged in but no dice.

  • Custom User Avatar

    Hi,

    • no description
    • link to the trainer of the other kata
    • no random tests
    • no sample tests

    If you're interested in authoring kata you should read the docs first.

    Cheers

  • Default User Avatar

    Could anyone explain this solution?

  • Default User Avatar
  • Custom User Avatar

    In the description under Examples you show the output for sample test 4 being { A: 114, B: 90, C: 106, D: 116 }. That is the output I get but the test yeilds this result:

    expected { A: 114, B: 90, C: 106, D: 116 } to deeply equal { A: 118, B: 94, C: 110, D: 120 }