Fast & Furious Driving School's (F&F) charges for lessons are as below: 



Time
Cost


Up to 1st hour
$30


Every subsequent half hour**
$10


** Subsequent charges are calculated by rounding up to nearest half hour.


For example, if student X has a lesson for 1hr 20 minutes, he will be charged $40 (30+10) for 1 hr 30 mins and if he has a lesson for 5 minutes, he will be charged $30 for the full hour. 

Out of the kindness of its heart, F&F also provides a 5 minutes grace period. So, if student X were to have a lesson for 65 minutes or 1 hr 35 mins, he will only have to pay for an hour or 1hr 30 minutes respectively. 

For a given lesson time in minutes (min) , write a function price to calculate how much the lesson costs.

Difficulty: EASY
Starter code: def cost(mins):
	

Solutions:
import math

def cost(mins):
	return 30 + 10 * math.ceil(max(0, mins - 60 - 5) / 30)


from math import ceil

def cost(n):
	n -= 5
	if n < 60:
		return 30
	n -= 60
	return 30 + ceil(n / 30) * 10


def cost(mins):
	price = 0
	print(mins)
	while mins > 0:
		if mins <= 65:
			price += 30
			mins -= 65
		elif mins - 65 > 0:
			price += 10
			mins -= 30
	return price


from math import ceil

def cost(mins):
	periods = ceil((mins - 5) / 30)
	return 30 if periods <= 2 else 30 + (periods - 2) * 10


def cost(mins):
	return max(0, -(-(mins - 65) // 30)) * 10 + 30


import math

def cost(mins):
	return 30 if mins < 60 else math.ceil((mins - 60 - 5) / 30) * 10 + 30


from math import ceil

def cost(minutes):
	return ceil(max(minutes + 25, 90) / 30) * 10


import math

def cost(mins):
	if mins <= 60:
		return 30
	if mins > 60:
		if mins % 30 <= 5:
			leftover = mins - 60
			multiple = round(leftover / 30)
			return 30 + 10 * multiple
		if mins % 30 > 5:
			leftover = mins - 60
			multiple = math.ceil(leftover / 30)
			return 30 + 10 * multiple


def cost(mins):
	price = 30
	while mins > 60:
		mins -= 30
		if mins > 35:
			price += 10
		else:
			return price
	else:
		return price


from math import ceil

def cost(n):
	return 30 + [ceil((n - 65) / 30) * 10, 0][n < 60]