Ad
  • Custom User Avatar

    Take some more time and implement a relatively efficient algorithm.

  • Default User Avatar

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

  • Custom User Avatar

    (Python, sorry~)

    And correct! Stupid of me, but yes I had given the function a third (thought defaulted) input (ans=[]), because I recursed and needed to pass on my accumulating list of squares. Must have screwed up the testing apparatus?
    Code could be less clunky, but it works and is submitted now. Ended up just pasting everything in a helper function so I could keep that logic. Will have to fine-tune later.

    Thanks!

  • Custom User Avatar

    My guess is you're using a global var that keeps its value when your function is called more than once.

  • Default User Avatar

    It's a good idea to tell which programming language you are using.
    My first guess is you are modifying the arguments given.

  • Custom User Avatar

    Issue: my code runs and outputs the exact array as Expected. HOWEVER... in the tests console, I pass test #1, but then for each subsequent test, my output answer is my actual/the real answer (again, tested in Atom and PythonTutor.com) BUT with the previous answer stacked on top of it!
    Here is my final console print for each test-- as you can see, each is 'stacked' with the previous test's answer PLUS this test's answer.
    SOLUTION!: [3, 2, 1, 1]
    SOLUTION!: [3, 2, 1, 1, 3, 2, 1, 1]
    SOLUTION!: [3, 2, 1, 1, 3, 2, 1, 1, 14, 6, 6, 2, 2, 2]
    (and it continues this indefinitely...)

    This issue does not happen in Atom or any other program that I run. Is this a bug on your side? Or is could there be a small error in my code? (though I don't know how my code could save a previous test's answer!!!)

  • Default User Avatar

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