Closed emmacgodfrey closed 3 years ago
The reason that your code is passing when run with interactive python and not when run directly through the test case is that you are actually running on a different list in both scenarios. The key is the line
xs = list(set(xs))
in the test case, which will change the order of the xs
list. On my python, I get
>>> list(set([0, 1, -1, 2, -2, 3]))
[0, 1, 2, 3, -2, -1]
but the order of an iterator of a set
is not guaranteed to be the same across python versions, and in particular may be different for you.
To debug this issue, you should be inserting the transformed list in interactive python, rather than the original list.
Hi @mikeizbicki and classmates,
I have been trying to de-bug my code for a couple days now, and I am officially stuck.
When I run the test cases, I keep failing the following case:
However, when I try to debug in python interactive mode, it seems as though my code is working. For example,
The only thing that I can think of is that my
_right_rotate
and_left_rotate
functions do not run in logarithmic time due to the deep copy. Could this be causing the failing test case? If so, any suggestions for fixing these functions?My
_left_rotate
function is as follows:Thanks in advance,
Emma Godfrey