#๐Ÿ”’ Need help clearing testcase

25 messages ยท Page 1 of 1 (latest)

small iron
#

My output:

> > move from (0,0) to (1,1)
> move from (1,1) to (3,1)
> move from (3,1) to (3,4)
> goodbye

Expected:

> 
> move from (0,0) to (1,1)
> move from (1,1) to (3,1)
> move from (3,1) to (3,4)
> goodbye

I have 3 separate files, but I believe the cause could be either of these issues.

task.py:
....
    while True:
        command = input("> ").strip()

        if command == "":
            print()
            continue

        if command == "quit":
            print("goodbye")
            break
 ....

I added the if command == "", but that still did not do anything. Even if you remove it, it doesn't do anything as a matter at all

unreal harnessBOT
#

@small iron

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

small iron
#
robot.py:
    def getSteps(self, start, end, maxVal):
        steps = []

        # directDist is the straight line distance
        directDist = abs(end - start) 
        # wrapDist is the distance if we go across a map
        wrapDist = maxVal - abs(end - start)

        if directDist < wrapDist:
            if start < end:
                # We're going forwards
                for i in range(start + 1, end + 1):
                    steps.append(i)
            else:
                # We're moving backwards
                for i in range(start - 1, end - 1, -1): # stops at 0
                    steps.append(i)
        else:
            if start < end:
                # Wrapping left, for example: 2, 1, 0, 9
                for i in range(start - 1, -1, -1):
                    steps.append(i)
                
                # Wraps to maxVal - 1 towards the end:
                for i in range(maxVal - 1, end - 1, -1):
                    steps.append(i)
            
            else:
                # Wrapping right, for example, 9, 0, 1, 2
                for i in range(start + 1, maxVal):
                    steps.append(i)
                
                # Wraps to 0 and go to end
                for i in range(0, end + 1):
                    steps.append(i)
        
        # Ensures all values are actually wrapped correctly
        finalSteps = []
        for i in steps:
            finalSteps.append(i % maxVal)
        
        return finalSteps
#

I have a feeling the cause will have to be here in this code section, but I am unclear where particularly

#

the other python file is just a bunch of classes and objects and has nothing to do with the actual error

torpid quiver
#

How are you doing your input? It looks to me like your terminal is having positioning issues, causing the next output to overwrite the previous line. Normally input only returns a value when a newline is entered, which should stop this from happening.

small iron
#

The platform automatically puts the testcases down, I'm unsure what they could be inputting, but this is the result of that

torpid quiver
#

What does the input to the program look like?

small iron
#

display journey
moveto 1 1
moveto 3 1
moveto 3 4
quit

torpid quiver
#

Is the Expected in your original message what the platform expects for it's test case?

small iron
#

yeah

torpid quiver
#

Does the platform/exercise specify you have to use input?

#

Hm, I think it might be something else actually. Can you show your code that handles display journey?

small iron
#
def displayJourney(self):
        for i in self.journeyLog:
            print(i)
#

this is it

torpid quiver
#

Does the exercise specify what it expects the output of display journey to be?

small iron
#

I can give you an example of what the input/outputs can be

#

Example 1

> moveto 0 0
same location
> moveto 0 1
move from (0,0) to (0,1)
> moveto 1 1
move from (0,1) to (1,1)
> moveto 2 4
move from (1,1) to (2,4)
> moveto 0 4
move from (2,4) to (0,4)
> display journey
Day 1: move (0,0) -> (0,1)
Day 2: move (0,1) -> (1,1)
Day 3-5: move (1,1) -> (1,0) -> (1,4) -> (2,4)
Day 6-7: move (2,4) -> (3,4) -> (0,4)
> quit
goodbye
#

Example 2

> show map
.....
.m...
....l
..c..
> moveto 1 1
move from (0,0) to (1,1)
> explore
explore mountain olympus mons
> moveto 2 3
move from (1,1) to (2,3)
> explore
nothing to explore
> display journey
Day 1-2: move (0,0) -> (0,1) -> (1,1)
Day 3-6: explore mountain olympus mons
Day 7-9: move (1,1) -> (1,2) -> (1,3) -> (2,3)
> quit
goodbye
#

ok nvm, i fixed it

#

i still lysm coz the problem was lied in def displayJourney(self)

#

and i just added a conditional statement of

if not self.journeyLog:
print()
else:
...

#

!close

unreal harnessBOT
#
Python help channel closed with !close

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.