Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 9 Online
OpenStudy (anonymous):

Hi everyone. This is what I did for problem 3 homework 6 for 2011spring it says there's indentatiion problem but I am getting confused. Is there anyone who knows where the problem lies? Thanks a lot~ def runSimulation(num_robots, speed, width, height, min_coverage, num_trials, robot_type): time=0 for trial in range(num_trial): room=RectangularRoom(width,height) robot=[] for ii in range(num_robots): robot.append(robot_type(room,speed)) while room.getNumCleanedTiles()/room.getNumTiles() < min_coverage: for ii in range(num_robots): robot[ii].updatePositionAndClean() time=time+1 return time/num_trial

OpenStudy (anonymous):

Your first and second line (not counting the def line) are not indented the same amount, but they should be.

OpenStudy (anonymous):

pls use a code pasting site http://dpaste.com http://pastebin.com http://codepad.org

OpenStudy (anonymous):

def runSimulation(num_robots, speed, width, height, min_coverage, num_trials, robot_type): """ Runs NUM_TRIALS trials of the simulation and returns the mean number of time-steps needed to clean the fraction MIN_COVERAGE of the room. The simulation is run with NUM_ROBOTS robots of type ROBOT_TYPE, each with speed SPEED, in a room of dimensions WIDTH x HEIGHT. num_robots: an int (num_robots > 0) speed: a float (speed > 0) width: an int (width > 0) height: an int (height > 0) min_coverage: a float (0 <= min_coverage <= 1.0) num_trials: an int (num_trials > 0) robot_type: class of robot to be instantiated (e.g. Robot or RandomWalkRobot) """ time=0 for trial in range(num_trial): room=RectangularRoom(width,height) robot=[] for ii in range(num_robots): robot.append(robot_type(room,speed)) while room.getNumCleanedTiles()/room.getNumTiles() < min_coverage: for ii in range(num_robots): robot[ii].updatePositionAndClean() time=time+1 return time/num_trial

OpenStudy (anonymous):

Thanks. As above, it still don't work~

OpenStudy (anonymous):

time=0 ^ IndentationError: unindent does not match any outer indentation level

OpenStudy (anonymous):

Like @bwca said, please use a code pasting site so it would be easier for us to see the indentations clearly and help you debug the code :)

OpenStudy (anonymous):

How do I do that? I just use the code pasting site to generate it and paste it here again...

OpenStudy (anonymous):

@CindyCheng: You paste it on the site, it will give you a link then you paste the link here. Like what I did with your code here :) http://dpaste.com/760382/ And with that, I noticed that your return statement at the end doesn't align with the first 2 lines of the code :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!