Program Repairs — Pseudocode

Fix villagers’ programs at Kinan’s watch stall: read the error message, the trace and the output. 14 levels, right in the browser.

What the levels ask

  1. Mr. Tono copied his harvest note into a program. He wants it to say Grain today: 17 sacks, but the program stops with an error message. Read the message: it has a line number and a guess at the name he meant. Pick the line that is wrong, pick the fix, then hand it back to Mr. Tono.
  2. Mrs. Ijah has an order for 25 rice boxes and 25 iced teas. The note must read Order total: Rp 400000. The program stops on its last line. The message says what is wrong, and its second sentence offers a way to fix it.
  3. At the market eatery, Mrs. Yanti gives free crackers to a buyer who eats 3 plates or more, and every buyer still gets a thank-you. The error message points at the IF line, but its second sentence says where the closer has to go. The program is tried for 4 plates and for 2.
  4. Ms. Wulan at the post office sorts the parcels: those for the village go out this afternoon, the rest go on Mr. Harun’s bus. The program stops on line 2. It is tried for a parcel to the village and one to town.
  5. Mrs. Lastri weighs four baskets of fish. A basket over 10 kg is noted as too heavy, and the note ends with Weighing done. The error message points at line 5, END FOR. Careful: the line a message names is not always the line to change.
  6. Mr. Bayu adds up his monthly shopping: sugar 14000 and eggs 28000. He copied the egg price from a WhatsApp message. The total must be Shopping this month: Rp 42000. The error message points at line 3 and suggests one fix. Think before you follow it.
  7. Bagas adds up the points from three arcade rounds: 120, 80 and 150. The result must be Bagas's score: 350. The message says score is used before it has a value, on line 4. But Bagas is sure he set it on the first line.
  8. Grandma Marni wants her phone to remind her three times to take her medicine, then say Today's medicine is done. As soon as the program runs, Grandma’s phone does not stop ringing. The computer stops it by itself after 10,000 steps.
  9. Mr. Harun writes the district bus timetable: four trips a day, leaving at 6, 8, 10 and 12. The program runs with no error at all, but the timetable it prints is not the one he asked for. Compare the result line by line.
  10. The neighbourhood head lists who may get an ID card: everyone aged 17 or over. The program is tried for Tia (17), Dimas (9) and Mrs. Ida (56). There is no error, but one of them gets the wrong answer.
  11. Mr. Arka swaps arcade tickets for prizes: 50 tickets or more get a doll, 20 or more a key ring, the rest sweets. The program is tried for 60, 25 and 5 tickets. The one with 60 complains.
  12. Mrs. Endang at the library sends reminders to four borrowers. The program sends three reminders, then stops with an error on line 3. Rara, the first borrower, gets nothing.

And more, 14 levels in all.