# Four Friends Fries

Write a program that tracks a drive through at Four Friends Fries

Have a queue for the line of cars

Have a stack of cooked fries for serving

Simulate 60 minutes worth of time at the drive thru.

Every minute, there is a 1/3 chance of a car showing up when a car gets to the front of the queue, it orders 1-6 orders of fries randomly the fry stack can have up to 8 fries at a time, track the ‘time’ they are done cooking.  if a fry is older than 10 minutes, it can’t be served you can be cooking up to 4 orders of fries at a time in the frier, they take 2 minutes to cook so for each ‘minute’ figure out if a new car arrives in the drive through take any cooked fries out of the frier and add to the cooked fry stack ( with time done cooking ) take the order from the front car possibly add more fries to the frier to cook assume each order of fries costs \$.5, and is sold for \$1.

track total profit/loss after 60 minutes

import random
import time

class Fry:
def __init__(self, cook_time):
self.cook_time = cook_time

class Car:
def __init__(self, order_size):
self.order_size = order_size

def main():
queue = []
stack = []

# Track the time and profit
current_time = 0
profit = 0

# Cook up to 4 orders of fries at a time
frier_size = 4
frier = []

# A car has a 1/3 chance of arriving each minute
arrival_chance = 1 / 3

# Each order of fries takes 2 minutes to cook
fry_cook_time = 2

# Each order of fries costs \$0.5 and is sold for \$1
fry_cost = 0.5
fry_price = 1

while current_time < 60:
current_time +=
1

# Check if a new car arrives
if random.uniform(0, 1) < arrival_chance:
order_size = random.randint(
1, 6)
queue.append(Car(order_size))

# Remove any cooked fries from the frier and add them to the stack
for fry in frier:
fry.cook_time -=
1
if fry.cook_time == 0:
stack.append(fry)
frier = [fry
for fry in frier if fry.cook_time != 0]

# Cook more fries if there’s room in the frier
if len(frier) < frier_size:
if len(queue) > 0 and len(stack) >= queue.order_size:
new_fries = []
for i in range(min(frier_size – len(frier), queue.order_size)):
fry = stack.pop()
new_fries.append(Fry(fry_cook_time))
frier.extend(new_fries)

# Serve the front car if their order is ready
if len(queue) > 0 and len(stack) >= queue.order_size:
order_size = queue.pop(
0).order_size
for i in range(order_size):
stack.pop()
profit += fry_price * order_size – fry_cost * order_size

# Remove any fries that are older than 10 minutes
stack = [fry for fry in stack if current_time – fry.cook_time <= 10]

print(“Total profit after 60 minutes: \$” + str(profit))

if __name__ == ‘__main__’:
main()