Let's just place tokens on a connect four board.



** INPUT **

Provided as input the list of columns where a token is placed, from 0 to 6 included.
The first player starting is the yellow one (marked with `Y`), then the red (marked with `R`); the other cells might be empty and marked with `-`.

** OUTPUT **

The output is the state of the board after all the tokens in input have been placed.

** ASSUMPTIONS **

- The board is the standard 7x6;
- Of course you'll need to deal with gravity;
- You don't need to hassle with wrong input, wrong column numbers, checking for full column or going off the board;
- the columns list will always include proper column numbers;
- Notice: when you read the results in tests, the highest row appears first and the lowest row appears last; debugging using `\n` after each row might help (check example);

** EXAMPLES **

1.
```
Moves = [0,1,2,5,6]

Result:
['-', '-', '-', '-', '-', '-', '-']
['-', '-', '-', '-', '-', '-', '-']
['-', '-', '-', '-', '-', '-', '-']
['-', '-', '-', '-', '-', '-', '-']
['-', '-', '-', '-', '-', '-', '-']
['Y', 'R', 'Y', '-', '-', 'R', 'Y']
```
2.
```
Moves = [0,1,2,5,6,2,0,0]

Result:
['-', '-', '-', '-', '-', '-', '-']
['-', '-', '-', '-', '-', '-', '-']
['-', '-', '-', '-', '-', '-', '-']
['R', '-', '-', '-', '-', '-', '-']
['Y', '-', 'R', '-', '-', '-', '-']
['Y', 'R', 'Y', '-', '-', 'R', 'Y']
```

See test cases for better details.

Difficulty: EASY
Tags: Fundamentals

Data structures
Skill types: Data structures

Starter code:
def connect_four_place(columns):
	

Solutions:
def connect_four_place(columns):
	(player, board, placed) = (1, [['-'] * 7 for _ in range(6)], [-1] * 7)
	for c in columns:
		player ^= 1
		board[placed[c]][c] = 'YR'[player]
		placed[c] -= 1
	return board


from itertools import cycle, zip_longest
(EMPTY_CELL, HIGH, WIDTH) = ('-', 6, 7)

def connect_four_place(columns):
	(player, cols) = (cycle(['Y', 'R']), [[] for _ in range(WIDTH)])
	for c in columns:
		cols[c].append(next(player))
	while len(cols[0]) < HIGH:
		cols[0].append(EMPTY_CELL)
	return [list(l) for l in zip_longest(*cols, fillvalue=EMPTY_CELL)][::-1]


from itertools import zip_longest

def connect_four_place(columns):
	grid = [[] for _ in [0] * 7] + ['-' * 6]
	for (i, c) in enumerate(columns):
		grid[c].append('YR'[i % 2])
	return [list(l[:-1]) for l in zip_longest(*grid, fillvalue='-')][::-1]


def place(table, pos, arg):
	for i in range(6):
		if table[5 - i][pos] == '-':
			table[5 - i][pos] = arg
			break

def connect_four_place(columns):
	table = [['-' for i in range(7)] for j in range(6)]
	for i in range(len(columns)):
		if i % 2 == 0:
			place(table, columns[i], 'Y')
		else:
			place(table, columns[i], 'R')
	return table


from collections import Counter

def connect_four_place(columns):
	board = [['-' for i in range(7)] for i in range(6)]
	c = Counter(columns)
	for (i, x) in enumerate(columns):
		board[columns.count(x) - c[x]][x] = 'YR'[i % 2]
		c[x] -= 1
	return list(reversed(board))


import itertools

def connect_four_place(columns):
	cs = [[] for i in range(7)]
	for (color, i) in zip(itertools.cycle('YR'), columns):
		cs[i].append(color)
	for c in cs:
		c.extend(['-'] * (6 - len(c)))
	return [list(x) for x in zip(*cs)][::-1]


def connect_four_place(columns):
	board = [['-' for i in range(7)] for j in range(6)]
	for (turn, column) in enumerate(columns):
		for line in board:
			if line[column] == '-':
				line[column] = 'R' if turn % 2 else 'Y'
				break
	return board[::-1]


def connect_four_place(columns):
	mat = [[] for _ in range(7)]
	ply = 0
	for col in columns:
		mat[col].append('YR'[ply])
		ply ^= 1
	for col in mat:
		while len(col) < 6:
			col.append('-')
	return [list(row) for row in zip(*mat)][::-1]


COLUMNS = 7
ROWS = 6

def connect_four_place(columns):
	board = [['-'] * COLUMNS for row in range(ROWS)]
	height = [0] * COLUMNS
	for (i, column) in enumerate(columns):
		if i % 2 == 0:
			player = 'Y'
		else:
			player = 'R'
		board[height[column]][column] = player
		height[column] += 1
	return board[::-1]


def connect_four_place(columns):
	ls = [['-'] * 7, ['-'] * 7, ['-'] * 7, ['-'] * 7, ['-'] * 7, ['-'] * 7]
	for (i, j) in enumerate(columns):
		if i % 2 == 0:
			token = 'Y'
		else:
			token = 'R'
		z = 5
		while z >= 0:
			if ls[z][j] == '-':
				ls[z][j] = token
				break
			elif ls[z][j] != '-':
				z -= 1
	return ls