$\require{cancel}$
sap.txt file contains a single number, the amount of sap you have harvested but not yet sold the future syrup it will produce and the file orders.txt which contains orders which you have not yet committed to fulfilling.
Orders in the orders.txt file contain a customer number and the number of pints of syrup they wish to order. It is in the format:
100201 3 100527 5 100012 1with the least recient order on top. You only sell on a first come first served basis. (IE you will fill the order for customer 100201 first).
At the end of each day, you compute the amout of syrup you can produce and then process all orders which can be fulfilled with this production. You assume that your production methods are efficient and there is no loss during production.
Algorihtm:
Get sap available
while not done
done = true
get customer
if the customer is valid
compute sap needed
if sap needed <= sap available
sap avaialble = sap available - sap needed
Process Customer Order
Remove Customer from order file.
update sap file