Ad
  • Custom User Avatar

    In maths ( and Wikipedia ), this is called "partitioning".

  • Custom User Avatar

    I'm not here to complain and I really liked the Kata but I have some opinions about it and why I think it can be improved (and how to do it).

    It's pointless test cases using numbers above MAX_SAFE_INTEGER in JavaScript.

    Why?

    1. A real solution using recursion breaks as 'max call stack' as it is pointed out by some users in comments
    2. There's no point requiring use of BigInt and not cite it as required in Desciption (as long as I think this is not necessary)
    3. This is a 7 kyu Kata. The user should not be concerned about performance that exceeds the MAX_SAFE_INTEGER

    My suggestion is: I hardly recommed to maintain the range of numbers as

    • 1 <= n <= 50
    • 1 <= k <= 30

    At least for JavaScript. JavaScript do not have full memory to store numbers like Python and if n exceeds 60, it easily surpass MAX_SAFE_INTEGER.

  • Custom User Avatar

    note: put a language specific note saying all results will be under MAX_DAFE_INTEGER, then, so that users don't try to use BigInt. Otherwise they'll still get the same error message.

  • Default User Avatar

    Either test under MAX_SAFE_INTEGER or require BigInt results (but then existing solution will be invalidated). It is a "7 kyu" kata so testing under MAX_SAFE_INTEGER is a reasonable choice.

  • Custom User Avatar

    should i test only under the MAX_INTEGER what say?

  • Default User Avatar

    It is not possible to solve this kata in JS with BigInt results. I get the following errors:

    Fixed tests
    expected {} to equal 1
    Completed in 1ms
    Random tests
    expected {} to equal 7
    

    I think it is possible to support both Number and BigInt results with a custom assertion. But I do not recommend to support Number results because these results are not precise for large input values.

  • Custom User Avatar

    BigInt has been added to support big numbers.

  • Custom User Avatar

    fixed

  • Default User Avatar

    BigInt should be used in JavaScript:

    Random tests
    expected 1.7014118346044496e+38 to equal 1.7014118346044475e+38
    
  • Custom User Avatar

    Why you are testing values higher than MAX_SAFE_INTEGER in JS? This make no sense at all in this Kata as 7 kyu... Numbers above that are not precise and the values exceeds the time of execution or do not pass the tests.

    If possible, can you make the test with numbers below MAX_SAFE_INTEGER in JS?

    As a suggestion, I hardly recommed to maintain the range of numbers as:

    • 1 <= n <= 50
    • 1 <= k <= 30

    At least for JS. JS do not have full memory to store numbers like Python and if n exceeds 60, it easily surpass MAX_SAFE_INTEGER.

  • Default User Avatar

    Question

  • Custom User Avatar

    And how is this a kata issue?? You can ask questions under any specific solution, if that helps. Closing...

    Edit: what the hell, sorry. It was showing up as issue to me. But you should use spoiler flag for questions like this.

  • Custom User Avatar

    You can search about fibonacci ladder problem where length of steps not greater than 2. Then think about generalization of this problem.

  • Custom User Avatar

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