Ad
  • Default User Avatar

    @brendanvos
    Your own solution also mutates the original list passed trough the function.

    Out of curiousity i tried your solution in Pycharm. I stored [1, 1, 1] in a variable x, stored 10 in varuable y, called the function with (x, y) parameters and after requested a print(x). Both the print(function) and print(x) yielded the same result.

  • Default User Avatar

    Sorry if I'm mistaken, but aren't you also mutating the input (signature) in your solution?

  • Default User Avatar

    When I apply this solution as tribonacci([15, 16, 14], 3) I receive [15, 16, 14] but I had in one of the randomly generated tests, that the correct answer should be [45], which does not make sense. There should be a clearer specification to what the function should do for n in [1,2,3], I guess.

  • Custom User Avatar

    You don't remember correctly. Python lists are mutable. Mutable objects are pass by reference.
    If you make changes to a list which was passed in as a parameter you WILL mutate the list for the caller.

  • Default User Avatar

    No because python should be treating anything within a function as abstracted. If I remember correctly you'd have to declare it as a global variable

  • Default User Avatar
  • Custom User Avatar

    You're mutating the signature despite that not being the goal of the function!

    That's a no no!

  • Default User Avatar

    My solution was EXACTLY like the top one when i unlocked solutions but it failed - so there is something wrong with this Kata's test cases - I want my honor for this one!

  • Custom User Avatar

    What is the point of these tests:

    Expected: "More Than One Space Between Words", instead got: "More Than One Space Between Words"
    Expected: " Leading Spaces", instead got: "Leading Spaces"
    Expected: "Trailing Spaces ", instead got: "Trailing Spaces"

    Especially when they aren't specified in the description nor shown in the initial test cases. You only see them when submitting answers. Why would the cases for leading and trailing spaces even require those spaces. The first is just silly; why would anyone put more than one space between words (unless a typo)?

    Just some feedback and a need for clarification. Thanks!

  • Default User Avatar

    This was a bogus kata - nowhere in the discussion does it say to leave spaces - that requirement in the test result is not fair at all.