       row.push 0
   row
 
-console.log collapseCells [0,4,4,0], 'right'
+# console.log collapseCells [0,4,4,0], 'right'
 
+moveIsValid = (originalBoard, newBoard) ->
+  for row in [0..3]
+    for col in [0..3]
+      if originalBoard[row][col] isnt newBoard[row][col]
+        return true
+  false
+
+showBoard = (board) ->
+  for row in [0..3]
+    for col in [0..3]
+      $(".r#{row}.c#{col} > div").html(board[row][col])
+
+printArray = (array) ->
+  console.log "--- Start ---"
+  for row in array
+    console.log row
+  console.log "--- End ---"
 
 
 $ ->

        else if row[b] isnt 0 then break
  row

console.log mergeCells [4,4,4,4], 'right'

collapseCells = (row, direction) ->
  row = row.filter (ele) -> ele isnt 0

  else
    generateTile(board)

move = (board, direction) ->
  newBoard = buildBoard()
  for i in [0..3]
    if direction == 'right' or 'left'
      row = getRow(i, board)
      row = mergeCells(row, direction)
      row = collapseCells(row, direction)
      setRow(row, i , newBoard)

  newBoard


getRow = (r, board) ->
  [board[r][0], board[r][1], board[r][2], board[r][3]]

setRow = (row, index, board) ->
  board[index] = row

mergeCells = (row, direction) ->

