Ad
  • Custom User Avatar

    Does negative numbers matter ?

    is a way of writing n as a sum of positive integers

    No.

    Should I count 0 as a way to sum ?

    No. A positive number is a number greater than 0.

    Are 2 + 1 and 1 + 2 considered 1 possiblity ?

    For example, 4 can be partitioned in five distinct ways:

    4
    3 + 1
    2 + 2
    2 + 1 + 1
    1 + 1 + 1 + 1
    

    If it says there are 5 partitions and you don't see 1 + 3 or 1 + 2 + 1 the answer is obviously yes.

  • Custom User Avatar

    I did, maybe I shouldn't be on codewars on Saturday at 12
    If someone is willing to answer:

    Q3. Are 2 + 1 and 1 + 2 considered 1 possiblity ?

  • Custom User Avatar

    Read the description and the examples.

  • Custom User Avatar

    Q1. Does negative numbers matter ? if so, then this is unsolvable (finitely), for example 2 can be summed with:

    • -1 + 3
    • -2 + 4
    • -3 + 5
    • -4 + 6
    • etc until infinity..

    Q2. Should I count 0 as a way to sum ? for example, the number 2 has these possible combinations:

    • 0 + 2
    • 1 + 1
  • Custom User Avatar

    Yeah, I just managed to solve it in 103 ms, but got ~300 with the naive approach. Read over the question again - maybe there's a piece of information you're not using? ;)

  • Custom User Avatar

    About to forfeit this, passing the tests in ~300ms, when maximum allowed is 150ms

    Anyone was able to submit with JavaScript recently ?