Skip to content

Instantly share code, notes, and snippets.

@distributedlife
Last active December 27, 2015 09:09
Show Gist options
  • Select an option

  • Save distributedlife/7301907 to your computer and use it in GitHub Desktop.

Select an option

Save distributedlife/7301907 to your computer and use it in GitHub Desktop.
snippets for improve this from november 2013 - p2 magazine
a = [[], [], [], []]
width = 10
length = 4
stones = 2 # or 3
for i in range(length):
for j in range(width):
a[i].append(stones)
if i == 1 and j == width - 2:
a[i][j] = 1
if i == 1 and j == width - 1:
a[i][j] = 0
if i == 2 and j == 0:
a[i][j] = 0
if i == 2 and j == 1:
a[i][j] = 1
if stones == 3:
if i == 1 and j == width - 3:
a[i][j] = 2
if i == 2 and j == 2:
a[i][j] = 2
for i in range(length):
for j in range(width):
a[i].append(stones)
def array(stones, length):
return [stones]*length
a = map(array, ([tincuva]*width, length))
a[1][width - 2] = 1
a[1][width - 1] = 0
a[2][0] = 0
a[2][1] = 1
if stones == 3:
a[1][width - 3] = 2
a[2][2] = 2
a[1][-3] = 2
a[1][-2] = 1
a[1][-1] = 0
a[2][0] = 0
a[2][1] = 1
a[2][2] = 2
width = 10
length = 4
stones = 2 # or 3
board = [[], [], [], []]
def set_board_up(length, breadth, tincuva):
board = map(array, ([tincuva]*breadth, length))
board[1][-3] = 2
board[1][-2] = 1
board[1][-1] = 0
board[2][0] = 0
board[2][1] = 1
board[2][2] = 2
return board
board[1][-1], board[2][0] = 0, 0
board[1][-2], board[2][1] = 1, 1
board[1][-3], board[2][2] = 2, 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment