An Ironman Triathlon is one of a series of long-distance triathlon races organized by the World Triathlon Corporaion (WTC).
It consists of a 2.4-mile swim, a 112-mile bicycle ride and a marathon (26.2-mile) (run, raced in that order and without a break. It hurts... trust me.

Your task is to take a distance that an athlete is through the race, and return one of the following:

If the distance is zero, return `'Starting Line... Good Luck!'`.

If the athlete will be swimming, return an object with `'Swim'` as the key, and the remaining race distance as the value.

If the athlete will be riding their bike, return an object with `'Bike'` as the key, and the remaining race distance as the value.

If the athlete will be running, and has more than 10 miles to go, return an object with `'Run'` as the key, and the remaining race distance as the value.

If the athlete has 10 miles or less to go, return return an object with `'Run'` as the key, and `'Nearly there!'` as the value.

Finally, if the athlete has completed te distance, return `"You're done! Stop running!"`.

All distance should be calculated to two decimal places.

Difficulty: EASY
Tags: Fundamentals

Data structures
Skill types: Data structures

Starter code:
def i_tri(s):
	

Solutions:
def i_tri(s):
	total = 2.4 + 112 + 26.2
	to_go = '%.2f to go!' % (total - s)
	return 'Starting Line... Good Luck!' if s == 0 else {'Swim': to_go} if s < 2.4 else {'Bike': to_go} if s < 2.4 + 112 else {'Run': to_go} if s < total - 10 else {'Run': 'Nearly there!'} if s < total else "You're done! Stop running!"


def i_tri(s):
	t = 2.4 + 112.0 + 26.2
	v = t - s
	k = 'Swim' if s < 2.4 else 'Bike' if s >= 2.4 and s < 114.4 else 'Run'
	if s == 0:
		return 'Starting Line... Good Luck!'
	elif s >= t:
		return "You're done! Stop running!"
	elif t - s <= 10:
		return {'Run': 'Nearly there!'}
	else:
		return {k: '{:.2f}'.format(v) + ' to go!'}


def i_tri(d):
	(r, k) = (140.6 - d, 'Run' if 114.4 < d else 'Bike' if 2.4 < d else 'Swim')
	v = f'{r:.2f} to go!' if r > 10 else 'Nearly there!'
	return {k: v} if d * r > 0 else "You're done! Stop running!" if d > 0 else 'Starting Line... Good Luck!'


def i_tri(s):
	out = 'Starting Line... Good Luck!'
	if s > 0.0 and s <= 2.4:
		out = {'Swim': f'{140.6 - s:.2f} to go!'}
	if s > 2.4 and s <= 114.4:
		out = {'Bike': f'{140.6 - s:.2f} to go!'}
	if s > 114.4 and s < 130.6:
		out = {'Run': f'{140.6 - s:.2f} to go!'}
	if s >= 130.6 and s < 140.6:
		out = {'Run': 'Nearly there!'}
	if s > 140.6:
		out = "You're done! Stop running!"
	return out


def i_tri(s):
	d = {2.4: 'Swim', 114.4: 'Bike', 140.6: 'Run'}
	if s == 0:
		return 'Starting Line... Good Luck!'
	for k in sorted(d):
		if s < k:
			return {d[k]: '{:.02f} to go!'.format(140.6 - s)}
	return "You're done! Stop running!"


def i_tri(s):
	if s == 0:
		return 'Starting Line... Good Luck!'
	swim = 2.4
	bicycle = 112
	marathon = 26.2
	distance = swim + bicycle + marathon
	if s > distance:
		return "You're done! Stop running!"
	txt = 'Swim' if s <= swim else 'Bike' if s <= swim + bicycle else 'Run'
	remaining = distance - s
	obj = {f'{txt}': f'{remaining:.2f} to go!'}
	return obj


def i_tri(s):
	stages = [['Starting Line... Good Luck!'], [2.4, 'Swim'], [114.4, 'Bike'], [140.6, 'Run'], ['Nearly there!'], ["You're done! Stop running!"]]
	if not s:
		return stages[0][0]
	elif s >= 140.6:
		return stages[-1][0]
	else:
		curr_stage = [v for (k, v) in stages[1:4] if s <= k]
		return {curr_stage[0]: '{:.2f} to go!'.format(140.6 - s)} if s <= 130.6 else {curr_stage[0]: stages[4][0]}