# Task
 Given a position of a knight on the standard chessboard, find the number of different moves the knight can perform.

 The knight can move to a square that is two squares horizontally and one square vertically, or two squares vertically and one square horizontally away from it. The complete move therefore looks like the letter L. Check out the image below to see all valid moves for a knight piece that is placed on one of the central squares.

 ![](https://codefightsuserpics.s3.amazonaws.com/tasks/chessKnight/img/knight.jpg?_tm=1473533979951)

# Example

 For `cell = "a1"`, the output should be `2`.

 ![](https://codefightsuserpics.s3.amazonaws.com/tasks/chessKnight/img/ex_1.jpg?_tm=1473533980197)

 For `cell = "c2"`, the output should be `6`.

 ![](https://codefightsuserpics.s3.amazonaws.com/tasks/chessKnight/img/ex_2.jpg?_tm=1473533980368)

# Input/Output


 - `[input]` string `cell`

    String consisting of letter+number - coordinates of the knight on an 8 × 8 chessboard in chess notation.


 - `[output]` an integer

Difficulty: EASY

Starter code:
def chess_knight(cell):
	

Solutions:
def chess_knight(cell):
	(x, y) = (ord(c) - ord(origin) for (c, origin) in zip(cell, 'a1'))
	return sum((0 <= x + dx < 8 and 0 <= y + dy < 8 for (dx, dy) in ((-2, -1), (-2, 1), (-1, -2), (-1, 2), (1, -2), (1, 2), (2, -1), (2, 1))))


moves = {(-2, -1), (-2, 1), (-1, 2), (1, 2), (2, 1), (2, -1), (1, -2), (-1, -2)}

def chess_knight(cell):
	(x, y) = (ord(cell[0]) - ord('a') + 1, int(cell[1]))
	return sum((0 < x + mx < 9 and 0 < y + my < 9 for (mx, my) in moves))


def chess_knight(cell):
	(x, y) = (ord(cell[0]) - 96, int(cell[1]))
	return sum([1 for dx in [-2, -1, 1, 2] for dy in [-2, -1, 1, 2] if all([abs(dx / dy) != 1, 0 < x + dx < 9, 0 < y + dy < 9])])


result = (2, 3, 4, 3, 4, 6, 4, 6, 8)

def chess_knight(cell):
	(x, y) = (ord(cell[0]) - 97, int(cell[1]) - 1)
	(x, y) = (min(2, x, 7 - x), min(2, y, 7 - y))
	return result[3 * x + y]


def chess_knight(cell):
	file = cell[0]
	rank = cell[1]
	if cell in ['a1', 'a8', 'h1', 'h8']:
		return 2
	if cell in ['a2', 'a7', 'b1', 'b8', 'g1', 'g8', 'h2', 'h7']:
		return 3
	if 'c' <= file <= 'f':
		if '3' <= rank <= '6':
			return 8
	if file in ['b', 'g'] and '3' <= rank <= '6':
		return 6
	if rank in ['2', '7'] and 'c' <= file <= 'f':
		return 6
	return 4


def chess_knight(k):
	(x, y) = (ord(k[0]) - ord('a'), ord(k[1]) - ord('1'))
	moves = 0
	if x - 2 in range(8) and y - 1 in range(8):
		moves += 1
	if x - 2 in range(8) and y + 1 in range(8):
		moves += 1
	if x - 1 in range(8) and y - 2 in range(8):
		moves += 1
	if x - 1 in range(8) and y + 2 in range(8):
		moves += 1
	if x + 1 in range(8) and y - 2 in range(8):
		moves += 1
	if x + 1 in range(8) and y + 2 in range(8):
		moves += 1
	if x + 2 in range(8) and y - 1 in range(8):
		moves += 1
	if x + 2 in range(8) and y + 1 in range(8):
		moves += 1
	return moves


from string import ascii_lowercase
_MOVES = [complex(a * c, b * d) for (a, b) in ((1, 2), (2, 1)) for c in (1, -1) for d in (1, -1)]
_BOARD = [complex(a, b) for a in range(1, 9) for b in range(1, 9)]

def chess_knight(cell):
	(file, rank) = cell
	start = complex(ascii_lowercase.index(file) + 1, int(rank))
	return sum((start + move in _BOARD for move in _MOVES))


def chess_knight(cell):
	(col, row) = cell
	(col, row) = (ord(col) - 97, int(row) - 1)
	return sum((abs(y - row) ** 2 + abs(x - col) ** 2 == 5 for y in range(8) for x in range(8)))


def chess_knight(pos):
	(i, j) = (int(8 - int(pos[1])), 'abcdefgh'.index(pos[0]))
	(A, B, C, D, E, F, G, H) = (i > 0, i < 7, j - 2 >= 0, j + 2 < 8, i + 2 < 8, i - 2 >= 0, j > 0, j < 7)
	return sum([A and D, A and C, B and C, B and D, F and H, F and G, E and H, E and G])


def chess_knight(cell):
	return sum((1 <= ord(cell[0]) - 96 + d1 <= 8 and 1 <= int(cell[1]) + d2 <= 8 for h in [2, -2] for w in [1, -1] for (d1, d2) in [(h, w), (w, h)]))