Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • 42743735?v=4

    hmm ok, thanks for the input. Will check the results again, maybe I DID miss something...

  • 32236948?v=4

    the order has no importance because "your" output is sorted before the assertion.

  • 42743735?v=4

    Ugh, all combinations are there with the BP(5) in the basic tests, almost in same order...

    ... only the middle 4 are somehow ordered differently. damn, one of THOSE kata's... :)

  • Profile pic

    JS tests are failing with the correct results. In the tests examples I had to remove the "n" from the expected results (i.e. 8n => 8) in order to let them pass.
    Something's weird there - can you please check?

  • 6678485?v=4

    If we have to consider the performance, we have to use the maths to calculate.
    from decimal import *

    def fib(n):
    n = Decimal(n)
    PHI = Decimal((1 + 50.5) / 2)
    result = round((PHI
    n - (-PHI)**(-n)) / (2*PHI - 1))
    return result

    But the result is not same as the verified in -96 and so on.

  • 2698843?v=3

    Well, that depends on the underlying algorithm.
    If the algorithm generates them in a fast way, but with duplicates, filtering them through a set might be faster then a slow algorithm that doesn't create duplicates.

    However, API wise, I still think that a Set or SortedSet would fit better, since

    • Duplicates are not allowed as by the specification
    • There is no "correct order" defined by the specification
  • Profile pic

    The expected return type could be Collection<String> though to allow Lists, Sets and what not... But it's not a big deal.

  • 32236948?v=4

    No, I doubt it would be more efficient.

    ... :o
    mmmh, don't you think...?

    • generates duplicates
    • consume time to order the set or even compute the hashcodes if you use a classic set


    • generate every possibility one and only one time
    • generate already in correct order.

    I guess you need to clear your mind a bit...

    The contract is a list to be consistent with the original language too. Don't forget that.

  • 2698843?v=3

    No, I doubt it would be more efficient. I use a Set to not create duplicates.

    Regardless, a SortedSet (or even a non-sorted set) seems to be more proper, because order doesn't matter and duplicates aren't allowed.
    That are the criterias for a Set, rather then a List.

  • 32236948?v=4

    Then I'd just say because:

    • either you don't need to sort the answers because the tests will do it for you
    • or if the tests wouldn't do it, you still don't need it because it will be more efficient to generate all the possibilities already in order.


  • 2698843?v=3

    I can see what the contract asks for, the question is WHY? And yes, I have done that conversion.

  • 32236948?v=4

    because the contract ask for a List<String>? ;)

    Use your sorted set if you want, then convert it?

  • 2698843?v=3

    Why can't I just return a SortedSet in Java? Would make it easier.

  • Profile pic

    javascript tests always get error
    you need to specify what kind of data need to return (number, string ...)

  • Profile pic

    fib (-2) + fib (-1) == fib 0 and fib 0 == 0, so they can't be all negative.

  • Loading more items...