# Setting up variables
numOfZones = int(input("Enter the number of zones: "))
spacesPerZone = int(input("Enter the number of spaces per zone: "))
zoneCounter = 1
freeSpaces = 0
mostFreeSpaces = 0
mostFreeZone = 1

# Looping through each zone and calculating occupancy status until all zones are completed
while zoneCounter <= numOfZones:

	# Collecting number of cars entered and exited
	carsEntered = int(input(f"Enter the number of cars that have entered the zone {zoneCounter}: "))

	carsExited = int(input(f"Enter the number of cars that have exited the zone {zoneCounter}: "))
	while carsExited > carsEntered:
		carsExited = int(input(f"Invalid input: Number of exited cars cannot exceed number of entered cars: "))

	# Calculating number of occupied spaces and occupancy percentage
	occupiedSpaces = carsEntered - carsExited
	occupiedPercent = int((occupiedSpaces / spacesPerZone) * 100)
	freeSpaces = spacesPerZone - occupiedSpaces

	# Displaying occupancy status to user
	if occupiedSpaces == 1:
		print(f"Zone {zoneCounter} has {occupiedSpaces} occupied space and is {occupiedPercent}% occupied.")
	else:
		print(f"Zone {zoneCounter} has {occupiedSpaces} occupied spaces and is {occupiedPercent}% occupied.")

	# Displaying warning, if occupancy above 80%
	if occupiedPercent >= 80:
		print(f"Warning: Zone {zoneCounter} is {occupiedPercent}% occupied. You should use a different zone.")

	# Mark as least occupied zone, if zone has most free spaces
	if freeSpaces > mostFreeSpaces:
		mostFreeSpaces = freeSpaces
		mostFreeZone = zoneCounter

	# Incrementing zone counter before looping to next zone
	zoneCounter += 1

# Presents the car park status to the user
if mostFreeSpaces == 0:
	print(f"Sorry, this car park is full and has no available spaces.")
elif mostFreeSpaces == 1:
	print(f"Zone {mostFreeZone} has the most available space, with {mostFreeSpaces} available space.")
else:
	print(f"Zone {mostFreeZone} has the most available space, with {mostFreeSpaces} available spaces.")
