Write a program that prints a chessboard with N rows and M columns with the following rules:
The top left cell must be an asterisk (*)
Any cell touching (left, right, up or down) a cell with an asterisk must be a dot (.)
Any cell touching (left, right, up or down) a cell with a dot must be an asterisk.

A chessboard of 8 rows and 8 columns printed using these rules would be:
```
*.*.*.*.
.*.*.*.*
*.*.*.*.
.*.*.*.*
*.*.*.*.
.*.*.*.*
*.*.*.*.
.*.*.*.*
```
Input

A single line with two integers N and M separated by space. The number N will represent the number of rows and M the number of columns.

Output

Return N lines each containing M characters with the chessboard pattern.
Empty string if N, M or both are 0.


From: 2016 AIPO National Finals
http://aipo.computing.dcu.ie/2016-aipo-national-finals-problems

Difficulty: introductory

Starter code:

def chessboard(s):
	

Solutions:
def chessboard(s):
    N, M = map(int, s.split())
    row = ".*" * M
    return "\n".join( [row[:M] if i&1 else row[1:M+1] for i in range(N)] )

chessboard = lambda s: '\n'.join(([''.join(['.' if (x + y) % 2 else '*' for x in range(int(s.split()[1]))]) for y in range(int(s.split()[0]))]))

from itertools import cycle, islice


def chessboard(s):
    n, m = (int(a) for a in s.split())
    if not n or not m:
        return ''
    return '\n'.join(islice(cycle(
        (''.join(islice(cycle('*.'), m)), ''.join(islice(cycle('.*'), m)))
    ), n))

def chessboard(st):
    height, width = map(int, st.split())
    if height == 0 or width == 0: return ""
    board = [["*."[(x+y)&1] for x in range(width)] for y in range(height)]
    return "\n".join(map("".join, board))

def chessboard(s):
    rows,cols = map(int,s.split())
    if rows and cols:
        return "\n".join("".join("*."[(i+j)%2] for i in range(cols)) for j in range(rows))
    return ''

def chessboard(s):
    a,b = map(int,s.split())
    return '\n'.join(('*.'*(b+1))[i&1:(i&1)+b] for i in range(a))

def chessboard(s):
    row, column = [int(num) for num in s.split()]
    return "\n".join("".join("*."[(i + j) % 2] for j in range(column)) for i in range(row))

def chessboard(s):
    w,h=map(int,s.split())
    return'\n'.join(''.join('*.'[(i+j)%2]for i in range(h))for j in range(w))

def chessboard(s):m,n=map(int,s.split());return'\n'.join(('*.'*n)[i%2:n+i%2]for i in range(m))

def chessboard(s):
    r,c=map(int,s.split())
    return "\n".join("".join("*."[j%2!=i%2] for j in range(c)) for i in range(r))