The Smallest Change
Asked to fix a program, the AI usually sends a whole new one. It may work, and still not be what you need: to see what was wrong, you have to compare it with yours line by line, and it often changes more than the mistake, rewriting lines that were fine in a way you haven't learned.
The program in the editor prints Total: 42, and Mia's walks cost 6 + 12 + 6 + 12 = 36. Asked Fix it., with the program, what it printed and the right total, one answer sent the whole program back with this function in it:
def walk_price(minutes):
half_hours = (minutes + 29) // 30 # round up to the next half hour
return half_hours * 6It gives the right total, and the answer explained: “Rounding up to the next half hour fixes both problems.” But the if is gone, (minutes + 29) // 30 is a trick you haven't learned, and nothing in the answer says that Mia's function was right except for one operator: // where % belongs. The same message gets a different answer each time. The others sent a whole program or a whole function too, and most of them replaced the function with something new, one with math.ceil() and max(), and a minimum price that Mia never asked for.
Ask for the smallest change instead: which line to change, how and why. You keep your program and your names, you learn what was wrong, and you can check the change yourself.
Instructions
- 1
Run the program. Attach
script.pyand what it printed, say that the walks cost 6 + 12 + 6 + 12 = 36, and ask for the smallest change that fixes it: which line to change, and why. Say that you don't want the whole program again. Then send it. - 2
Change that line in your program, and only that line. Run it: it prints
Walks: 4andTotal: 36. - 3
Mia walked Max for 75 minutes today. Add
75at the end of the list and run the program. It printsWalks: 5andTotal: 54.