You have recently discovered that horses travel in a unique pattern - they're either running (at top speed) or resting (standing still).

Here's an example of how one particular horse might travel:

```
The horse Blaze can run at 14 metres/second for 60 seconds, but must then rest for 45 seconds.

After 500 seconds Blaze will have traveled 4200 metres.
```

Your job is to write a function that returns how long a horse will have traveled after a given time.

####Input: 

* totalTime - How long the horse will be traveling (in seconds)

* runTime - How long the horse can run for before having to rest (in seconds)

* restTime - How long the horse have to rest for after running (in seconds)

* speed - The max speed of the horse (in metres/second)

Source: codewars | Difficulty: EASY
Tags: Ad-hoc

Starter code: def travel(total_time, run_time, rest_time, speed):
	

Solutions:
def travel(total_time, run_time, rest_time, speed):
	(q, r) = divmod(total_time, run_time + rest_time)
	return (q * run_time + min(r, run_time)) * speed


def travel(total_time, run_time, rest_time, speed):
	(d, m) = divmod(total_time, run_time + rest_time)
	return (d * run_time + min(m, run_time)) * speed


def travel(total_time, run_time, rest_time, speed):
	(cycle, left) = divmod(total_time, run_time + rest_time)
	return cycle * run_time * speed + min(left, run_time) * speed


def travel(total_time, run_time, rest_time, speed):
	(cycles, remaining) = divmod(total_time, run_time + rest_time)
	last_run = min(remaining, run_time)
	return (cycles * run_time + last_run) * speed

def travel(total, run, rest, speed):
	return (total // (run + rest) * run + min(total % (run + rest), run)) * speed


def travel(total_time, run_time, rest_time, speed):
	return speed * (run_time * (total_time // (run_time + rest_time)) + min(run_time, total_time % (run_time + rest_time)))


def travel(total_time, run_time, rest_time, speed):
	(runs, extra) = divmod(total_time, run_time + rest_time)
	return (runs * run_time + min(extra, run_time)) * speed


def travel(total_time, run_time, rest_time, speed):
	(x, y) = divmod(total_time, run_time + rest_time)
	return (x * run_time + min(y, run_time)) * speed


def travel(total_time, run_time, rest_time, speed):
	av_speed = speed * run_time / (run_time + rest_time)
	av_time = total_time // (run_time + rest_time)
	r_time = total_time - av_time * (run_time + rest_time)
	return round(av_time * (run_time + rest_time) * av_speed + run_time * speed) if run_time < r_time else round(av_time * (run_time + rest_time) * av_speed + r_time * speed)


def travel(total_time, run_time, rest_time, speed):
	run_periods = float(total_time) / (run_time + rest_time)
	last_run_time = min(run_periods - int(run_periods), float(run_time) / (run_time + rest_time)) * (run_time + rest_time)
	total_run_time = int(run_periods) * run_time + last_run_time
	return round(total_run_time * speed)


def travel(total_time, run_time, rest_time, speed):
	(s, is_running) = (0, True)
	while total_time:
		if is_running:
			s += min(total_time, run_time) * speed
		total_time -= min(total_time, run_time) if is_running else min(rest_time, total_time)
		is_running = not is_running
	return s