## **Task**

Four mirrors are placed in a way that they form a rectangle with corners at coordinates `(0, 0)`, `(max_x, 0)`, `(0, max_y)`, and `(max_x, max_y)`. A light ray enters this rectangle through a hole at the position `(0, 0)` and moves at an angle of 45 degrees relative to the axes. Each time it hits one of the mirrors, it gets reflected. In the end, the light ray hits one of the rectangle's corners, and flies out. Your function must determine whether the exit point is either `(0, 0)` or `(max_x, max_y)`. If it is either `(0, 0)` or `(max_x, max_y)`, return `True` and `False` otherwise.

**Example**

For `max_x = 10` and `max_y = 20`, the ray goes through the following lattice points: `(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7), (8, 8), (9, 9), (10, 10), (9, 11), (8, 12), (7, 13), (6, 14), (5, 15), (4, 16), (3, 17), (2, 18), (1, 19), (0, 20)`.

The ray left the rectangle at position `(0, 20)`, so the result is `False`.

Here is an image of the light being reflected.
![d](https://upload.wikimedia.org/wikipedia/commons/thumb/7/73/Arithmetic-billiard-40-10.jpg/450px-Arithmetic-billiard-40-10.jpg)


Also, once completing this kata, please do not rate it based off of the difficulty level(kyu) and instead on whether you think it is a good kata.

Difficulty: EASY
Starter code: def reflections(max_x, max_y):
	

Solutions:
def reflections(n, m):
	x = y = 0
	dx = dy = 1
	while 1:
		x += dx
		y += dy
		if x == y == 0 or (x == n and y == m):
			return 1
		if 0 in (x, y) and (x == n or y == m):
			return 0
		if x in (0, n):
			dx *= -1
		if y in (0, m):
			dy *= -1


from math import gcd

def reflections(x, y):
	g = gcd(x, y)
	return (x // g + y // g) % 2 == 0


def reflections(max_x, max_y):
	return max_x & -max_x == max_y & -max_y


from math import gcd

def reflections(max_x, max_y):
	d = gcd(max_x, max_y)
	return max_x // d & max_y // d & 1


from math import gcd

def reflections(x, y):
	v = gcd(x, y)
	(x, y) = (x // v, y // v)
	return not x & 1 ^ y & 1


def reflections(max_x, max_y):
	slope = (1, 1)
	current = (1, 1)
	while True:
		if current[0] == max_x:
			slope = (-1, 1) if slope == (1, 1) else (-1, -1)
		elif current[1] == max_y:
			slope = (1, -1) if slope == (1, 1) else (-1, -1)
		elif current[0] == 0:
			slope = (1, 1) if slope == (-1, 1) else (1, -1)
		elif current[1] == 0:
			slope = (1, 1) if slope == (1, -1) else (-1, 1)
		current = (current[0] + slope[0], current[1] + slope[1])
		if current in [(0, 0), (max_x, max_y)]:
			return True
		elif current in [(0, max_y), (max_x, 0)]:
			return False


def reflections(max_x, max_y):
	return bool(max_x & -max_x & (max_y & -max_y))


from math import gcd

def reflections(max_x, max_y):
	i = gcd(max_x, max_y)
	return (max_x // i + max_y // i) % 2 == 0