Write Python for Bu Murti's LPG pangkalan: dicts, classes, files, with, modules and type hints. 16 levels, played right in the browser with nothing to install.
What the levels ask
Monday, 2 November. The distributor now takes the depot's logbook only as a file, so Mrs. Murti keeps her buyers in a dict on her netbook. Mr. Dodi is in the queue, but his name is not on the list yet. Choose how the book looks up a name so registered buyers are served and Mr. Dodi is turned away as not registered.
Tuesday and Wednesday. A house may take one cylinder a day, so Mrs. Murti writes a function log_day that notes who has been served that day. The program runs Tuesday, then Wednesday. Choose the function's header so Mr. Tono, who comes twice on Tuesday, is turned away once, yet on Wednesday everyone is served again.
Thursday. The distributor sets a share of three cylinders per house per week. The program counts each ID number's cylinders from this week's log, then serves Thursday's queue. Choose how the count goes up so Mr. Tono, who has taken three, is turned away, while Grandma Marni and Mrs. Yanti are served.
Friday. The neighbourhood head wants each area of the neighbourhood to know how many cylinders went to its houses this week. The program groups this week's log by area, then posts the count on the boards of areas 01, 02 and 03. Choose the container and what the last loop unpacks so each board gets its own number: 5, 2 and 2.
Saturday. The neighbourhood head wants to invite the three houses that took the most cylinders this month, to make sure nobody resells them. The program has already counted counts per ID number. Choose what is sorted and its key so the invitations reach the three biggest buyers, the biggest first.
Monday and Tuesday. In the class Buyer each buyer keeps their own history of days, and all of them pay one set price. On Tuesday the program raises it with Buyer.SET_PRICE = 20000. Choose what goes in the class body and what in __init__, so nobody is turned away for someone else's history and Tuesday's buyers pay the new price.
Wednesday. The distributor's truck only comes in the afternoon, and three full cylinders are left in the cage. Mrs. Murti makes a class Cage with stock as a property: its setter refuses a number below zero, so the fourth buyer is asked to wait for the truck. Choose the line that stores the value in the setter.
Thursday. Mrs. Sari's stall is registered as a micro business and may take two cylinders a day. Mrs. Murti makes a class MicroBusiness that inherits from Buyer and adds a licence number. Choose the first line of its __init__ so Mrs. Sari is served twice and then turned away, and Mr. Tono once and then turned away.
Saturday. The neighbourhood head brings five forms: Mr. Bayu handed his in twice, and two residents are both called Sri, with different ID numbers. Choose __eq__ and __repr__ of Resident so the double form is registered once, both Sris are registered, and the printed list shows each ID number.
Monday, 16 November. Mr. Rohim, the distributor's truck driver, copies logbook.csv from the netbook right after the queue is done. The program writes today's rows, then calls send_to_distributor. Choose how the file is opened so the distributor's copy holds both of today's sales.
Tuesday, 17 November. logbook.csv already holds five rows from earlier days. Today three buyers are served, and the logbook must hold eight rows, one sale a row, before the distributor copies it. Choose the open mode and the text written for each sale.
Thursday, 19 November. The truck unloads five cylinders, each checked before it goes into the cage. cage_open opens the padlock on the way in and must lock it on the way out. Cylinder T03 leaks. Choose its body so LeakyCylinder still reaches the top, as the distributor must know, and the cage stays locked tonight.