注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
第一题:Question Description The task is to simulate a supermarket checkout system with multiple checkout lines. Customers enter the supermarket with a set number of items, queue up in specific checkout lines, and exit the supermarket once all their items are processed. Key Rules and Actions Customer Entry and Line Joining: Customers are assigned a checkout line and a specific number of items upon entering. A customer cannot switch lines after joining. Basket Modification: Customers can add or remove items from their basket. If items are added, the customer must move to the back of the same line. If items are removed, the customer remains in their position in the line. Checkout Processing: LineService: Processes a specified number of items in a particular line. LinesService: Processes one item for each customer across all active lines. Customer Exit: A customer leaves the supermarket as soon as they have no items left. If multiple customers reach zero items at the same time, the one with the line closest to the exit leaves first. Methods to Implement on_customer_enter(customer_id, line_number, num_items): Adds a customer to a specified line with a set number of items. on_basket_change(customer_id, new_num_items): Updates the number of items for a customer. Moves the customer to the back of the line if items increase. on_line_service(line_number, num_processed_items): Processes a specific number of items in a given line. Removes customers with zero items and calls on_customer_exit. on_lines_service(): Processes one item per line, across all lines. Removes customers with zero items and calls on_customer_exit. on_customer_exit(customer_id) (pre-implemented): Prints the custome show goes as follows: 8 minutes after the start of the show a lion with a height of 200cm enters the room - based on the schedule it is not one of ours. 10 minutes after the start of the show two lions enter the room: a 310cm one and a 300cm one. The second one is marry. We do an inspection, but unfortunately marry is not the biggest lion in the room, so we return an empty list. 13 minutes after the start of the show rob enters the room and the unknown 310cm lion exits it. We do an inspection. Both marry and rob are higher than the 200cm height lion that entered the room at the 8th minute of the show, so we return both names. 15 minutes after the start of the show marry leaves the room. We do an inspection. rob is still the biggest lion in the room. 16 and 20 minutes after the start of the show both remaining lions exit the room.
我知道不好读但是照片有水印,加米我直接发🐎 |