A chess position can be expressed as a string using the  Forsyth–Edwards Notation (FEN). Your task is to write a parser that reads in a FEN-encoded string and returns a depiction of the board using the Unicode chess symbols (♔,♕,♘,etc.). The board should be drawn from the perspective of the active color (i.e. the side making the next move). 

Using the CodeWars dark theme is strongly recommended for this kata. Otherwise, the colors will appear to be inverted.

The complete FEN format contains 6 fields separated by spaces, but we will only consider the first two fields: Piece placement and active color (side-to-move). The rules for these fields are as follows:

The first field of the FEN describes piece placement.
Each row ('rank') of the board is described one-by-one, starting with rank 8 (the far side of the board from White's perspective) and ending with rank 1 (White's home rank). Rows are separated by a forward slash ('/').
Within each row, the contents of the squares are listed starting with the "a-file" (White's left) and ending with the "h-file" (White's right).
Each piece is identified by a single letter: pawn = P, knight = N, bishop = B, rook = R, queen = Q and king = K. White pieces are upper-case (PNBRQK), while black pieces are lowercase (pnbrqk).
Empty squares are represented using the digits 1 through 8 to denote the number of consecutive empty squares.
The piece placement field is followed by a single space, then a single character representing the color who has the next move ('w' for White and 'b' for Black).
Four additional fields follow the active color, separated by spaces. These fields can be ignored.


Using this encoding, the starting position is:

```rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1```

Using the characters "＿" and "▇" to represent dark and light unoccupied spaces, respectively, the starting position using the Unicode pieces would be:


♖♘♗♕♔♗♘♖
♙♙♙♙♙♙♙♙
▇＿▇＿▇＿▇＿
＿▇＿▇＿▇＿▇
▇＿▇＿▇＿▇＿
＿▇＿▇＿▇＿▇
♟♟♟♟♟♟♟♟
♜♞♝♛♚♝♞♜


After the move 1. Nf3, the FEN would be...

```rnbqkbnr/pppppppp/8/8/8/5N2/PPPPPPPP/RNBQKB1R b KQkq - 1 1```

...and because we draw the board from the perspective of the active color, the Unicode board would be:

♜＿♝♛♚♝♞♜
♟♟♟♟♟♟♟♟
▇＿♞＿▇＿▇＿
＿▇＿▇＿▇＿▇
▇＿▇＿▇＿▇＿
＿▇＿▇＿▇＿▇
♙♙♙♙♙♙♙♙
♖♘♗♕♔♗♘♖

Symbols

*Again, note that these colors are inverted from the Unicode character names because most people seem to use the dark theme for CodeWars.


Empty white square: ▇ (2587)
Empty black square: ＿ (FF3F)
White king (K): ♚ (265A)
White queen (Q): ♛ (265B)
White rook (R): ♜ (265C)
White bishop (B): ♝ (265D)
White knight (N): ♞ (265E)
White pawn (P): ♟ (265F)
Black king (k): ♔ (2654)
Black queen (q): ♕ (2655)
Black rook (r): ♖ (2656)
Black bishop (b): ♗ (2657)
Black knight (n): ♘ (2658)
Black pawn (p): ♙ (2659)

NB: Empty squares must have the proper colors. The bottom-right and top-left squares on a chess board are white.

Difficulty: EASY
Tags: String algorithms

Starter code:
def parse_fen(string):
	

Solutions:
from pprint import *
uni = {'q': '♕', 'B': '♝', 'p': '♙', 'K': '♚', 'N': '♞', 'Q': '♛', 'P': '♟', 'R': '♜', 'n': '♘', 'r': '♖', 'b': '♗', 'k': '♔', 1: '▇', 0: '＿'}

def parse_fen(string):
	board = [[1, 0, 1, 0, 1, 0, 1, 0] if not i % 2 else [0, 1, 0, 1, 0, 1, 0, 1] for i in range(8)]
	(col, row) = (0, 0)
	pos = 0
	(placement, turn) = string.split(' ')[:2]
	while pos < len(placement):
		if placement[pos] == '/':
			row += 1
			col = 0
		elif placement[pos].isdigit():
			col += int(placement[pos])
		else:
			board[row][col] = uni[placement[pos]]
			col += 1
		pos += 1
	board = [[uni[i] if type(i) is int else i for i in x] for x in board]
	if turn == 'b':
		board = [list(v)[::-1] for v in zip(*[i[::-1] for i in zip(*board)])]
	return '\n'.join([''.join(i) for i in board]) + '\n'


fen_notation = 'rnbqkbnrpc/CPRNBQKBNR'
chess_board = '♖♘♗♕♔♗♘♖♙＿\n▇♟♜♞♝♛♚♝♞♜'
table = dict(list(zip(fen_notation, chess_board)))

def parse_fen(fen_string):
	rev = lambda p: p[1][::(-1) ** (p[0] % 2)]
	board = list('/'.join(map(rev, enumerate(['Cc' * 4] * 8))))
	(idx, (game, turn)) = (0, fen_string.split()[:2])
	for c in game:
		if c.isdigit():
			idx += int(c)
		else:
			board[idx] = c
			idx += 1
	return rev((turn == 'b', ''.join(map(table.get, board)))) + '\n'


def parse_fen(string):
	unicodes = {'p': '♙', 'n': '♘', 'b': '♗', 'r': '♖', 'q': '♕', 'k': '♔', 'P': '♟', 'N': '♞', 'B': '♝', 'R': '♜', 'Q': '♛', 'K': '♚', 'black': '▇', 'white': '＿'}
	(black, white) = (unicodes['black'], unicodes['white'])
	empty = [list(black + white) * 4 if i % 2 == 0 else list(white + black) * 4 for i in range(8)]
	(field_one, active, *rest) = string.split(' ')
	rows = field_one.split('/')
	if active != 'w':
		rows = [i[::-1] for i in rows[::-1]]
	for (row_index, row) in enumerate(rows):
		count = 0
		for char in row:
			if char.isdigit():
				count += int(char)
			else:
				empty[row_index][count] = unicodes[char]
				count += 1
	return '\n'.join([''.join(i) for i in empty]) + '\n'


TOME = {0: '▇', 1: '＿', 'K': '♚', 'Q': '♛', 'R': '♜', 'B': '♝', 'N': '♞', 'P': '♟', 'k': '♔', 'q': '♕', 'r': '♖', 'b': '♗', 'n': '♘', 'p': '♙'}

def parse_fen(s):
	(bd, color, *_) = s.split()
	bd = [formatRow(row, x & 1) for (x, row) in enumerate(bd.split('/'))]
	if color == 'b':
		bd = (r[::-1] for r in reversed(bd))
	return '\n'.join(bd) + '\n'

def formatRow(row, p):
	out = ''.join((TOME[c] if not c.isdigit() else 'x' * int(c) for (i, c) in enumerate(row)))
	return ''.join((c if c != 'x' else TOME[p ^ i & 1] for (i, c) in enumerate(out)))


def parse_fen(string):
	(placement, active, *_) = string.split()
	board = []
	for (color, pieces) in enumerate(placement.split('/')):
		color %= 2
		rank = []
		for piece in pieces:
			if piece.isdigit():
				spaces = int(piece)
				for i in range(spaces):
					rank.append(empty[(color + i) % 2])
				color ^= spaces % 2
			else:
				rank.append(symbols[piece])
				color ^= 1
		board.append(rank)
	d = 1 if active == 'w' else -1
	return '\n'.join((''.join((c for c in rank[::d])) for rank in board[::d])) + '\n'
symbols = dict(list(zip('PNBRQKpnbrqk', '♟♞♝♜♛♚♙♘♗♖♕♔')))
empty = '▇＿'


BOARD = '▇＿▇＿▇＿▇＿\n＿▇＿▇＿▇＿▇\n▇＿▇＿▇＿▇＿\n＿▇＿▇＿▇＿▇\n▇＿▇＿▇＿▇＿\n＿▇＿▇＿▇＿▇\n▇＿▇＿▇＿▇＿\n＿▇＿▇＿▇＿▇'
PIECES = dict(zip('kqrbnpKQRBNP', '♔♕♖♗♘♙♚♛♜♝♞♟'))

def parse_fen(string):
	board = list(map(list, BOARD.splitlines()))
	(pieces, color) = string.split()[:2]
	for (r, rank) in enumerate(pieces.split('/')):
		f = 0
		for square in rank:
			if square.isdigit():
				f += int(square)
			else:
				board[r][f] = PIECES[square]
				f += 1
	return '\n'.join(map(''.join, board if color == 'w' else [rank[::-1] for rank in board[::-1]])) + '\n'


def parse_fen(string):
	ranks = string.split('/')
	game_info_fields = ranks[7].split(' ')
	ranks[7] = game_info_fields[0]
	color = game_info_fields[1]
	pretty_pieces = {'r': '♖', 'n': '♘', 'b': '♗', 'q': '♕', 'k': '♔', 'p': '♙', 'R': '♜', 'N': '♞', 'B': '♝', 'Q': '♛', 'K': '♚', 'P': '♟'}
	squares = ['▇', '＿']
	board = [[squares[(i + j) % 2] for i in range(0, 8)] for j in range(0, 8)]
	for row in range(0, 8):
		rank = ranks[row]
		column = 0
		for char in rank:
			if char.isnumeric():
				column += int(char)
			else:
				board[row][column] = pretty_pieces[char]
				column += 1
	stringify = '\n'.join([''.join(board[i]) for i in range(0, 8)])
	return stringify + '\n' if color is 'w' else stringify[::-1] + '\n'