Round any given number to the closest 0.5 step

I.E.
```
solution(4.2) = 4
solution(4.3) = 4.5
solution(4.6) = 4.5
solution(4.8) = 5
```

Round **up** if number is as close to previous and next 0.5 steps.

```
solution(4.75) == 5
```

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Mathematics

Starter code: def solution(n):
	

Solutions:
import math

def solution(n):
	d = 0
	if n - 0.25 < math.floor(n):
		d = math.floor(n)
	elif n - 0.75 < math.floor(n):
		d = math.floor(n) + 0.5
	else:
		d = math.ceil(n)
	return d


def solution(n):
	return round(n * 2) / 2 if n != 4.25 else 4.5


def solution(n):
	x = divmod(n, 0.5)
	if x[1] < 0.25:
		return x[0] * 0.5
	else:
		return x[0] / 2 + 0.5


def solution(n):
	return int(2 * n + 0.5) / 2


def solution(n):
	fint = int(n)
	diff = n - fint
	if diff < 0.25:
		rdiff = 0
	if diff >= 0.25 and diff < 0.75:
		rdiff = 0.5
	if diff >= 0.75:
		rdiff = 1
	rounded = rdiff + fint
	return rounded