xxx020xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 464, 'const': 266, 'code+const': 730}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], []]
import numpy as np
def get_score(board):
    s = 0
    l = board.shape[1]
    z = board != 0
    n = np.sum(z, axis=1)
    x = sum(n == l)
    return x*40
def get_time_cap(board, time_caps):
    r = board.shape[0]
    t = len(time_caps)
    n = r//t
    z = np.sum(board, axis=1)
    x = np.sum(z)
    y = np.arange(r)
    if x == 0 :
        return time_caps[-1]
    else :
        a = y[z > 0]
        k = a[0]
        return time_caps[k//n]
def rotate_right(shape):
    r = shape[::-1,:]
    return r.T
def rotate_left(shape):
    l = shape.T
    return l[::-1,:]
def animate_drop(board, shape, c):
    a = []
    row = board.shape[0]
    col = board.shape[1]
    sc = shape.shape[1] 
    sr = shape.shape[0]
    for i in range(row) :
        new = np.array(board)
        n = new[i:i+sr, c:c+sc]
        if np.sum(n == 0) == sc*sr :
            new[i:i+sr, c:c+sc] = shape
            a.append(new)
    return a
def animate_clear(board):
    pass

xxx024xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 926, 'const': 366, 'code+const': 1292}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 7)], [('While', 12)]]
import numpy as np
def get_score(board):
    s = np.min(board, axis = 1)
    return len(s[s > 0])*40
def get_time_cap(board, time_caps):
    nrows = board.shape[0]
    t = len(time_caps)
    n = nrows//t
    nrange = np.arange(n,nrows+n,n)
    s = np.sum(board, axis = 1)
    l = np.arange(0,nrows)
    allpos = s>0
    if True not in allpos :
        return time_caps[-1]
    first_index_pos = np.min(l[s>0])
    first_group = np.min(nrange[nrange>first_index_pos])
    first_time_cap = first_group//n - 1
    return time_caps[first_time_cap]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    new_board1 = np.array(board)
    shape_board = np.zeros_like(board,int)
    start = 0
    shape_board[start:shape.shape[0],c:c+shape.shape[1]] = shape
    result = []
    while True :
        new_board2 = new_board1 + shape_board
        if sorted(list(board[board>0]) + list(shape[shape>0])) == sorted(list(new_board2[new_board2>0])) :
            result.append(np.array(new_board2))
            start += 1
            if start > (board.shape[0] - shape.shape[0]) : break
            shape_board = np.zeros_like(board,int)
            shape_board[start:shape.shape[0]+start,c:c+shape.shape[1]] = shape
        else :
            break
    return result
def animate_clear(board):
    result = []
    new_board = np.array(board)
    row_min = np.min(board, axis = 1)
    new_board[row_min != 0] = 0
    if list(np.sum(new_board,axis = 1)) == list(np.sum(board, axis = 1)) :
        return result
    new_board_1 = np.array(new_board)
    result.append(np.array(new_board))
    i = board.shape[0]-1
    while i > -1 :
        if sum(new_board[i]) == 0 :
            if i == board.shape[0]-1 :
                new_board_1[board.shape[0]-i:i+1] = new_board[board.shape[0]-i-1:i]
                new_board_1[0] = 0
            else :
                new_board_1[board.shape[0]-i-1:i+1] = new_board[board.shape[0]-i-2:i]
                new_board_1[0] = 0
            if list(np.sum(new_board_1, axis = 1)) == list(np.sum(new_board, axis = 1)) :
                break
            else :
                result.append(np.array(new_board_1))
                new_board = np.array(new_board_1)
        else : i -= 1
    return result

xxx042xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 790, 'const': 364, 'code+const': 1154}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 8)], [('While', 11)]]
import numpy as np
def get_score(board):
  a = np.min(board,axis = 1)
  return (a[a!=0].shape[0])*40
def get_time_cap(board, time_caps):
  a = board.reshape(len(time_caps), int((board.shape[0]/len(time_caps)*board.shape[1])))
  a = np.max(a,axis = 1) 
  c = np.array(time_caps)
  c = c[a != 0]
  if c.shape[0] == 0 :
    return time_caps[-1]
  return c[0]
def rotate_right(shape):
  return shape.T[:,::-1]
def rotate_left(shape):
  return shape.T[::-1,:]
def animate_drop(board, shape, c):
  new_shape = np.array(shape)
  x=[]
  a=0
  b=new_shape!=0
  d = True
  while True :
    new_board = np.array(board)
    n=new_board[a:a+new_shape.shape[0] , c:c+new_shape.shape[1]]
    if a==0 and np.max(n[0,:]) != 0: break
    if n.shape[0]==new_shape.shape[0]:
      if np.max(n[b]) == 0 and a<=new_board.shape[0]-new_shape.shape[0]:
        n[b]=new_shape[b]
        x.append(new_board)
        a+=1
      else: d=False; break
    elif d==False: break
    else: break
  return x
def animate_clear(board):
  new_board = np.array(board)
  a = np.min(board,axis = 1)
  new_board[a!=0] = 0 
  x = [np.array(new_board)]
  index = new_board.shape[0] - 1
  stop = 0
  if np.max(a) == 0 :
    return []
  while True :
    if np.max(new_board[index , ::]) == 0 and np.max(new_board[index -1 , ::]) != 0 :
      new_board[index , ::] = new_board[index -1 , ::]
      new_board[index -1 , ::] = 0
      stop += 1
    if index ==  1:
      x.append(np.array(new_board))
      if stop == 0 :
        break
      stop = 0
      index = new_board.shape[0] - 1
    index -= 1
  return x[:-1]

xxx034xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score0.0NameError("name 'np' is not defined")
[0, 120]
test_get_time_cap0.0NameError("name 'np' is not defined")
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right0.0NameError("name 'np' is not defined")
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left0.0NameError("name 'np' is not defined")
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0NameError("name 'np' is not defined")
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0NameError("name 'np' is not defined")
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0NameError("name 'np' is not defined")
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0NameError("name 'np' is not defined")
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0NameError("name 'np' is not defined")
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0NameError("name 'np' is not defined")
[[]]
bytecount: {'code': 662, 'const': 286, 'code+const': 948}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 24)], []]
def get_score(board):
    x = np.min(board,axis=1)
    y = board[x!=0]
    return len(y)*40
def get_time_cap(board, time_caps):
    time_caps += int(len(board)/len(time_caps)-1)*time_caps
    time_caps.sort()
    x = np.sum(board,axis=1)
    row = np.arange(board.shape[0])
    if np.sum(x)==0:
        return time_caps[-1]
    else:
        pos = row[x!=0][0]
        return time_caps[pos]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
  cb = board.shape[1] 
  cs = shape.shape[1]
  rb = board.shape[0] 
  rs = shape.shape[0]
  tf = sum(board[0:rs,c:c+cs]!=0)
  l = []
  if sum(tf)!=0:
      return l
  else:
      new_board = np.array(board)
      new_shape = np.zeros((shape.shape[0],cb),int)
      new_shape[:,c:cs+c] = new_shape[:,c:cs+c]+shape[:,:]
      row = np.arange(board.shape[0])
      y = np.sum(board[:,c:c+cs],axis=1)
      x = row[y==0]
      check = np.arange(len(x))
      d = x-check
      z = x[d==0]
      if rs>1:
          n = len(z)-((rs)-1)
      else:
          n = len(z)
      for i in range(n):
          new_board[i:i+rs] = new_board[i:i+rs]+new_shape
          l.append(new_board)
          new_board = np.array(board)
      return l
def animate_clear(board):
    pass

xxx026xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 968, 'const': 280, 'code+const': 1248}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 16)]]
import numpy as np
def get_score(board):
  o=np.zeros_like(board,int)
  u=np.arange(board.shape[0])
  un=u.reshape((1,board.shape[0]))
  t=un.T+o
  k=np.zeros_like(board,int)
  n=t[board == k]
  return len(set(u)-set(n))*40
def get_time_cap(board, time_caps):
  o=np.zeros_like(board,int)
  u=np.arange(board.shape[0])
  un=u.reshape((1,board.shape[0]))
  t=un.T+o
  k=np.zeros_like(board,int)
  n=t[board != k]
  if n.shape[0] != 0:
    a=board.shape[0]//len(time_caps)
    return time_caps[n[0]//a] 
  else:
    return time_caps[-1]
def rotate_right(shape):
  return shape[::-1,:].T
def rotate_left(shape):
  return shape[:,::-1].T
def animate_drop(board, shape, c):
  a=[]
  new_shape = np.array(shape)
  new_board=np.array(board)
  for i in range(new_board.shape[0]):
    x=new_board[i:shape.shape[0]+i,c:c+shape.shape[1]]
    if x.shape != shape.shape:
      break
    b= x[new_shape != 0]==0
    if False not in b and True in b:
      o=np.array(new_board)
      o[i:shape.shape[0]+i,c:c+shape.shape[1]]+=new_shape
      a.append(o)
    else: 
      break
  return a
def animate_clear(board):
  a=[]
  new_board = np.array(board)
  o=np.zeros_like(board,int)
  u=np.arange(board.shape[0])
  un=u.reshape((1,board.shape[0]))
  t=un.T+o
  k=np.zeros_like(board,int)
  n=t[board == k]
  r=list(set(u)-set(n))
  if len(r) == 0:
    return a
  new_board[r,:]=0 
  l=new_board.shape[0]-1
  while l>0:
    ww=new_board[:l,:] == 0
    if False not in ww:
      break
    b=new_board[l,:]==0
    if False not in b and True in b:
      a.append(new_board)
      j=np.zeros_like(board,int)
      j[l:,:]=new_board[l:,:]
      j[1:l+1,:]+=new_board[:l,:]
      new_board=j
    else:
      l-=1
  a.append(new_board)
  return a

xxx212xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 740, 'const': 338, 'code+const': 1078}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 15)]]
import numpy as np
def get_score(board):
    x = np.min(board , axis=1 )
    y = np.sum(x != 0)
    return y*40
def get_time_cap(board, time_caps):
    d = board.shape[0]//len(time_caps)
    x =np.sum(board , axis=1)
    if np.sum(x) == 0 :
        j = -1
    else :
        pos = np.arange(x.shape[0])
        i = pos[x > 0][0]
        j = i//d
    return time_caps[j]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    out = []
    new_shape = np.array(shape)
    l = c + new_shape.shape[1]
    for i in range(board.shape[0]-shape.shape[0]+1) :
        new_board = np.array(board)
        x = board != 0
        new_board[i:i+shape.shape[0],c:c+shape.shape[1]] += new_shape
        b401 = np.sum(x) + np.sum(shape != 0)
        rft02 = np.sum(new_board != 0 )
        if b401 == rft02 :
            out.append(new_board)
        else :
            break
    return out
def animate_clear(board):
    out = []
    new_board = np.array(board)
    l = np.arange(new_board.shape[0])
    z = np.zeros(new_board.shape[1])
    y = new_board != 0
    x = np.sum(y,axis=1)
    pos = np.arange(x.shape[0])
    i = pos[x == new_board.shape[1] ]
    new_board[i,] = z
    out.append(new_board)
    if np.sum(np.sum(new_board != 0 ,axis=1)== 0) == 0 :
        return []
    while True :
        a = np.sum(new_board != 0 ,axis=1) == 0
        position = np.arange(new_board.shape[0])
        b = position[a][-1]
        new_board = new_board[[b]+list(position[:b])+list(position[b+1:])]
        if str(new_board) == str(out[-1]) :
            break
        else :
            out.append(new_board)     
    return out

xxx203xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1008, 'const': 338, 'code+const': 1346}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 8)], [('While', 18)]]
import numpy as np
def get_score(board):
    s = np.sum(board==0,axis=1)
    return len(s[s==0])*40
def get_time_cap(board, time_caps):
    s = np.arange(board.shape[0])
    l = list(s[np.sum(board, axis=1)!=0])
    if len(l)==0:
        return time_caps[-1]
    else:
        brow = board.shape[0]
        n = len(time_caps)
        row = l[0]
        return time_caps[int(row//(brow/n))]
def rotate_right(shape):
    s = shape.T
    return s[:,::-1]
def rotate_left(shape):
    s = shape.T
    return s[::-1,:]
def animate_drop(board, shape, c):
    l = []
    newboard = np.array(board)
    row = shape.shape[0]
    col = shape.shape[1]
    n = -(row-1)
    while n<(newboard.shape[0]-row+1):
        if n<0:
            check = shape[-(row+n):,:]!=0
            rrow = shape[-(row+n):,].shape[0]
            eachcheck = newboard[:rrow,c:c+col][check]!=0
            if np.sum(eachcheck) != 0:
                return l
            else:
                n += 1
        elif n>=0:
            check = shape!=0
            eachcheck = newboard[n:n+row,c:c+col][check]!=0
            if np.sum(eachcheck) == 0:
                newboard[n:n+row,c:c+col] += shape
                l.append(newboard)
                n += 1
                newboard = np.array(board)
            else:
                return l
    return l
def animate_clear(board):
    l = []
    newboard = np.array(board)
    r = np.arange(newboard.shape[0])
    rowzero = r[np.sum(newboard==0,axis=1)==0]
    if len(rowzero)==0:
        return l
    newboard[rowzero,:]=0
    l.append(newboard)
    if len(list(r[np.sum(newboard, axis=1)!=0]))==0:
        return l
    first = list(r[np.sum(newboard, axis=1)!=0])[0]
    count = np.sum(np.sum(newboard[first:,:]!=0,axis=1)==0)
    c = 0
    i = newboard.shape[0]-1
    while i!=-1:
        if c == count:
            break
        if np.sum(newboard[i,:])==0:
            new = np.array(newboard)
            new[1:i+1,:] = new[:i,:]
            new[0,:] = 0
            l.append(new)
            newboard = new
            c += 1
        else:
            i -= 1
    return l

xxx213xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 884, 'const': 338, 'code+const': 1222}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('For', 13)]]
import numpy as np
def get_score(board):
    return np.sum(np.sum(board == np.zeros(board.shape[1]),axis=1) == 0)*40
def get_time_cap(board, time_caps):
    ss = np.sum(board.reshape((len(time_caps),board.shape[1]*board.shape[0]//len(time_caps))),axis=1)
    e = np.array(time_caps)[ss != 0]
    if e.shape[0] != 0:
        return e[0]
    else:
        return time_caps[-1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    w = board.shape[0]
    u = []
    for x in range(w):
        i = x + 1
        e = np.zeros_like(board,int)
        qq = x+1 -shape.shape[0]
        ll = shape.shape[0] - i
        if qq <= 0:
            qq = 0
        if ll <= 0:
            ll = 0
        e[qq:x+1,c:c+shape.shape[1]] = shape[ll:shape.shape[0]]
        f = board + e
        if np.sum(f==0) == (np.sum(board==0)-np.sum(shape[ll:shape.shape[0]]!=0)):
            u.append(f)
        else:
            break
    if len(u) < shape.shape[0]:
        u = []
    return u[shape.shape[0]-1:]
def animate_clear(board):
    new_board = np.array(board)
    r,c = board.shape
    x = np.arange(r)[np.sum(board != 0,axis=1) == c]
    new_board[x,:] = np.zeros((1,c),int)
    w = np.arange(board.shape[0])[np.sum(new_board,axis=1) == 0][::-1]
    xxx = w.shape[0]
    a = []
    a.append(new_board)
    newboard1 = np.array(new_board)
    q = 1
    for oo in range(xxx):
        i = w[oo]
        omg = np.array(new_board)
        omg[q:q+i] = newboard1[0:i]
        omg[q-1] = np.zeros((1,c),int)
        if np.sum(a[q-1] == omg) != r*c:
            a.append(omg)
            new_board = omg
            q += 1
        else:
            break
    if np.sum(a[0] == board) == r*c:
        return []
    return a

xxx044xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 754, 'const': 310, 'code+const': 1064}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [], [('any', 15)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 7)], [('While', 6)]]
import numpy as np
def get_score(board):
    a = np.min(board,axis=1)
    b = a != 0
    score = sum(b)*40
    return score
def get_time_cap(board, time_caps):
    c_board = np.array(board)
    a = np.sum(c_board, axis=1)
    b = a == 0
    count = min(sum(b),board.shape[0]-1)
    return time_caps[(int)(count * len(time_caps) / board.shape[0])]
def rotate_right(shape):
    a = shape.T
    b = a[:,::-1]
    return b
def rotate_left(shape):
    a = shape.T
    b = a[::-1,:]
    return b
def animate_drop(board, shape, c):
    n_board = np.array(board)
    n_shape = np.array(shape)
    ls = list()
    posi = 0
    while(True):
      a = np.array(n_board)
      end_r = posi+shape.shape[0]
      end_c = c+shape.shape[1]
      if(end_r == board.shape[0]): return ls
      a[posi:end_r, c:end_c] += n_shape
      posi += 1
      if np.sum(a!=0) == np.sum(board!=0) + np.sum(shape!=0) :
        ls.append(a)
      else :
        return ls
def animate_clear(board):
    ls = list()
    a,b = 0, board.shape[0]-1
    now_board = np.array(board)
    while(True) :
      if(a==b): break
      if(np.sum(np.min(now_board, axis=1)!=0) != 0) :
        now_board[np.min(now_board, axis=1)!=0] = [0]
        ls.append(now_board)
        continue
      c = np.array(now_board)
      c[0:b,:] = [0]
      c[1:b+1,:] = c[1:b+1,:] + now_board[0:b,:]
      if (c != now_board).any() and (np.sum(c==0) == np.sum(now_board==0)) :
        now_board = np.array(c)
        ls.append(c)
        a+=1
      else:
        b-=1
    return ls

xxx026xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 874, 'const': 352, 'code+const': 1226}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 9)], [('For', 17)]]
import numpy as np
def get_score(board):
    hp = np.zeros(board.shape[1])
    hp2 = np.sum(board==hp,axis=1)
    hp3 = list(hp2)
    return 40*(hp3.count(0))
def get_time_cap(board, time_caps):
    cb = board.shape[1] ; rb = board.shape[0]
    n = len(time_caps)
    newboard = board.reshape((n,cb*rb//n))
    zeroboard = np.zeros_like(newboard,int)
    hp = np.sum(newboard!=zeroboard,axis=1)
    hp = hp!=0
    time = np.array(time_caps)
    if len(time[hp]) == 0 : return time_caps[-1]
    return time[hp][0]
def rotate_right(shape):
    shape = shape[::-1]
    return shape.T
def rotate_left(shape):
    shape = shape[:,::-1]
    return shape.T
def animate_drop(board, shape, c):
    if board[0,c] != 0 : return []
    result = []
    rb = board.shape[0]
    rs = shape.shape[0] ; cs = shape.shape[1]
    new_board = np.array(board)
    zeroboard = np.zeros_like(new_board,int)
    for i in range(rb-rs+1) :
        shapeboard = np.array(zeroboard)
        shapeboard[i:i+rs,c:c+cs] = shape
        TFshape = (zeroboard!=shapeboard) + zeroboard
        TFboard = (zeroboard!=new_board) + zeroboard
        hp = np.sum((TFshape + TFboard)>1)
        if hp != 0 : break
        changing = shapeboard + new_board
        result.append(changing)
    return result
def animate_clear(board):
    result = []
    c = board.shape[1] ; r = board.shape[0]
    new_board = np.array(board)
    zeroboard = np.zeros_like(new_board,int)
    hp = np.sum(new_board==zeroboard,axis=1)
    firstcheck = np.zeros_like(hp)
    hp2 = hp==firstcheck 
    if True not in hp2 : return result
    pos = np.arange(r)
    fixpos = pos[hp2]
    new_board[fixpos,:] = np.zeros(c,int)
    result.append(new_board)
    zerocheck = firstcheck==(np.sum(zeroboard!=new_board,axis=1))
    zeropos = pos[zerocheck][::-1]
    for i in range(len(zeropos)) :
        freeboard = np.array(zeroboard)
        freeboard[1:zeropos[0]+1] = new_board[:zeropos[0]]
        freeboard[zeropos[0]+1:] = new_board[zeropos[0]+1:]
        if np.sum(freeboard!=new_board) == 0 : break
        result.append(freeboard)
        zeropos += 1 ; zeropos = zeropos[1:]
        new_board = freeboard
    return result

xxx028xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0ValueError('cannot reshape array of size 24 into shape (2,8)')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (2,3) (3,3) (2,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [0, 0, 0, 0],
       [1, 0, 2, 4]]),
  array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [1, 0, 5, 4],
       [1, 0, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 788, 'const': 418, 'code+const': 1206}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 11)], [('While', 9)]]
import numpy as np
def get_score(board):
    return np.sum(np.min(board!=0,axis=1))*40
def get_time_cap(board, time_caps):
    rs_board = board.reshape(len(time_caps),2*len(board[0]))
    non_empty = np.arange(len(time_caps))[np.max(rs_board,axis=1)!=0]
    if len(non_empty) == 0:
        non_empty = [-1]
    return time_caps[non_empty[0]]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    if np.sum(board[0:shape.shape[0], c:c+shape.shape[1]] != 0):
      return []
    ani = []
    cpy_board = np.array(board)
    board_h, board_w = board.shape
    shape_h, shape_w = shape.shape
    if cpy_board[:shape_h:,c:c+shape_w][shape!=0].sum() > 0:
        return ani
    for r in range(board_h):
        r_butt = r+shape_h
        c_butt = c+shape_w
        cpy_board = np.array(board)
        cpy_board[r:r_butt,c:c_butt] += shape
        if np.max(cpy_board[r:r_butt,c:c+c_butt][shape!=0] != shape[shape!=0]) != 0:
            return ani
        ani.append(np.array(cpy_board))
    return ani
def row_fall(arr):
    cpy_arr = np.array(arr)
    row_indexes = np.arange(cpy_arr.shape[0])
    full_zero = np.min(cpy_arr == 0, axis=1)
    full_zero_idx = row_indexes[full_zero]
    full_zero_idx = full_zero_idx[full_zero_idx != 0]
    t = cpy_arr[full_zero_idx-1] 
    cpy_arr[full_zero_idx-1] = cpy_arr[full_zero_idx]
    cpy_arr[full_zero_idx] = t
    return cpy_arr
def animate_clear(board):
    cpy_board = np.array(board)
    full_row = np.min(cpy_board != 0, axis=1)
    ani = []
    if sum(full_row) != 0:
        cpy_board[full_row,:] = 0
        ani.append(np.array(cpy_board))
        while True:
            cpy_board = row_fall(cpy_board)
            if np.sum(ani[-1] == cpy_board) == cpy_board.shape[0]*cpy_board.shape[1]:
                break
            ani.append(np.array(cpy_board))
    return ani

xxx122xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (1,3)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (2,3) (3,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('zero-size array to reduction operation maximum which has no identity')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 950, 'const': 392, 'code+const': 1342}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [], [('any', 7)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 13)], [('While', 11)]]
import numpy as np
def get_score(board):
    min = np.min(board, axis=1)
    return 40*sum(min != 0)
def get_time_cap(board, time_caps):
    new_board = np.array(board)
    new_board = new_board.reshape((len(time_caps),(new_board.shape[0]//len(time_caps))*new_board.shape[1]))
    a = np.max((new_board != 0),axis=1)
    b = a*time_caps
    b = b[b != 0]
    if len(b) > 0:
      return min(b)
    else:
      return time_caps[-1]
def rotate_right(shape):
    shape.T
    return shape.T[::1,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    animate = []
    x = 0
    y = c
    l = shape.shape[0]
    w = shape.shape[1]
    new_board = np.array(board)
    max_1 = np.max(board[x:x+l,y:y+w])
    max_2 = np.max(shape)
    max_3 = max(max_1,max_2)
    new_board[x:x+l,y:y+w] = board[x:x+l,y:y+w] + shape
    while np.max(new_board[x:x+l,y:y+w]) <= max_3 and x+l <= board.shape[0] :
      animate.append(new_board)
      x += 1
      new_board = np.array(board)
      max_1 = np.max(board[x:x+l,y:y+w])
      max_2 = np.max(shape)
      max_3 = max(max_1,max_2)
      new_board[x:x+l,y:y+w] = board[x:x+l,y:y+w] + shape
    return animate
def animate_clear(board):
    animate = []
    new_board = np.array(board)
    min = np.min(board, axis=1)
    new_board = new_board * np.array(min == 0).reshape(board.shape[0],1)
    if (new_board != board).any():
      animate.append(np.array(new_board))
      swap = False
      i = new_board.shape[0] - 2
      while True:
        if i == - 1:
          if swap:
            animate.append(np.array(new_board))
            i =  new_board.shape[0] - 2
            swap = False
          else:
            break
        if np.max(new_board[i,:]) > 0 and np.max(new_board[i+1,:]) == 0:
          tmp = np.array(new_board[i,:])
          new_board[i,:] = new_board[i+1,:]
          new_board[i+1,:] = tmp
          swap = True
        i -= 1
    return animate

xxx033xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 816, 'const': 228, 'code+const': 1044}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [], [('all', 9)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 9)], [('While', 12)]]
import numpy as np
def get_score(board):
    return ((board != 0).sum(1) == board.shape[1]).sum() * 40
def get_time_cap(board, time_caps):
    rows, cols = board.shape
    lines = np.arange(rows)
    non_zero = ((board != 0).sum(1) != 0)
    index = -1 
    if len(lines[non_zero]) != 0:
      first_non_zero = lines[non_zero][0]
      index = first_non_zero // (rows // len(time_caps))
      return time_caps[index]
    else:
      return time_caps[-1]
def rotate_right(shape):
    new_shape = shape[::-1]
    return new_shape.T
def rotate_left(shape):
    new_shape = shape.T
    return new_shape[::-1]
def animate_drop(board, shape, c):
    result = []
    h, w = shape.shape
    shape_no_zero = shape[shape!=0]
    shape_no_zero_1d = np.reshape(shape_no_zero, (shape != 0).sum())
    non_zero_count = (board != 0).sum() + (shape != 0).sum()
    i = 0
    while True:
      try:
        new_board = np.zeros((board.shape[0]+h - 1, board.shape[1]), int)
        new_board[h-1:,:] = board
        new_board[ i:i+h , c:c+w ][shape != 0] = shape_no_zero_1d
        if (new_board != 0).sum() == non_zero_count:
          result.append(new_board[h-1:,:])
          i+=1
        else:
          break
      except:
        break
    return result[h-1:] if len(result) >= h else []
def animate_clear(board):
    h, w = board.shape
    c_row_index = h -1
    new_board = np.array(board)
    new_board[((new_board !=0).sum(1) == w),:] = 0
    len_zero_row = ((new_board == 0).sum(1) == w).sum()
    res = [np.array(new_board)]
    if (new_board == board).all(): return []
    if new_board[:len_zero_row,:].sum() == 0:
      return res
    while True:
      c_row = new_board[c_row_index]
      if (c_row==0).sum() == w:
        new_board[[c_row_index, c_row_index-1]] = new_board[[c_row_index-1, c_row_index]] 
      c_row_index -= 1
      if c_row_index == 0 :
        res.append(np.array(new_board))
        if new_board[:len_zero_row,:].sum() != 0:
          c_row_index = h -1
        else:
          return res

xxx016xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0IndexError('list index out of range')
[[]]
bytecount: {'code': 746, 'const': 338, 'code+const': 1084}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[('all', 2)], [('all', 2), ('all', 4)], [], [], [], [('all', 5), ('any', 14)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 11)]]
import numpy as np
def get_score(board):
    a=board[(board!=0).all(axis=1)]
    return len(a)*40
def get_time_cap(board, time_caps):
    a=board[(board==0).all(axis=1)]
    n=len(a)
    if not all((board==0).all(axis=1)):
        n+=1
    n/=len(board)//len(time_caps)
    if n-int(n)>0:
        n+=1
    n=int(n)-1
    return time_caps[n]
def rotate_right(shape):
    s=np.array(shape)
    s=s[::-1].T
    return s
def rotate_left(shape):
    s=np.array(shape)
    s=s.T[::-1]
    return s
def animate_drop(board, shape, c):
    ans=[]
    for i in range(len(shape),len(board)+1):
        new_board = np.array(board)
        new_shape = np.array(shape)
        new_board[i-len(shape):i,c:c+shape.shape[1]]+=new_shape
        if all((new_board[i-len(shape):i,c:c+shape.shape[1]][new_shape!=0])==shape.max()):
            ans.append(new_board)
        else:
            break
    return ans
def animate_clear(board):
    ans=[]
    new_board = np.array(board)
    clear=new_board.all(axis=1)
    new_board[clear]=np.zeros(new_board.shape[1])
    if len(clear[clear==True])>0:
        ans.append(np.array(new_board))
    i = board.shape[0]-1
    j = 0
    while True:
        if i==-1 or j>new_board.shape[0]:
            break
        if not new_board[i].any():
            j=j+1
            new_board[1:i+1]=new_board[:i]
            new_board[0]=np.zeros(new_board.shape[1])
            l=new_board.shape[0]*new_board.shape[1]
            if not all(ans[-1].reshape((l))==new_board.reshape((l))):
                ans.append(np.array(new_board))
        else:
            j=0
            i=i-1
    return ans

xxx033xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 778, 'const': 384, 'code+const': 1162}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 8)], []]
import numpy as np
def get_score(board):
    haszero = np.min(board,axis=1)
    nozeroboard = board[haszero>0]
    return nozeroboard.shape[0]*40
def get_time_cap(board, time_caps):
    minzero = np.min(board,axis=1)
    maxzero = np.max(board,axis=1)
    n = board.shape[0]
    N = np.arange(n)
    N = N[(maxzero != 0) | (minzero != 0)]
    if(N.shape[0] > 0):
        m = N[0]//(n//len(time_caps))
    else:
        m = -1
    return time_caps[m]
def rotate_right(shape):
    newshape = shape.T
    m,n = newshape.shape[0],newshape.shape[1]
    newshape = newshape.reshape(m*n)
    id = np.arange(m*n)
    id = id+n-2*(id-n*(id//n))-1
    newshape = newshape[id]
    newshape = newshape.reshape((m,n))
    return newshape
def rotate_left(shape):
    newshape = shape.T
    m,n = newshape.shape[0],newshape.shape[1]
    newshape = newshape.reshape(m*n)
    id = np.arange(m*n)
    id = id + n*(m-1-2*(id//n))
    newshape = newshape[id]
    newshape = newshape.reshape((m,n))
    return newshape
def iszero(board):
    minzero = np.min(board,axis=1)
    maxzero = np.max(board,axis=1)
    n = board.shape[0]
    N = np.arange(n)
    N = N[(maxzero != 0) | (minzero != 0)] 
    return (N.shape[0] == 0)
def animate_drop(board, shape, c):
    if(c> board.shape[1]-shape.shape[1]):
        return []
    else:
        result = []
        start = 0
        while start+shape.shape[0] -1 < board.shape[0]:
            newboard = np.array(board)
            partial = board[start:start+shape.shape[0],c:c+shape.shape[1]]
            check = partial*shape
            if np.sum(check) == 0:
                newboard[start:start+shape.shape[0],c:c+shape.shape[1]] += shape
                result.append(newboard)
                start = start+1
            else:
                break
        return result
def animate_clear(board):
    pass

xxx214xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 668, 'const': 352, 'code+const': 1020}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 5)], [('While', 8)]]
import numpy as np
def get_score(board):
    return sum((np.sum((board==0),axis=1)==0)*40)
def get_time_cap(board, time_caps):
    found = list(np.sum(np.sum(board.reshape(len(time_caps),-1,board.shape[1]),axis=1),axis=1) > 0)
    if True in found:
        idx = found.index(True)
    else:
        idx = -1
    return time_caps[idx]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    animations = []
    i=0
    while True:
        board_copy = np.array(board)
        if i+shape.shape[0] > board.shape[0]:
            break
        board_copy[i:i+shape.shape[0],c:c+shape.shape[1]] += shape
        if np.sum(board_copy[i:i+shape.shape[0],c:c+shape.shape[1]][shape!=0] != shape[shape!=0]) > 0:
            break
        animations.append(np.array(board_copy))
        i+=1
    return animations
def animate_clear(board):
    board_copy = np.array(board)
    if not np.max(np.min(board_copy, axis=1) != 0):
        return []
    board_copy[np.min(board_copy, axis=1) != 0] = 0
    animations = []
    animations += [board_copy]
    while True:
        board_copy = np.array(board_copy)
        b = np.sum(board_copy[::-1], axis=1)
        min_v = np.min(b)
        min_idx = list(b).index(min_v)
        swap = board_copy.shape[0]-min_idx
        board_copy[1:swap] = board_copy[:swap-1]
        board_copy[0] = np.zeros(board.shape[1])
        if not np.max(board_copy != animations[-1]):
            return animations
        animations.append(board_copy)

xxx244xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('operands could not be broadcast together with shapes (4,) (3,) (4,) ')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (6,) (3,) (6,) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('operands could not be broadcast together with shapes (3,) (2,) (3,) ')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 636, 'const': 338, 'code+const': 974}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('For', 13)]]
import numpy as np
def get_score(board):
    r = np.sum(board == 0, axis=1)
    zeros_rows = (r == 0).sum()
    return zeros_rows*40
def get_time_cap(board, time_caps):
    n_rows = len(board)//len(time_caps)
    X = board.reshape(len(time_caps),board.shape[1]*n_rows)
    r = np.sum(X , axis=1)
    non_zeros = r != 0
    return np.array(time_caps)[non_zeros][0] if True in non_zeros else time_caps[-1]
def rotate_right(shape):
    return np.array((list(zip(*shape))))[:,::-1]
def rotate_left(shape):
    return np.array(list(reversed(list(zip(*shape)))))
def animate_drop(board, shape, c):
    drop = []
    new_board = np.array(board)
    for i in range(len(new_board)):
      if new_board[i][c] == 0:
        new_board[i][c:] += shape[0]
        drop.append(new_board)
      new_board = np.array(board)
    return drop
def animate_clear(board):
    clear = []
    new_board = np.array(board)
    zeroes_row = np.zeros((1,board.shape[1]),int)
    non_zeros = (np.min(board,axis=1) != 0)
    if True in non_zeros:
      new_board[non_zeros] = zeroes_row
      clear.append(new_board)
      sum_z = (np.sum(new_board,axis=1) == 0)
      ind = np.arange(len(sum_z))
      z = ind[sum_z == True]
      for i in range(len(z)):
        new_board = np.array(new_board)
        sum_z = (np.sum(new_board,axis=1) == 0)
        ind = np.arange(len(sum_z))
        s = ind[sum_z == True][-1]
        new_board[1:s+1] = new_board[:s]
        new_board[0] = zeroes_row
        clear.append(new_board)
    return clear

xxx200xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1146, 'const': 352, 'code+const': 1498}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 12)], [('While', 18)]]
import numpy as np
def get_score(board):
    b=board!=0
    n=np.sum(b,axis=1)
    col=board.shape[1]
    x=np.sum(n==col)
    return x*40
def get_time_cap(board, time_caps):
    b=board!=0
    index=np.arange(board.shape[0])
    n=np.sum(b,axis=1)
    nn=n>0
    if np.sum(nn)==0: return time_caps[-1]
    i=index[nn][0]
    return time_caps[i//((board.shape[0]//len(time_caps)))]
def rotate_right(shape):
    s=shape.T
    return s[:,-1::-1]
def rotate_left(shape):
    s=shape.T
    return s[-1::-1,:]
def animate_drop(board, shape, c):
    r=0
    r1=1
    r2=-1
    animatedrop=[]
    b=board[r:r1,c:c+shape.shape[1]]
    s=shape[r2::,:]>0
    checkboard=b[s]==0
    put=np.sum(checkboard)==np.sum(s)
    r1+=1
    r2-=1
    while put:
        if r1<shape.shape[0]:
            b=board[r:r1,c:c+shape.shape[1]]
            s=shape[r2::,:]>0
            checkboard=b[s]==0
            r1+=1
            r2-=1
            put=np.sum(checkboard)==np.sum(s)
        elif r1==shape.shape[0]:
            b=board[r:r1,c:c+shape.shape[1]]
            s=shape>0
            checkboard=b[s]==0
            put=np.sum(checkboard)==np.sum(s)
            r1+=1
            r2-=1
        else:
            newboard=np.array(board)
            newboard[r:r+shape.shape[0],c:c+shape.shape[1]]+=shape
            animatedrop.append(newboard)
            r+=1
            if board.shape[0]-shape.shape[0]<r : break
            b=board[r:r+shape.shape[0],c:c+shape.shape[1]]
            s=shape>0
            checkboard=b[s]==0
            put=np.sum(checkboard)==np.sum(s)
    return animatedrop
def animate_clear(board):
    clear=[]
    b=board!=0
    index=np.arange(board.shape[0])
    n=np.sum(b,axis=1)
    nn=n==board.shape[1]
    if np.sum(nn)==0:
        return []
    i=index[nn]
    newboard=np.array(board)
    newboard[i,:]=0
    clear.append(newboard)
    b=newboard!=0
    n=np.sum(b,axis=1)
    n0=n==0
    i0=index[n0]
    while np.sum(newboard[:i0[-1],:])!=0:
        new=np.array(newboard)
        new[1:i0[-1]+1]=newboard[:i0[-1]]
        new[0,:]=0
        clear.append(new)
        newboard=new
        b=newboard!=0
        n=np.sum(b,axis=1)
        n0=n==0
        i0=index[n0]
    return clear

xxx044xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0Time-out: 5s
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 932, 'const': 384, 'code+const': 1316}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 17)]]
import numpy as np
def get_score(board):
  b1 = np.min(board, axis=1)
  b1 = b1[b1>0]
  pts = len(b1)*40
  return pts
def get_time_cap(board, time_caps):
  if np.max(board)>0:
    b1 = board
    b22 = np.max(b1, axis=1)
    b4 = b22!=0
    b4 = list(b4)
    if True in b4:
      a = b4.index(True)
      b = time_caps[a//(len(board)//len(time_caps))]
      return b
    else:
      return time_caps[-1]
  else:
    return time_caps[-1]
def rotate_right(shape):
  return shape[::-1].T
def rotate_left(shape):
  return shape[:,::-1].T
def animate_drop(board, shape, c):
  new_board = np.array(board)
  new_shape = np.array(shape)
  s = []
  j = 1
  for i in range(len(new_board)):
    if j<len(new_shape):
      b1 = np.array(new_board)
      a = b1[0:0+j,c:c+len(new_shape[-1])]
      b = new_shape[len(new_shape)-j:]
      cc = a, b
      d = np.max(cc, axis=0)
      e = a+b
      if np.sum(d)==np.sum(e):
        j+=1
      else:
        break
    else:
      b1 = np.array(new_board)
      a = b1[i-j+1:i-j+1+len(new_shape),c:c+len(new_shape[-1])]
      b = new_shape
      cc = a, b
      d = np.max(cc, axis=0)
      e = a+b
      if np.sum(d)==np.sum(e):
        b1[i-j+1:i-j+1+len(shape),c:c+len(new_shape[-1])] = e
        b2 = np.array(b1)
        s.append(b2)
      else: break
  return s
def animate_clear(board):
  b1 = np.array(board)
  b2 = np.min(b1, axis=1)
  b2check = np.arange(len(b2))
  b2final = b2check[b2!=0]
  s = []
  if len(b2final)==0:
    return s
  else:
    b1[b2final] = 0
    b3 = b1[np.max(b1, axis=1)!=0]
    i = 0
    lb = len(b1)-1
    b4 = np.array(b1)
    s.append(b4)
    while True:
      if np.max(b1[lb-i])==0:
        b1[1:lb-i+1] = b1[0:lb-i]
        b1[0] = 0
        b4 = np.array(b1)
        s.append(b4)
      else:
        i+=1
        if i==len(b3): break
    return s

xxx035xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0Time-out: 5s
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 620, 'const': 242, 'code+const': 862}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 4)], [('While', 9)]]
import numpy as np
def get_score(board):
    z=board.min(1)
    return sum(z!=0)*40
def get_time_cap(board, time_caps):
    if board.max()!=0:
        n=board.shape[0]//len(time_caps)
        i=(board.max(1)!=0).argmax()//n
        return time_caps[i]
    else:
        return time_caps[-1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    i=0
    L=[]
    while i+shape.shape[0]<=board.shape[0] and (board[i:i+shape.shape[0],c:c+shape.shape[1]]*shape).max()==0:
        Board = np.array(board)
        Board[i:i+shape.shape[0],c:c+shape.shape[1]]+=shape
        L.append(np.array(Board))
        i+=1
    return L
def animate_clear(board):
    L=[]
    if sum(board.min(1)!=0)!=0:
        Board = np.array(board)
        Board[board.min(1)!=0]=0
        L.append(np.array(Board))
        n=sum(Board.max(1)==0)
        i=board.shape[0]-1
        while i>-1:
            if Board[i].max()==0:
                Board[1:i+1]=Board[:i]
                Board[0]=0
                L.append(np.array(Board))
            elif sum(Board.max(1)[:n]!=[0])==0:break
            else:
                i-=1
    return L

xxx210xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 852, 'const': 338, 'code+const': 1190}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 12)]]
import numpy as np
def get_score(board):
  fc = np.sum(board[:,:] != 0,axis = 1)
  return np.sum(fc[fc == board.shape[1]] == board.shape[1])*40
def get_time_cap(board, time_caps):
  if np.max(board) == 0:
    return time_caps[-1]
  else:
    r = board.shape[0]
    return time_caps[np.min(np.arange(r)[np.sum(board, axis = 1) != 0])//(r//len(time_caps))]
def rotate_right(shape):
  return shape[::-1,:].T
def rotate_left(shape):
  return shape[:,::-1].T
def animate_drop(board, shape, c):
  ans = []
  new_board = np.array(board)
  for n in range(board.shape[0]-shape.shape[0]+1):
    if np.sum(board[np.arange(shape.shape[0]) + n, c:c+shape.shape[1]]*shape) == 0 and np.sum(board[:shape.shape[0]-1,c:c+shape.shape[1]]*shape[1-shape.shape[0]:]) == 0:
      new_board[np.arange(shape.shape[0]) + n, c:c+shape.shape[1]] += shape
      ans.append(new_board)
      new_board = np.array(board)
    else:break
  return ans
def animate_clear(board):
  c = 0
  sss = []
  e = board.shape[0]
  dd = np.min(board, axis = 1)
  if np.max(dd) == 0:
    return sss
  new_board = np.array(board)
  new_board[np.arange(e)[dd > 0]] *= 0
  sss.append(new_board)
  bbc = np.array(new_board)
  while c <= e and np.sum(bbc[np.arange(np.arange(e)[np.max(bbc, axis = 1) == 0][-1])]) != 0:
    bbc[np.arange(np.arange(e)[np.max(bbc, axis = 1) == 0][-1])+1] = bbc[np.arange(np.arange(e)[np.max(bbc, axis = 1) == 0][-1])]
    bbc[0] *= 0
    yet = np.array(bbc)
    sss.append(yet)
    c += 1
  return sss

xxx043xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 01, 01]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 01, 5, 5, 0, 0, 0],
       [0, 2, 02, 02, 5, 02, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (2,3) (3,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 562, 'const': 352, 'code+const': 914}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], []]
import numpy as np
def get_score(board):
    check = np.sum((board == 0),axis = 1)
    return len(check[check==0]) * 40
def get_time_cap(board, time_caps):
    check = np.sum((board == 0), axis = 1)
    row_index = np.arange(board.shape[0])
    check_all_zero = (check != board.shape[1])
    non_all_zero_row = row_index[check_all_zero == True]
    if len(non_all_zero_row) == 0:
      return time_caps[-1]
    else:
      index = non_all_zero_row[0] // 2
    return time_caps[index]
def rotate_right(shape):
    new_shape = shape.T
    return new_shape[:,::-1]
def rotate_left(shape):
    new_shape = shape.T
    return new_shape[::-1,:]
def animate_drop(board, shape, c):
    out = []
    for i in range(board.shape[0]):
      new_board = np.array(board)
      new_shape = np.array(shape)
      area = new_board[i:i + shape.shape[0], c:c+shape.shape[1]]
      if np.sum((area == 0) | ((area!=0) & (new_shape==0))) == (shape.shape[0] * shape.shape[1]):
        new_board[i:i+shape.shape[0],c:c+shape.shape[1]] = new_shape
        out.append(new_board)
      else: break
    return out
def animate_clear(board):
    out = []
    new_board = np.array(board)
    row_index = np.arange(board.shape[0])
    non_zero = row_index[board.min(axis=1) != 0]
    if len(non_zero) == 0:
      return out
    else:
      new_board[non_zero,:] = 0
      out.append(new_board)
    return out

xxx020xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 628, 'const': 352, 'code+const': 980}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 5)], [('For', 11)]]
import numpy as np
def get_score(board):
  return sum(np.sum(board!=0,axis = 1)==board.shape[1])*40
def get_time_cap(board, time_caps):
  a = np.sum(board,axis=1) != 0 
  if True in a: 
   return time_caps[int(list(a).index(True)/(board.shape[0]//len(time_caps)))]
  else:
    return time_caps[-1]
def rotate_right(shape):
  return shape.T[:,::-1]
def rotate_left(shape):
  return shape.T[::-1,:]
def animate_drop(board, shape, c):
  a = []
  i = 0
  d,f=shape.shape
  while i + d <= board.shape[0] and np.sum(board[i:i+d,c:c+f][shape!=0]) == 0:
    nb = np.array(board)
    nb[i:i+d,c:c+f] += shape
    a.append(nb)
    i+=1
  return a
def animate_clear(board):
  v = []
  nb = np.array(board)
  pos = np.arange(board.shape[0])
  c = pos[np.sum(board != 0,axis = 1)==board.shape[1]]
  nb[c]=0
  if c.shape[0] == 0:
    return []
  v.append(nb)
  a = 0
  for i in pos[np.sum(nb,axis=1)==0][::-1]:
    if np.sum(nb[:i+a]) != 0:
      nbb = np.zeros_like(nb)
      nbb[1:] = nb[pos[pos!=(i+a)]]
      nb = nbb
      v.append(nb)
      a+=1
  return v

xxx022xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 912, 'const': 338, 'code+const': 1250}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 8)], [('While', 13)]]
import numpy as np
def get_score(board):
    ro = np.min(board, axis=1)
    return sum(ro>0)*40
def get_time_cap(board, time_caps):
    rowcn = board.shape[0]
    cn = rowcn*board.shape[1]
    newrow = len(time_caps)
    newcol = cn//newrow
    newboard = board.reshape((newrow,newcol))
    cp = np.sum(newboard, axis=1)
    tcap = np.array(time_caps)
    tcs = tcap[cp>0]
    if len(tcs)==0:
        return tcap[-1]
    else:
        return tcs[0]
def rotate_right(shape):
    shet = shape.T
    return (shet[::, ::-1])
def rotate_left(shape):
    shet = shape.T
    return (shet[::-1, ::])
def animate_drop(board, shape, c):
    new_shape = np.array(shape)
    new_board = np.array(board)
    ro = new_shape.shape[0]
    co = new_shape.shape[1]
    plist = []
    r = 0
    while True:
        if r>(new_board.shape[0]-ro):
            break
        resv = new_board[r:(r+ro):, c:(c+co):]
        lns = ro*co
        nsha = np.array(new_shape)
        coms = nsha.reshape(lns) 
        rems = resv.reshape(lns) 
        pos = np.arange(lns)
        tilepos = pos[coms!=0]
        checkval = rems[tilepos]
        if np.sum(checkval)==0:
            rems[tilepos]=coms[tilepos]
            remss = rems.reshape((ro,co))
            new_board[r:(r+ro):, c:(c+co):]=remss
            plist.append(new_board)
            new_board = np.array(board)
            r+=1
        else:
            break
    return plist
def animate_clear(board):
    new_board = np.array(board)
    blist = []
    mi = np.min(new_board, axis=1)
    od = np.arange(new_board.shape[0])
    oli = od[mi>0]
    if len(oli)==0:
        return[]
    sboard = np.array(board)
    sboard[oli, ::] = 0
    blist.append(sboard)
    stb = np.array(sboard)
    while True:
        flipb = stb[::-1,::]
        broww = np.sum(flipb, axis=1)
        odo = np.arange(len(broww))
        zr = odo[broww==0]
        if len(zr)==0:
            break
        fzr = zr[0]
        ifz = (np.array(flipb))[fzr::,::]
        if np.sum(ifz)==0:
            break
        freeb = np.array(flipb)
        freeb[fzr:-1:, ::]=flipb[(fzr+1)::, ::]
        freeb[-1,::]=0
        stb=freeb[::-1,::]
        blist.append(stb)           
    return blist

xxx020xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0IndexError('index 2 is out of bounds for axis 0 with size 2')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0IndexError('index 5 is out of bounds for axis 0 with size 5')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0IndexError('index 2 is out of bounds for axis 0 with size 2')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 972, 'const': 338, 'code+const': 1310}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 23)], [('For', 22)]]
import numpy as np
def get_score(board):
    s = np.sum(board!=0,axis = 1)
    return np.sum(s==board.shape[1]) * 40
def get_time_cap(board, time_caps):
    r,c = board.shape
    cboard = board.reshape((len(time_caps), r*c//len(time_caps)))
    check = np.sum(cboard!=0, axis=1)
    t = np.array(time_caps)[check!=0]
    if len(t)!=0:
        return t[0]
    else:
        return time_caps[-1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    cboard = np.array(board)
    cshape = np.array(shape)
    rb,cb = cboard.shape
    rs,cs = cshape.shape
    pc = np.arange(np.abs(cb - cs)+1)
    if c in pc:
        ir = np.ndarray((cs,rs),int)
        ir[:] = np.arange(0,rs)
        ir = ir.T
        ic = np.ndarray((rs,cs),int)
        ic[:] = np.arange(0,cs)
        ir = ir[shape != 0] 
        ic = ic[shape != 0] 
        v = shape[shape!=0][0]
        check = np.array([0]*np.sum(shape!=0))
        ic = ic + c
        if np.sum(cboard[ir,ic] != check) != 0: return []
        ans = []
        while np.sum(cboard[ir,ic] != check) == 0:
            cboard[ir,ic] = v
            ans.append(cboard)
            cboard = np.array(board)
            ir = ir +1
        return ans
    else:
        return []
def animate_clear(board):
    cboard = np.array(board)
    r,c = cboard.shape
    s = np.sum(cboard!=0,axis = 1)
    check_r = np.arange(r)
    d = check_r[s==c]
    if len(d) == 0: return []
    cboard[d] = 0
    ans = []
    ans.append(cboard)
    cboard = np.array(cboard)
    z = np.sum(cboard != 0,axis = 1)
    z = check_r[z==0]
    z = z[::-1]
    v = np.sum(cboard!=0,axis = 1)
    v = check_r[v!=0][0] 
    z = z[z>v]
    for i in range(len(z)):
        e = z[0]
        qboard = np.array(cboard)
        cboard[1:e+1] = qboard[0:e]
        cboard[0] = 0
        ans.append(cboard)
        cboard = np.array(cboard)
        z = np.sum(cboard != 0,axis = 1)
        check_z = np.arange(r)
        z = check_z[z==0]
        z = z[::-1]
    return ans

xxx207xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 1630, 'const': 338, 'code+const': 1968}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 9)], [('For', 15)]]
import numpy as np
def get_score(board):
    a = np.min(board, axis=1)
    check0 = a[a != 0]
    return int(np.sum(check0/check0)*40)
def get_time_cap(board, time_caps):
    b_max = np.max(board, axis=1)
    b_col = board.shape[0]
    c = (b_max != 0)[0::int(b_col/len(time_caps))] | (b_max != 0)[int(b_col/len(time_caps)-1)::int(b_col/len(time_caps))]
    check = np.arange(len(time_caps))
    if check[c].shape[0] == 0 :
        return time_caps[-1]
    else :
        return time_caps[np.min(check[c], axis=0)]
def rotate_right(shape):
    ans = shape.T[::,::-1]
    return ans
def rotate_left(shape):
    ans = shape.T[::-1,::]
    return ans
def animate_drop(board, shape, c):
    new_board1 = np.array(board)
    new_shape = np.array(shape)
    ans = []
    if board[board.T[c] == 0].shape[0] == 0 :
        return []
    else :
        for i in range(new_board1.T[c::].T.shape[0]) :
            new_board2 = np.array(board)
            new_board2.T[c::].T[:,:] = board.T[c::].T
            if new_board2.T[c:c+shape.shape[1]:].T[i][new_board2.T[c:c+shape.shape[1]:].T[i] == 0].shape[0] == shape[0].shape[0] :
                if new_board2.T[c:c+shape.shape[1]:].T[i:i+(shape.shape[0])].shape[0] == shape.shape[0] :
                    z = new_board2.T[c:c+shape.shape[1]:].T[i:i+(shape.shape[0])]
                    if np.sum(z) == np.sum((z+shape)[(z+shape) != shape]):
                        z[:,:] += shape
                        ans.append(new_board2)
            else : break
        return ans
def animate_clear(board):
    ans = []
    new_board = np.array(board)
    nb_min = np.min(new_board, axis=1)
    c = np.arange(new_board.shape[0])
    new_board[c[nb_min != 0]] = 0
    nb_max = np.max(new_board, axis=1)
    if nb_max[nb_max == 0].shape[0] > 0 :
        ans.append(new_board)
        if c[nb_max == 0].shape[0] == 1 and c[nb_max == 0] == c[0] :
            pass
        else :
            check2 = np.array(new_board)
            for i in range(new_board.shape[0]) :
                c_max = np.max(check2, axis=1)
                n = c[c_max != 0][c[c_max != 0] != check2.shape[0]-1]
                if n.shape[0] == 0 :
                    break
                n_z = n[n!=n[0]]
                if check2[n_z-1][check2[n_z-1] != 0].shape[0]==0:
                    n = n[np.max(check2[n+1], axis=1) == 0]
                    if n.shape[0] == 0 :
                        break
                    if check2[n+1][check2[n+1] != 0].shape[0] == 0 :
                        check2[n+1] = check2[n]
                        check2[n] = 0
                        n += 1
                        r = np.array(check2)
                        ans.append(r)
                else :
                    if check2[n[-1]+1][check2[n[-1]+1] !=0].shape[0] == 0 :
                        n_z = n[n!=n[0]]
                        if check2[n_z-1][np.max(check2[n_z-1], axis=1) == 0].shape[0]==1:
                            check2[n+1] = check2[n]
                            check2[n[0]] = 0
                            check2[n_z[n_z[check2[n_z-1][np.max(check2[n_z-1], axis=1) == 0].shape[0]]-1]+1] = check2[n_z[n_z[check2[n_z-1][np.max(check2[n_z-1], axis=1) == 0].shape[0]]-1]]
                            check2[n_z[n_z[check2[n_z-1][np.max(check2[n_z-1], axis=1) == 0].shape[0]]-1]] = 0
                            r = np.array(check2)
                            ans.append(r)
                        else :
                            check2[n+1] = check2[n]
                            check2[n[0]] = 0
                            r = np.array(check2)
                            ans.append(r)    
    return ans
    return ans

xxx205xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([3[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 30, 30, 0],
       [0, 0, 0, 0]]),
  array([3[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 30, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 32, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 30],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[array([0, 0, 0, 0])]
bytecount: {'code': 532, 'const': 324, 'code+const': 856}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], []]
import numpy as np
def get_score(board):
    pos = np.min(board,axis = 1)
    position = pos[pos != 0]
    return len(position)*40
def get_time_cap(board, time_caps): 
    summ = np.sum(board, axis = 1)
    if np.sum(summ) == 0:
      return time_caps[-1]
    zero = np.sum(board, axis = 1)
    div = board.shape[0]//len(time_caps)
    pos = np.arange(board.shape[0])
    first = pos[zero != 0][0]
    return time_caps[first//div]
def rotate_right(shape):
    return np.array(shape.T[::,::-1])
def rotate_left(shape):
    return np.array(shape.T[::-1,::])
def animate_drop(board, shape, c):
    wide,le = shape.shape
    zero = np.sum(board != 0) + np.sum(shape != 0)
    l = []
    for i in range(len(board) - wide + 1):
      new_board = np.array(board)
      new_board[i:i+wide, c:c+le] += shape
      if np.sum(new_board != 0) != zero:
        break
      l.append(new_board)
    return l
def animate_clear(board):
    new_board = np.array(board)
    find = np.min(new_board,axis = 1)
    k = find != 0
    new_board[k,::] = 0
    nzero = np.sum(new_board != 0 , axis = 1)
    pos = np.arange(new_board.shape[0])   
    return nzero

xxx028xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 778, 'const': 370, 'code+const': 1148}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('For', 11)]]
import numpy as np
def get_score(board):
    score = int(sum(np.min(board,axis=1)!=0)) * 40
    return score
def get_time_cap(board, time_caps):
    if np.sum(board) == 0:
        return time_caps[-1]
    interval = board.shape[0]//len(time_caps)
    fst = np.arange(board.shape[0])[np.sum(board,axis=1) != 0][0]
    capsth = fst//interval
    return time_caps[capsth]
def rotate_right(shape):
    rotated = shape.T[:,-1::-1]
    return rotated
def rotate_left(shape):
    rotated = shape.T[-1::-1,:]
    return rotated
def animate_drop(board, shape, c):
    drop_list = []
    srow = shape.shape[0]
    scol = shape.shape[1]
    new_board = np.array(board)
    new_shape = np.array(shape)
    for i in range(board.shape[0]-(srow-1)):
        new_board = np.array(board)
        new_shape = np.array(shape)
        if np.sum(np.max((new_board[i:i+srow,c:c+scol]!=0) & (new_shape!=0),axis=1)) == 0:
            new_board[i:i+srow,c:c+scol] += new_shape
            drop_list.append(new_board)
        else:
            break
    return drop_list
def animate_clear(board):
    new_board = np.array(board)
    clear_board = []
    if len(new_board[np.min(new_board,axis=1) != 0]) != 0:
        new_board[np.min(new_board,axis=1) != 0] = np.zeros((1,new_board.shape[1]),int)
        clear_board.append(new_board)
        th = np.arange(new_board.shape[0])
        sq = th[np.sum(new_board,axis=1)==0]
        c = 0
        for i in sq[-1::-1]:
            new_board = np.array(new_board)
            i += c
            if np.sum(new_board[:i,:]) == 0:
                break
            new_board[1:i+1,:] = new_board[:i,:]
            new_board[0,:] = np.zeros((1,new_board.shape[1]),int)
            clear_board.append(new_board)
            c += 1
    return clear_board

xxx150xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError("non-broadcastable output operand with shape (1,3) doesn't match the broadcast shape (2,3)")
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 14, 4, 14]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (2,3) (3,3) (2,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[ 0,  0,  0,  02,  02,  02],
       [ 0,  20,  20,  20,  0,  02],
       [ 0,  0,  0,  20,  8,  02],
       [ 1,  1,  0, 108,  8,  0],
       [ 1,  1,  0,  0,  8,  0]]),
  array([[ 0,  0,  0,  0,  0,  0],
       [ 0,  0,  0,  02,  02,  02],
       [ 0,  20,  20,  20,  8,  02],
       [ 1,  1,  0, 108,  8,  02],
       [ 1,  1,  0,  20,  8,  0]])]]
test_animate_drop_30.0ValueError('operands could not be broadcast together with shapes (3,2) (4,2) (3,2) ')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]]),
  array([[0, 0, 0, 0],
       [1, 1, 0, 0],
       [1, 2, 2, 0],
       [1, 1, 2, 1],
       [1, 3, 3, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 458, 'const': 266, 'code+const': 724}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], []]
import numpy as np
def get_score(board):
    k = np.sum(board[:,]!= 0,axis = 1) 
    return len(k[k ==board.shape[1]])*40
def get_time_cap(board, time_caps):
    step =int(board.shape[0]/len(time_caps))
    k =  np.arange(0,board.shape[0],1)
    j = np.sum(board,axis =1)
    if len(k[j!=0]) > 0:
        return time_caps[(len(k)-len(k[j!=0]))//step]
    else:return time_caps[-1]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    k = np.array(board);h=[]
    for i in range(len(k)):
        if k[i][c] == 0:
            k[i:i+shape.shape[0],c:c+shape.shape[1]] += shape
            m = np.array(k)
            h.append(m)
            k[i:i+shape.shape[0],c:c+shape.shape[1]] -= shape
    return h
def animate_clear(board):
    h = []
    return h

xxx034xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 916, 'const': 338, 'code+const': 1254}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 13)], [('While', 18)]]
import numpy as np
def get_score(board):
  x = np.min(board,axis = 1) != 0
  y = board[x]
  return(y.shape[0]*40)
  pass
def get_time_cap(board, time_caps):
  n = len(time_caps)
  m1 = board.shape[0]
  m2 = board.shape[1]
  x = board.reshape(n,m1*m2//n)
  y = x[np.sum(x,axis = 1) != 0]
  if len(y) > 0:
    z = x == y[0]
    k = np.argmax(np.sum(z,axis =1))
    return(time_caps[k])
  else:
    return(time_caps[-1])   
  pass
def rotate_right(shape):
  new_shape = np.array(shape)
  return(new_shape.T[:,::-1])
  pass
def rotate_left(shape):
  new_shape = np.array(shape)
  return(new_shape.T[::-1]) 
  pass
def animate_drop(board, shape, c):
  import numpy as np
  ans = []
  sum_board = np.sum(board)
  sum_shape = np.sum(shape)
  a = board != 0
  b = shape != 0
  a1 = np.sum(a)
  b1 = np.sum(b)
  h = shape.shape[0]
  w = shape.shape[1]
  for i in range(board.shape[0]+1-h):
    new_board = np.array(board)
    new_board[i:i+h, c:c+w] += shape
    sum_newboard = np.sum(new_board)
    new_z = new_board != 0
    sum_newz = np.sum(new_z)
    if sum_newboard == sum_board + sum_shape and a1 + b1 == sum_newz :
      ans.append(new_board)
    else:
      break
  return(ans)       
  pass
def animate_clear(board):
    new_board = np.array(board)
    ans = []
    x = np.min(board,axis = 1)
    y = x == 0
    y = y.reshape(len(y),1)
    z = np.sum(y,axis = 1)
    t = z == 0
    zero = np.zeros(board.shape[1])
    new_board[t] = zero
    n = board.shape[0]
    new1 = np.array(new_board)
    T_F = np.sum(new_board,axis =1) == 0 
    line_z = np.sum(T_F)
    line_n = new_board.shape[0] - line_z
    ans.append(new1)
    while True:
      T_F = np.sum(new_board,axis =1) == 0 
      if line_z != 0:
        ind = np.arange(board.shape[0])
        ind_z = ind[T_F]
        if ind_z[-1] != board.shape[0]: 
          new_board[1:ind_z[-1]+1] = new_board[0:ind_z[-1]]
          new_board[0] = zero
          new2 = np.array(new_board)
          ans.append(new2)
      else:
        return[]
      L = new_board[-line_n:]
      sum_L = np.sum(np.sum(L,axis =1) != 0)
      if line_n == sum_L:
        break
    return(ans)       
    pass

xxx120xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0KeyError(3)
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 928, 'const': 366, 'code+const': 1294}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 15)], [('While', 13)]]
import numpy as np
def get_score(board):
    full_row = board[board.min(axis = 1) != 0]
    score = full_row.shape[0] * 40
    return score
def get_time_cap(board, time_caps):
    if board.sum() == 0:
      return time_caps[-1]
    pos = np.arange(board.shape[0])
    min = pos[board.max(axis = 1) != 0][0]
    range_rows = int(board.shape[0] / len(time_caps))
    time_pos = int(min / range_rows)
    time = time_caps[time_pos]
    return time
def rotate_right(shape):
    return shape.T[:, ::-1]
def rotate_left(shape):
    return shape.T[::-1, :]
def animate_drop(board, shape, c):
    new_shape = np.array(shape)
    height, width = new_shape.shape 
    sum_shape = new_shape.sum()
    row = board.shape[0]
    max_row = shape.shape[0]
    max_col = shape.shape[1]
    list_ans = []
    row1 = 0
    column = 0
    list_pos = {}
    step = 1
    i = 0
    while True:
      if step == 1:
        if column == max_col:
          step = 2
          column = 0
        if step == 1:
          if shape[row1, column] != 0:
            list_pos[column] = row1
          row1 += 1
          if row1 == max_row:
            row1 = 0
            column += 1
      elif step == 2:
        if column != max_col:
          row_ck = list_pos[column]
          if board[: row_ck + 1, c + column].max() != 0 :
            break
          column += 1
        else:
          step = 3
      elif step == 3:
        if i == row - height + 1:
          break
        new_board = np.array(board)
        space = new_board[i: i + height, c: c + width]
        if (space * new_shape).sum() == 0:
          new_board[i: i + height, c: c + width] += new_shape
          list_ans.append(new_board)
        else:
          break
        i += 1
    return list_ans
def animate_clear(board):
    pos = np.arange(board.shape[0])
    full_row = pos[board.min(axis = 1) != 0]
    new_board = np.array(board)
    new_board[full_row] = 0
    empty_row = pos[new_board.max(axis = 1) == 0].shape[0]
    max_row_check = new_board.shape[0] - 1
    list_ans = []
    if empty_row != 0:
      list_ans.append(new_board.copy())
      i = 0
      while True:
        if new_board[:empty_row].max() == 0:
          break
        drop_row =pos[new_board.max(axis = 1) == 0][-1]
        temp = new_board[i + 1: drop_row + 1].copy()
        new_board[i + 1: drop_row + 1] = new_board[i: drop_row].copy()
        new_board[i] = 0
        list_ans.append(new_board.copy())
        i += 1
    return list_ans

xxx016xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 968, 'const': 364, 'code+const': 1332}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('For', 12)]]
import numpy as np
def get_score(board):
    return np.sum(np.sum(np.array(board != 0), axis=1) == board.shape[1]) * 40
def get_time_cap(board, time_caps):
    if np.sum(board) == 0 : return time_caps[-1]
    b_reshaped = np.sum(board, axis=1).reshape((len(time_caps), board.shape[0]//len(time_caps))).T
    result = np.array(time_caps)[np.sum(b_reshaped, axis=0) != 0]
    return result[0]
def rotate_right(shape):
    return shape.T[:, ::-1]
def rotate_left(shape):
    return shape.T[::-1, :]
def animate_drop(board, shape, c):
    if c <= board.shape[1] - shape.shape[1] :
        result = []
        drop = True
        for i in range(shape.shape[0], board.shape[0]+1) :
            board_part = board[:i, c:c+shape.shape[1]]
            if i <= shape.shape[0] :
                block = shape[shape.shape[0]-i:]
            else :
                n = i - shape.shape[0]
                block = np.zeros_like(board_part, int)
                block[n:] += shape
            if np.sum(board_part*block) == 0 :
                new_board = np.array(board)
                new_board[:i, c:c+shape.shape[1]] += block
                result.append(new_board)
            elif i <= shape.shape[0] :
                drop = False
                break
            else : break
        if not drop : return []
        else : return result
    else : return []
def animate_clear(board):
    if np.sum(np.min(board, axis=1) != 0) != 0 :
        result = []
        new_board = np.array(board)
        ind = np.arange(0,board.shape[0])[np.min(board, axis=1) != 0]
        new_board[ind] = np.zeros((1,board.shape[1]), int)
        result.append(new_board)
        ind = np.arange(0,new_board.shape[0])[np.max(new_board, axis=1) == 0]
        ind_check = np.arange(0,ind.shape[0])
        final_ind = ind[ind != ind_check]
        l = len(final_ind)
        for i in range(l) :
            n = ind[-1]
            moved_board = np.zeros_like(new_board, int)
            moved_board[1:n+1] += new_board[:n]
            if np.sum(moved_board[-1]) == 0 :
                moved_board[n+1:] += new_board[n+1:]
            result.append(moved_board)
            new_board = np.array(moved_board)
            ind = np.arange(0,new_board.shape[0])[np.max(new_board, axis=1) == 0]
        return result
    else : return []

xxx208xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError("non-broadcastable output operand with shape (1,3) doesn't match the broadcast shape (2,3)")
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (2,3) (3,3) (2,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0Time-out: 5s
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0Time-out: 5s
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0Time-out: 5s
[[]]
bytecount: {'code': 618, 'const': 352, 'code+const': 970}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 10)]]
import numpy as np
def get_score(board):
  a = np.min(board, axis = 1)
  return list(a != 0).count(True) * 40
def get_time_cap(board, time_caps):
  a = int(board.shape[0] / len(time_caps))
  b = list(np.max(board, axis = 1)).count(0) + 1
  c = np.arange(0, len(board), a)
  return time_caps[list(b > c).count(True) - 1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    ans = []
    derm = np.sum(board != 0) + np.sum(shape != 0)
    brick = np.array(shape)
    b_s = brick.shape
    for i in range(len(board) + b_s[0] + 1):
      n_board = np.array(board)
      n_board[i:i + b_s[0], c:c + b_s[1]] += brick
      if np.sum(n_board != 0) == derm: 
        ans.append(n_board)
      else:
        break
    return ans
def animate_clear(board):
    ans = []
    n_board = np.array(board)
    clear = np.min(n_board, axis = 1)
    checks = clear != 0
    n_board[checks,:] = 0
    ans.append(n_board)
    h = len(n_board)
    while True:
      blank = np.max(n_board, axis = 1)
      checks_b = blank == 0
      if np.sum(checks_b) == 0:
        return []
      hh = np.arange(h)
      bm = hh[checks_b][-1]
      if bm != h:
        n_board[1:bm + 1] = n_board[0:bm]
        n_board[0] = 0
        ans.append(n_board)
    return ans

xxx215xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 746, 'const': 338, 'code+const': 1084}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 7)], [('While', 8)]]
import numpy as np
def get_score(board):
    count_bool = np.sum((board == 0), axis=1)
    return count_bool[count_bool == 0].shape[0] * 40
def get_time_cap(board, time_caps):
    len_time = len(time_caps)
    len_mod = board.shape[0] * board.shape[1]
    count_bool = np.sum((board.reshape((len_time, len_mod // len_time)) != 0), axis=1)
    idx_min = np.argmax(count_bool > 0)
    val_min = count_bool[idx_min]
    return time_caps[-1 if idx_min == val_min == 0 else idx_min]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    r_board, c_board = board.shape
    r_shape, c_shape = shape.shape
    list_out = []
    idx_max = r_board - r_shape
    idx_y = 0
    while idx_y <= idx_max:
        to_check = np.array(board[idx_y:idx_y + r_shape, c:c + c_shape])
        to_check[shape == 0] = 0
        if np.sum(to_check != np.zeros_like(shape)):
            break
        else:
            repl_board = np.array(board)
            repl_board[idx_y:idx_y + r_shape, c:c + c_shape] += shape
            list_out.append(repl_board)
        idx_y += 1
    return list_out
def animate_clear(board):
    _board = np.array(board)
    _board[np.sum(_board == 0, axis=1) == 0] = 0
    list_out = []
    idx_max = np.sum(np.sum(_board != 0, axis=1) == 0)
    if idx_max and np.sum(_board != board):
        list_out.append(_board)
        while np.sum(np.sum(_board[:idx_max] != 0, axis=1) == 0) < idx_max:
            np_bool_zeros = np.sum(_board != 0, axis=1) == 0
            idx_last = len(np_bool_zeros) - np.argmax(np_bool_zeros[::-1]) - 1
            t_list = []
            t_list.extend(_board[idx_last:idx_last + 1])
            t_list.extend(_board[:idx_last])
            t_list.extend(_board[idx_last + 1:])
            _board = np.array(t_list)
            list_out.append(_board)
    return list_out

xxx214xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[array([[2, 2, 2, 0],
       [3, 0, 1, 1]])], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[ 0,  0,  0,  0,  0,  0],
       [ 0,  2,  2,  2,  0,  0],
       [ 0,  0,  0,  2,  8,  0],
       [ 1,  1,  0, 10,  8,  0],
       [ 1,  1,  0,  0,  8,  0]]),
  array([[ 0,  0,  0,  0,  0,  0],
       [ 0,  0,  0,  0,  0,  0],
       [ 0,  2,  2,  2,  8,  0],
       [ 1,  1,  0, 10,  8,  0],
       [ 1,  1,  0,  2,  8,  0]])],
 [array([[ 0,  0,  2,  2,  2,  0],
       [ 0,  0,  0,  0,  2,  0],
       [ 0,  0,  0,  0, 10,  0],
    ... (more)
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 742, 'const': 406, 'code+const': 1148}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('For', 13)]]
import numpy as np
def get_score(board):
    min1 = np.min(board,axis=1)
    min2 = min1 != 0
    return sum(min2)*40
def get_time_cap(board, time_caps):
    max1 = np.max(board,axis=1)
    x = np.arange(board.shape[0])
    A = x[max1 != 0]
    if len(A) != 0:
        B = A[0]
        z= len(board)//len(time_caps)
        w = int(((B+1)/z)-0.3)
        if w%(B+1)/z > 0.5:
          w += 0.5
        out = time_caps[int(w)]
    else:
        out = time_caps[-1]
    return out
def rotate_right(shape):
    return shape[::-1,::].T
def rotate_left(shape):
    return shape[::,::-1].T
def animate_drop(board, shape, c):
    out = []
    for i in range(len(board)-shape.shape[0]+1):
        new_board = np.array(board)
        new_board[i:i+shape.shape[0],c:c+shape.shape[1]] += shape
        if new_board[i,c] != shape[0,0]:
            break
        out.append(new_board )
    return out
def animate_clear(board):
    out = []
    new_board = np.array(board)
    min1 = np.min(board,axis=1)
    A = np.arange(len(board))
    zero1 = A[min1 != 0]
    if len(zero1 != 0):
        new_board[zero1,:] = 0
        out.append(new_board)
    max1 = np.max(new_board,axis=1)
    zero2 = A[max1 == 0]
    for i in range(1,len(zero2)+1):
        new_board = np.array(new_board)
        max1 = np.max(new_board[i:,:],axis=1)
        zero2 = A[i:][max1 == 0]
        if len(zero2) == 0:break
        new_board[1:zero2[-1]+1,:] = new_board[:zero2[-1],:]
        new_board[0,:] = 0
        out.append(new_board)
    return out

xxx212xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 948, 'const': 352, 'code+const': 1300}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('For', 10)]]
import numpy as np
def get_score(board):
    check = np.sum((np.array(board[:] != 0)),axis = 1)
    check_again = np.sum(np.array(check == board.shape[1]))*40
    return check_again
def get_time_cap(board, time_caps):
    n = board.shape[0]//len(time_caps)
    check = np.array(board != 0)
    check = check.reshape((board.shape[0]//n,board.shape[1]*n))
    check = np.sum(check,axis = 1)
    check = np.array(check > 0)
    check_index = np.arange(0,check.shape[0],1)
    check_index = check_index[check]
    if len(check_index) == 0 :
        return time_caps[-1]
    else :
        return time_caps[check_index[0]]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    bc = np.array(board)
    check = np.array(board != 0)
    drop_list = []
    for i in range(len(bc)) :
        if i == len(bc) - len(shape) + 1 : break
        ch = np.array((check[i:i+shape.shape[0],c:c+shape.shape[1]]) & (shape != 0))
        if True in ch:
            break      
        else :
            bc[i:i+shape.shape[0],c:c+shape.shape[1]] = bc[i:i+shape.shape[0],c:c+shape.shape[1]] + shape 
            drop_list.append(np.array(bc))
            bc[i:i+shape.shape[0],c:c+shape.shape[1]] = bc[i:i+shape.shape[0],c:c+shape.shape[1]] - shape 
    return drop_list
def animate_clear(board):
    clear_list = []
    clone = np.array(board)
    check = np.sum(np.array(board[:] == 0),axis = 1) == 0
    g = np.arange(0,len(board),1)[check]
    clone[g] = clone[g] - clone[g]
    clear_list.append(np.array(clone))
    n = np.arange(0,len(clone))
    for i in range(len(clone)) :
        line_zero = n[np.sum(clone,axis=1)==0]
        if len(line_zero) == 0 :
            return []
        if np.sum(clone[0:len(line_zero)]) == 0 :
            break
        clone[1:line_zero[-1]+1] = clone[0:line_zero[-1]]
        if i == 0 :
            clone[0] = 0
        clear_list.append(np.array(clone)) 
    return clear_list

xxx035xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('operands could not be broadcast together with shapes (2,4) (3,4) ')
[[], [array([[0, 2, 2, 2],
 dtype=float64      [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, [13, 23, 03, 0], 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (2,3) (3,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('operands could not be broadcast together with shapes (2,2) (3,2) ')
[[array([[[1, 1, 2, 2],
        [1, 1, 0, 0]]),

       array([[1, 1, 0, 0],
        [1, 1, 2, 2]])]), [], [],
 []]
test_animate_clear_10.0
[[array([[[0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0]]])],
 [array([[[0, 5, 5, 4],
        [1, 0, 5, 4],
        [1, 0, 2, 4],
        [0, 0, 0, 0]]),

       array([[0, 0, 0, 0],
        [0, 5, 5, 4],
        [1, 0, 5, 4],
        [1, 0, 2, 4]]])],
 [array([[[0, 5, 5, 4],
        [0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0]]),

       array([[0, 0, 0, 0],
        [0, 5, 5, 4],
        [0, 0, 0, 0],
        [0, 0, 0, 0]]),

       array([[0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 5, 5, 4],
        [0, 0, 0, 0]]),

       array([[0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 5, 5, 4]]])],
 [array([[[0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 2, 2, 4]]])]]
test_animate_clear_20.0
[[],
 [array([[[1, 2, 0, 0],
        [0, 0, 0, 0],
        [1, 0, 2, 4],
        [0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 1, 1]]),

       array([[0, 0, 0, 0],
        [1, 2, 0, 0],
        [0, 0, 0, 0],
        [1, 0, 2, 4],
        [0, 0, 0, 0],
        [0, 0, 1, 1]]),

       array([[0, 0, 0, 0],
        [0, 0, 0, 0],
        [1, 2, 0, 0],
        [0, 0, 0, 0],
        [1, 0, 2, 4],
        [0, 0, 1, 1]]),

       array([[0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0],
        [1, 2, 0, 0],
        [1, 0, 2, 4],
        [0, 0, 1, 1]]])]]
test_animate_clear_30.0
[array([[[0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0],
        [0, 0, 0, 0]]])]
bytecount: {'code': 946, 'const': 372, 'code+const': 1318}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 15)]]
import numpy as np
def roll(n):
    z = np.zeros(n.shape , int)
    z[0] = n[-1]
    z[1::,:] = n[:-1:,:]
    return z
def get_score(board):
    a = np.min(board, axis=1)
    b = a[a != 0]
    return len(b) * 40
def get_time_cap(board, time_caps):
    r,c = board.shape
    zero = np.zeros((r,c),int)
    if str(board) == str(zero):
        return time_caps[-1]
    d = int(r/len(time_caps))
    b = board.reshape(len(time_caps),c*d)
    maxx = np.max(b, axis=1)
    ran = np.arange(0,len(time_caps))
    tf = maxx != 0
    r = ran[tf]
    return time_caps[r[0]]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    rs,cs = shape.shape
    rb = board.shape[0]
    lst = []
    for i in range(rb):
        r1 = board[i:i+rs,c:c+cs] == 0
        r2 = shape[:,:] != 0 
        if str(r1 & r2) == str(r2) :
            new_board[i:i+rs,c:c+cs] = shape
            lst.append(new_board)
        new_board = np.array(board)
    return np.array(lst)
def animate_clear(board):
    z = np.min(board,axis = 1)
    ran = np.arange(0,len(board))
    tf = z != 0
    nzrow = ran[tf]
    new_board = np.array(board)
    new_board[nzrow,:] = 0
    lst = [new_board]
    summ = np.sum(new_board,axis = 1)
    zero = summ[summ == 0]
    if len(zero) == 0:
        return []
    ranz = np.arange(len(zero))
    z = np.zeros((len(zero),board.shape[1]),int)
    while str(new_board[ranz,:]) != str(z):
        summ = np.sum(new_board,axis = 1)
        zero = summ == 0
        lastz = ran[zero][-1]
        broll = new_board[:lastz+1:,:]
        constant = new_board[lastz+1:,:]
        r = roll(broll)
        new_board = np.zeros_like(board)
        new_board[:lastz+1:,:] = r
        new_board[lastz+1:,:] = constant
        lst.append(new_board)
    return np.array(lst)

xxx015xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
    None   [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, None0, None8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
   None    [1, 1, 0, 0]]), array([[1, 1, None0, None0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 418, 'const': 266, 'code+const': 684}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], []]
import numpy as np
def get_score(board):
  minn = np.min(board, axis=1)
  full = minn[minn>0]
  return len(full)*40
def get_time_cap(board, time_caps):
  b2 = board.reshape(len(time_caps),int((board.shape[0]/len(time_caps))*board.shape[1]))
  maxx = np.max(b2,axis=1)
  key = np.arange(len(maxx))
  a1 = maxx > 0
  a2 = key[a1]
  if len(a2) > 0 :
      return time_caps[a2[0]]
  else :
      return time_caps[-1]
def rotate_right(shape):
  shape2 = shape.T[:,::-1]
  return shape2
def rotate_left(shape):
  shape2 = shape[:,::-1].T
  return shape2
def animate_drop(board, shape, c):
  fall_ok = board.shape[1] - shape.shape[1]
  if c not in range(fall_ok) :
      return []
  for i in range(board.shape[0]) :
      x = board[i,c:c+shape.shape[1]]
      x2 = x + shape
      if np.min(x2-x) != 0 :
          return []
      else :
          return
def animate_clear(board):
    pass

xxx021xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 458, 'const': 266, 'code+const': 724}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('size', 10)], []]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], []]
import numpy as np
def get_score(board):
    a=board==0            
    b=np.sum(a,axis=1)
    return np.sum(b==0)*40
def get_time_cap(board, time_caps):
    r,c=board.shape
    n=len(time_caps)
    k=board.reshape(n,c*(r//n))
    a=np.sum(k>0,axis=1)
    pos=np.arange(a.shape[0])
    b=a>0
    if np.sum(b)==0:
        return time_caps[-1]
    c=pos[b][0]
    return time_caps[c]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    k=[]
    row,col=shape.shape
    for i in range(board.shape[0]-row+1):
        a=board[i:row+i,c:col+c]
        new_board = np.array(board)
        x=a==0
        y=shape==0
        if np.sum(x|y)==np.size(shape):
            new_board[i:row+i,c:col+c]+=shape
            k.append(new_board)
        else:
            return k
    return k
def animate_clear(board):
    pass

xxx025xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 806, 'const': 350, 'code+const': 1156}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 12)]]
import numpy as np
def get_score(board):
    x = np.sum(board > 0,axis = 1)
    return sum(x == board.shape[1])*40
def get_time_cap(board, time_caps):
    n = int(board.shape[0]/len(time_caps))
    x = np.sum(board != 0,axis = 1)
    if True in list(x != 0):
        k = list(x != 0).index(True)
        return time_caps[k//n]
    else:
        return time_caps[-1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    l = []
    new_shape = np.array(shape)
    for i in range(board.shape[0]):
        new_board = np.array(board)
        cut_board = new_board[i:shape.shape[0]+i:,c:shape.shape[1]+c:]
        if cut_board.shape == new_shape.shape:
            d=np.array(cut_board)
            x = new_shape != 0
            k=np.sum(new_shape)
            v=np.sum(d)
            d[x]=new_shape[x]
            m=np.sum(d)
            if m==v+k:
                new_board[i:shape.shape[0]+i:,c:shape.shape[1]+c:] += new_shape
                l.append(new_board)
            else:
                break
    return l
def animate_clear(board):
    l = []
    new_board = np.array(board)
    new_board_sum = np.sum(new_board != 0,axis = 1)
    new_board_TF = (new_board_sum == board.shape[1])
    new_board[new_board_TF] = 0 
    z = (new_board == board)
    if False in z:
        l.append(new_board)
    new_board_loop = np.zeros((board.shape[0],board.shape[1]), int)
    i = board.shape[0]-1
    while i >= 0:
        old_board = np.array(new_board)
        x = np.sum(new_board[i] == 0)
        if x == board.shape[1]:
            new_board_loop[1:i+1:] = new_board[:i:]
            TF = (old_board == new_board_loop)
            if False in TF:
                l.append(np.array(new_board_loop))
            elif np.sum(TF) == (board.shape[1]*board.shape[0]):
                break
            else:
                pass
            new_board = new_board_loop
        else:
            new_board_loop[i] = new_board[i]
            i -= 1
    return l

xxx208xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 984, 'const': 350, 'code+const': 1334}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('For', 15)]]
import numpy as np
def get_score(board):
  score = board != 0
  points = np.sum(score, axis = 1)
  total_points = sum(points == board.shape[1])
  return total_points * 40
def get_time_cap(board, time_caps):
  max_score = np.max(board, axis = 1)
  num_pos = list(max_score == 0)
  sum_score = sum(max_score == False)
  if sum_score == len(num_pos):
    timecap = time_caps[-1]
    return timecap
  idx = num_pos.index(False)
  shape = board.shape[0]
  num_caps = len(time_caps)
  if (idx + 1) / (shape / num_caps) % 1 == 0:
    pos = (int((idx + 1) / (shape / num_caps))) 
  else:
    pos = int((idx + 1) / (shape / num_caps) + 1)
  timecap = time_caps[pos - 1]
  return timecap
def rotate_right(shape):
  return np.array(np.array(shape)[::-1]).T
def rotate_left(shape):
  return np.array(np.array(shape[:]).T[::-1])
def animate_drop(board, shape, c):
  drop = []
  board_shape0 = board.shape[0]
  shape0 = shape.shape[0]
  board_shape1 = board.shape[1]
  shape1 = shape.shape[1]
  ranges = range(board_shape0 - shape0 + 1)
  for items in ranges:
    new = np.array(board)
    new_board = np.array(board)
    pos1 = items + shape0
    pos2 = c + shape1
    new[items:pos1, c:pos2] += shape
    reshape = new_board.reshape(board_shape0 * board_shape1)
    reshape2 = new.reshape(board_shape0 * board_shape1)
    drop_shape = reshape[reshape == 0].shape[0]
    drop_shape2 = reshape2[reshape2 == 0].shape[0]
    res = shape.reshape(shape0 * shape1)
    blog = res[res != 0].shape[0]
    if drop_shape != drop_shape2 + blog:
      break
    drop += [new]
  return drop
def animate_clear(board):
  new = np.array(board)
  sum_board = np.sum(new == 0, axis = 1)
  new[sum_board == 0] = np.array(0)
  max_board = np.max(new, axis = 1)
  sum_max = sum(max_board == 0)
  if sum_max == 0:
    clear = []
    return clear
  clear = []
  idx = 0
  new_board = np.array(new)
  clear.append(new_board)
  ranges = range(sum_max * 2)
  for items in ranges:
    if np.max(new[-(idx+1)]) == 0:
      if idx != 0:
        new[1:-idx] = new[:-(idx+1)]
      else:
        new[1:] = new[:-(idx+1)]
      new[0] = np.array(0)
      idx = 0
      shown = np.array(new)
      clear.append(shown)
      max = np.max(new, axis = 1)
      sum_new = sum(max == 0)
      sum_compare = sum(np.max(new[:sum_new], axis = 1) == 0)
      if sum_compare == sum_new:
        break
    idx += 1
  return clear

xxx201xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 1006, 'const': 338, 'code+const': 1344}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 10)], [('While', 24)]]
import numpy as np
def get_score(board):
    bool_board = board == 0
    score_array = np.sum(bool_board, axis=1)
    line = score_array == 0
    score = np.sum(line)*40
    return score
def get_time_cap(board, time_caps):
    if np.sum(board) == 0:
        return time_caps[-1]
    partition = len(time_caps)
    r,c = board.shape
    width_of_part = r/partition
    bool_board = board == 0
    score_array = np.sum(bool_board, axis=1)
    line = score_array < c
    RB = np.arange(0,line.shape[0])[line]
    first_row = RB[0]
    return time_caps[int(first_row//width_of_part)]
def rotate_right(shape):
    T_Shape = shape.T
    return T_Shape[:,::-1]
def rotate_left(shape):
    T_Shape = shape.T
    return T_Shape[::-1]
def animate_drop(board, shape, c):
    memory = []
    new_board = np.array(board) 
    new_shape = np.array(shape)
    board_r = new_board.shape[0]
    shape_r, shape_c = new_shape.shape
    displacement_row = board_r - shape_r + 1
    bool_shape = new_shape == 0
    for r in range(displacement_row):
        new_board = np.array(board) 
        considering_space = new_board[r:r+shape_r, c:c+shape_c]
        bool_considering_space = considering_space == 0
        if np.sum(bool_shape | bool_considering_space) == shape_r*shape_c:
          new_board[r:r+shape_r, c:c+shape_c] += shape
          memory.append(new_board)
        else:
          break
    return memory
def animate_clear(board):
    new_board = np.array(board)
    board_r,board_c = new_board.shape
    bool_board = new_board == 0
    isFilled_array = np.sum(bool_board, axis=1)
    isFilled_array = isFilled_array == 0
    new_board[isFilled_array] = 0
    bool_clear = new_board != 0
    bool_clear_2 = np.sum(bool_clear, axis = 1)
    index_row = np.arange(0,board_r,1)
    pos = index_row[bool_clear_2 != 0][::-1]
    space = index_row[bool_clear_2 == 0][::-1]
    fixed_pos = np.array(pos)
    memory = []
    memory.append(new_board)
    r = 0
    if len(space) == 0:
        return []
    while r < fixed_pos.shape[0]:
        if len(memory) == 0:
            clean_board = np.zeros((board_r,board_c))
        else:
            clean_board = np.array(memory[-1])
        if space[0] - pos[r] > 0:
            shape = new_board[fixed_pos[-1]:fixed_pos[r]+1]
            if np.sum(clean_board[pos[r]+1]) == 0:
                clean_board[pos[-1]:pos[r]+1] = 0
                clean_board[pos[-1]+1:pos[r]+1+1] = shape
                pos += 1
                bool_clear = clean_board != 0
                bool_clear_2 = np.sum(bool_clear, axis = 1)
                index_row = np.arange(0,board_r,1)
                space = index_row[bool_clear_2 == 0][::-1]
                memory.append(clean_board)
            elif np.sum(clean_board[pos[r]+1]) != 0:
                r += 1
        else:
            r += 1
    return memory

xxx036xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 754, 'const': 338, 'code+const': 1092}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('While', 8)]]
import numpy as np
def get_score(board):
    return np.sum((np.sum(board > 0 ,axis=1)) == board.shape[1]) * 40
def get_time_cap(board, time_caps):
    if np.sum(board) == 0 :
        return time_caps[-1]
    else :
        return np.array(time_caps)[np.sum((board.reshape(len(time_caps),                  int((board.shape[0]/len(time_caps))*board.shape[1])))> 0,axis =1) > 0][0]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    new_shape = np.array(shape)
    z = []
    for i in range(board.shape[0]- new_shape.shape[0] + 1) :
        new_board = np.array(board)
        a = (new_board[i : i + new_shape.shape[0],c:int(c+new_shape.shape[1])])
        if np.sum(a[shape != 0]) == 0 :
            new_board[i: i + new_shape.shape[0] ,c:int(c+new_shape.shape[1])] += new_shape
            z.append(new_board)
        else :
            break
    return z
def animate_clear(board):
    new_board = np.array(board)
    board2 = new_board * (np.sum(new_board>0,axis = 1) != board.shape[1]).reshape(board.shape[0],1)
    z = []
    if np.sum(board2) != np.sum(new_board) :
        z.append(board2)
        while True :
            mid = np.arange(0,board.shape[0])[(np.sum(board2 > 0 ,axis = 1) == 0)][-1]
            a = board2[:mid]
            if np.sum(a) == 0 :
                break
            b = board2[mid]
            c = board2[mid+1:]
            newboard = np.ndarray((board.shape[0],board.shape[1]),int)
            newboard[0] = b
            newboard[1:1 + a.shape[0]] = a
            newboard[1 + a.shape[0] : ] = c
            z.append(newboard)
            board2 = newboard
        return z
    else :
        return z

xxx023xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 860, 'const': 396, 'code+const': 1256}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('For', 14)]]
import numpy as np
def get_score(board):
    col = board.shape[1]
    sum_not_zero = np.sum(board!=0,axis=1)
    full_row = np.sum(sum_not_zero == col)
    return full_row*40
def get_time_cap(board, time_caps):
    row,col = board.shape
    n = row//len(time_caps)
    sum_is_zero = np.sum(board==0,axis=1)
    full_row = np.arange(row)[(1<=sum_is_zero)&(sum_is_zero<col)]
    if len(full_row)==0:
        return time_caps[-1]
    return time_caps[full_row[0]//n]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    list_board=[]
    row_shape,col_shape = shape.shape
    row_can_drop = np.sum(board[:,c:c+col_shape]==0,axis=1)==col_shape
    if row_can_drop[0]==False:
        return []
    for i in range(len(row_can_drop)-row_shape+1):
        if row_can_drop[i+row_shape-1] == False:
            break
        else:
            A0 = np.zeros((board.shape[0],board.shape[1]),int)
            if row_can_drop[i]==True:
                A0[i:i+row_shape,c:c+col_shape]=shape
                list_board.append(board+A0)
            else:
                break
    return list_board
def animate_clear(board):
    mylist = []
    row,col = board.shape
    Board = np.array(board)
    row_not_zero = np.arange(row)[np.sum(Board!=0,axis=1)==col]
    if len(row_not_zero) == 0:
        return []
    Board[row_not_zero] = 0
    mylist.append(Board)
    first_not_zero = np.arange(row)[np.sum(Board==0,axis=1)!=col][0]
    zero = np.arange(row)[np.sum(Board==0,axis=1)==col]
    last_zero = zero[-1]
    for i in range(len(zero)-first_not_zero):
        New = np.ndarray((row,col),int)
        New[0] = np.zeros(col,int)
        if last_zero == row-1 :
            New[1:last_zero+1]=Board[:last_zero]
        elif last_zero != row-1:
            New[1:last_zero+1]=Board[:last_zero]
            New[last_zero+1:]=Board[last_zero+1:]
        mylist.append(New)
        last_zero = np.arange(row)[np.sum(New==0,axis=1)==col][-1]
        Board = New
    return mylist

xxx041xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [10, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 25, 4],
       [1, 50, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [10, 15, 5, 4],
       [10, 0, 0, 0],
       [0, 10, 0, 0]]),
  2array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 974, 'const': 346, 'code+const': 1320}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 9)], []]
import numpy as np
def get_score(board):
    m = np.min(board,axis=1)
    p = m[abs(m)>0]
    return len(p)*40
def get_time_cap(board, time_caps):
    if np.sum(board) == 0:
        return time_caps[-1]
    else:
        M = np.sum(board,axis=1)
        A = np.arange(1,len(M)+1,1)
        m = np.max(M)
        t0 = np.abs(np.abs((M+1)-m)-1)
        t1 = np.max(t0)
        s = t0//t1
        s = s+1
        w = np.max(s)
        S = np.abs(s-w)
        y = np.max(S)
        u = S/y
        A = np.arange(1,len(M)+1,1)
        pos = u*A
        position = pos[pos != 0]
        P = position[0]
        if P%2 == 0:
            f = int((P/2)-1)
            return time_caps[f]
        else:
            f = int(((P+1)/2)-1)
            return time_caps[f]
def rotate_right(shape):
    s = shape.T
    return s[::,::-1]
def rotate_left(shape):
    s = shape.T
    return s[::-1,::]
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    d = abs(new_board.shape[1]-new_shape.shape[1])
    if len(new_board[0,c:new_shape.shape[1]+c]) < new_shape.shape[1]:
        return [] 
    else:
        x = []
        for i in range(len(board)):
            new_board = np.array(board)
            if i+new_shape.shape[0] > new_board.shape[0]:
                return x
            else:
                if np.sum(new_board[i:i+new_shape.shape[0],c:new_shape.shape[1]+c]*new_shape) != 0:
                    return x
                else:
                    new_board[i:i+new_shape.shape[0],c:new_shape.shape[1]+c] = new_shape+new_board[i:i+new_shape.shape[0],c:new_shape.shape[1]+c]
                    x.append(new_board)
        return x
def clear_row(board):
    x = []
    new_board = np.array(board)
    m = np.min(new_board,axis=1)
    if np.sum(m) == 0:
        return x
    else:
        t = np.max(m[m!=0])
        M = np.abs(np.abs((m+1)-t)-1)
        p = np.max(M)
        s = M//p
        S = np.array(s,int)
        clear = (S*new_board.T).T
        return clear
def animate_clear(board):
    x = []
    new_board = np.array(board)
    if clear_row(new_board) == []:
        return x
    else:
        nb = np.array(clear_row(new_board))
        return nb

xxx208xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 888, 'const': 338, 'code+const': 1226}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('For', 20)]]
import numpy as np
def get_score(board):
  game = abs(board)
  score = np.min(game,axis = 1)
  score = score[score > 0]
  return len(score)*40
def get_time_cap(board, time_caps):
  index = np.arange(board.shape[0])
  game = abs(board)
  row = np.sum(game,axis = 1 )
  row = index[row != 0]
  if len(row) > 0 :
    t = board.shape[0]//len(time_caps) 
    time = time_caps[row[0]//t]
    return time
  else: return time_caps[-1]
def rotate_right(shape):
  new = shape[::-1,:]
  return new.T
def rotate_left(shape):
  new = shape[:,::-1]
  return new.T
def animate_drop(board, shape, c):
  new_board = np.array(board)
  new_shape = np.array(shape)
  game = []
  for i in range(abs(new_board.shape[0]-new_shape.shape[0]+1)):
    play =  new_board[i:i+new_shape.shape[0]:,c: shape.shape[1]+c:] != 0
    if np.sum(shape[play]) != 0 : return game
    new_board[i:i+new_shape.shape[0]:,c: shape.shape[1]+c:][~play] = shape[~play]
    game.append(new_board)
    new_board = np.array(board)
  return game
def animate_clear(board):
  game = []
  new_board = np.array(board)
  row = new_board.shape[0]
  col = new_board.shape[1]
  if np.sum(np.min(new_board,axis = 1) == 0) == row and (np.sum(np.sum(new_board, axis = 1) == 0) == 0) :  return game
  change = np.min(new_board,axis = 1) != 0
  new_board[change] = np.zeros(col)
  board_new = np.array(new_board)
  game.append(board_new)
  zero = np.sum(new_board,axis = 1) == 0
  check = np.arange(row)
  Range = np.arange(row)
  power = np.array([10]*row)
  power = power**Range
  last = zero * check
  check = np.arange(row)
  check[np.sum(zero):] = 0
  for i in range(row):
    if np.sum(last * power) == np.sum(check * power) : break
    new_board[1:np.max(last)+1] = new_board[:np.max(last)]
    new_board[0] = np.zeros(col)
    last = (np.sum(new_board,axis = 1) == 0) * Range
    board_new = np.array(new_board)
    game.append(board_new)
  return game

xxx018xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 948, 'const': 332, 'code+const': 1280}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 9)], [('While', 14)]]
import numpy as np
def get_score(board):
    a=np.min(board,axis=1)    
    return sum(a!=0)*40
def get_time_cap(board, time_caps):
    a=np.max(board,axis=1)
    b=(a!=0)
    c=np.argmax(b)
    if max(a) != 0:
        return time_caps[c//(board.shape[0]//len(time_caps))]
    else:
        return time_caps[-1]
def rotate_right(shape):
    return shape.T[:,-1::-1]
def rotate_left(shape):
    return rotate_right(rotate_right(rotate_right(shape)))
def animate_drop(board, shape, c):
    x=0
    new_board = np.array(board)
    s1,s2=board.shape
    a1,a2=shape.shape
    bg=np.array(board)
    ans=[]
    while True:
        if x+a1==s1+1:
            break
        k=bg[x:x+a1,c:a2+c]
        if np.sum(k[shape!=0])!=0:
            break        
        new_board = np.array(board)
        new_board[x:x+a1,c:a2+c]+=shape
        ans.append(new_board)
        x+=1
    return ans
def animate_clear(board):
    new_board = np.array(board)
    check=False
    s1,s2=board.shape
    ones = np.ones((1,new_board.shape[1]),int)
    board1=np.ones((new_board.shape),int)
    board2=np.zeros((new_board.shape),int)
    a=[]
    count=s1
    count1=count
    clear=0
    ans=[]
    while True:
        if check==False:
            if get_score(new_board)==0 or s1==-1:
                check=True
                ans.append(new_board)
            newboo=new_board!=0
            if np.sum(newboo[s1-1:s1,0:s2])==np.sum(ones):
                new_board[s1-1:s1,0:s2]=0
                clear+=1
            s1-=1
        else:
            if clear==0:
                return []
            if np.sum(new_board[count-1,:])==0:
                zero=np.zeros(new_board.shape,int)
                zero[0,:]=new_board[count-1]
                zero[1:count,:]=new_board[0:count-1]
                zero[count:,:]=new_board[count:]
                new_board=np.array(zero)
                ans.append(new_board)
            if  np.sum(new_board[count-1,:])==0 and np.sum(new_board[:count-2,:])!=0:
                count+=1
            if np.sum(new_board[:count-2,:])==0:
                break
            count-=1
    return ans

xxx037xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 25, 25, 4]])],
  [array([[0, 0, 0, 0],
    ... (more)
test_animate_clear_20.0
[[array([[0, 2, 0, 0],
       [2, 2, 2, 0],
       [1, 1, 0, 0]])],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 868, 'const': 338, 'code+const': 1206}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('For', 11)]]
import numpy as np
def get_score(board):
    result = board != 0
    seachr = np.sum(result, axis = 1)
    nboard = board[seachr == board.shape[1]]
    output = int(len(nboard) * 40)
    return output
def get_time_cap(board, time_caps):
    a = len(time_caps)
    w = board.shape[0]
    k = np.max(board,axis = 1)
    x = len(k[k!=0])
    if x == 0:
      return time_caps[-1]
    else :
      position = np.argmax(k != 0)
      x = w // a
      timecaps_pos = position // x
      output = time_caps[timecaps_pos]
    return output
def rotate_right(shape):
    new = shape.T[::,::-1]
    output = np.array(new)
    return output
def rotate_left(shape):
    new = shape.T[::-1,::]
    output = np.array(new)
    return output
def animate_clear(board):
    new = np.array(board)
    min_ = np.min(board, axis = 1)
    pos1 = np.arange(board.shape[0])
    pos2 = pos1[min_ != 0]
    new[pos2] = 0
    new_pos = pos1[np.sum(new, axis = 1) == 0]
    L = [np.array(new)]
    sumary = np.sum(np.sum(new, axis = 1) != 0)
    for i in range(len(new_pos)):
        index = pos1[np.sum(new, axis = 1) == 0][-1]
        if index != board.shape[0]:
            new[1:index+1] = new[0:index]
            new[0] = 0
            L.append(np.array(new))
        if np.sum(np.sum(board[-sumary:], axis = 1) != 0) == sumary:
            break
    return L
def animate_drop(board, shape, c):
    c1,r1 = shape.shape
    ans = []
    for i in range(shape.shape[0], len(board) - c1 +1):
        new = np.array(board)
        if i < 0: new[0:-i, c: c+r1] += shape[i:]
        if np.sum(new != 0) != np.sum(board != 0) + np.sum(shape[i:] != 0) : 
            return ans
        else:
            x = np.sum(board != 0) + np.sum(shape != 0)
            new[i:i+c1 , c:c+r1] += shape
            if np.sum(new !=0) != x: break
            ans.append(np.array(new))
    return ans

xxx039xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('operands could not be broadcast together with shapes (2,4) (3,4) (2,4) ')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (2,3) (3,3) (2,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('operands could not be broadcast together with shapes (2,2) (3,2) (2,2) ')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 938, 'const': 324, 'code+const': 1262}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('While', 14)]]
import numpy as np
def get_score(board):
    get = board[np.min(board,axis=1)!=0]
    n = get.shape[0]
    return n*40
def get_time_cap(board, time_caps):
    r = board.shape[0]
    n = len(time_caps)
    ch = r//n
    max = np.max(board,axis=1)
    idx = np.arange(board.shape[0])
    if np.max(max)==0:
        return time_caps[-1]
    else:
        pos = idx[max[idx]!=0][0]
        return time_caps[pos//ch]
def rotate_right(shape):
    t = shape.T
    return t[:,-1::-1]
def rotate_left(shape):
    t = shape.T
    return t[-1::-1,:]
def animate_drop(board, shape, c):
    b1 = board[:,c:c+shape.shape[1]]
    final = []
    for i in range(board.shape[0]-1):
        new0 = np.array(board)
        new = np.array(b1)
        new[i:i+shape.shape[0],:] += shape[:,:]
        tf = (new[i:i+shape.shape[0],:]==shape) & (new[i:i+shape.shape[0],:]!=0)
        if np.sum(tf)==np.sum(shape!=0):
            new0[i:i+shape.shape[0],c:c+shape.shape[1]] = new[i:i+shape.shape[0],:]
            final.append(new0)
    return final
def animate_clear(board):
    r = board.shape[0]
    final = []
    if np.sum(np.min(board,axis=1)==0)==r:
        return []
    b0 = np.array(board)
    b0[np.min(b0,axis=1)!=0] = 0
    final.append(b0)
    i = r-1
    top0 = b0[np.sum(b0,axis=1)==0]
    r0 = top0.shape[0]
    b1 = np.array(b0)
    while i!=0:
        if np.sum(b1[i]!=0)==0:
            b1[1:i+1] = b1[0:i]
            b1[0] = 0
            b2 = np.array(b1)
            final.append(b2)
        if np.sum(b1[i]!=0)==0:
            b1[1:i+1] = b1[0:i]
            b1[0] = 0
            b2 = np.array(b1)
            final.append(b2)
        if np.min(b1[0:r0]==top0):
            break
        i-=1
    return final

xxx016xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 740, 'const': 324, 'code+const': 1064}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 9)], [('While', 14)]]
import numpy as np
def get_score(board):
    a = np.min(board , axis = 1)
    b = np.ones( (board.shape[0]), int)
    b = b*40
    tf = a > 0
    return np.sum(b[tf])
def get_time_cap(board, time_caps):
    tung = np.max(board , axis = 1)
    if np.max(tung) == 0:
        return time_caps[-1]
    else:
        tf = tung > 0
        reang = np.arange(board.shape[0])
        b = reang[tf]
        m = b[0]
        return time_caps[m// (board.shape[0] // len(time_caps))]
def rotate_right(shape):
    t = shape.T
    return(t[: , ::-1 ])
def rotate_left(shape):
    t = shape.T
    return(t[::-1 , : ])
def animate_drop(board, shape, c):
    copy_board = np.array(board)
    new_board = np.array(board)
    copy_shape = np.array(shape)
    nver = copy_shape.shape[0]
    nhor = copy_shape.shape[1]
    out = []
    for i in range(copy_board.shape[0] - nver + 1):
        new_board[i:i + nver , c:c + nhor] += copy_shape
        if np.sum(np.ones_like(copy_board , int)[new_board*copy_board == copy_board*copy_board]) == copy_board.shape[0]*copy_board.shape[1]:
            out.append(new_board)
        else:
            break
        new_board = np.array(board)
    return out
def animate_clear(board):
    copy_board = np.array(board)
    tung = np.min(copy_board , axis = 1)
    tf = tung > 0
    if np.sum(tung) == 0:
      return []
    else:
      copy_board[tf] = np.zeros_like(copy_board[tf])
      out = []
      out.append(np.array(copy_board))
      n = copy_board.shape[0] - 1
      zerow = np.zeros_like(copy_board[0])
      while n != 0:
          if np.sum(copy_board[n]) == 0:
              top = copy_board[:n]
              if np.sum(top) != 0:
                  copy_board[1:n+1] = top
                  copy_board[0] = zerow
                  out.append(np.array(copy_board))
              else:
                  break
          else:
              n -= 1
      return out

xxx034xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[56, 56, 56, 56, 45, 45, 456]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1036, 'const': 382, 'code+const': 1418}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 15)]]
import numpy as np
def get_score(board):
    x = (board != 0)
    s = x.sum(axis = 1)
    return sum(s == x.shape[1]) * 40
def get_time_cap(board, time_caps):
    s = (board != 0)
    su = s.sum(axis = 1)
    p = (su != 0)
    pos = np.argmax(p)
    if pos == 0:
      return time_caps[-1]
    n = p.shape[0] // len(time_caps)
    return time_caps[pos // n]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    List = []
    for i in range(board.shape[0]-shape.shape[0]+1):
      x = np.array(board)
      y = np.array(shape)
      sy1,sy2 = y.shape
      s = np.array(x[:,c:c+sy2])
      cx = (s[i:i+sy1,:sy2] == 0)
      sss = (~cx).sum(axis = 1)
      if sss.max() > 0:
        poss = sss.argmax()
        cx[poss:,:sss.max()] = False
      cy = (shape != 0)
      a = (cx & cy == cy)
      if np.sum(a) == (sy1 * sy2):
        s[i:i+sy1,:sy2] += y
        x[:,c:c+sy2] = np.array(s)
        List.append(x)
      if len(List) == 0:
        break
    return List
def animate_clear(board):
    List = []
    x = np.array(board)
    p = (x == 0)
    s = p.sum(axis = 1)
    if sum(s==0) == 0:
      return List
    a = np.arange(x.shape[0])[s == 0]
    x[a,:] = np.zeros(x.shape[1],int)
    List.append(x)
    nn = x.shape[0]
    i = -1
    c = 0
    while True:
        if c - i == nn:
            break
        x = np.array(List[-1])
        if sum(x[i]) == 0:
            d = np.ndarray((x.shape[0],x.shape[1]),int)
            if i == -1:
                d[1:,:] = np.array(x[:-1,:])
                d[0,:] = np.zeros(x.shape[1],int)
                c += 1
            else:
                d[-1:i:-1,:] = np.array(x[-1:i:-1,:])
                d[i:0:-1,:] = np.array(x[i-1::-1,:])
                d[0,:] = np.zeros(x.shape[1],int)
                c += 1
            List.append(d)
        else:
            i -= 1
    return List

xxx018xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 788, 'const': 228, 'code+const': 1016}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [], [('all', 8)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 12)]]
import numpy as np
def get_score(board):
  return ((board != 0).sum(1) == board.shape[1]).sum() * 40
def get_time_cap(board, time_caps):
    r, c = board.shape
    l = np.arange(r)
    block_count = ((board != 0).sum(1) != 0)
    index = -1 
    if len(l[block_count]) != 0:
      index = l[block_count][0] // (r // len(time_caps))
    return time_caps[index]
def rotate_right(shape):
  return shape[::-1].T
def rotate_left(shape):
  return shape.T[::-1]
def animate_drop(board, shape, c):
    res = []
    shape_x, shape_y = shape.shape
    board_size = (board != 0).sum() + (shape != 0).sum()
    max_fall = board.shape[0] - shape_x
    for fall_count in range(max_fall+shape_x):
      new_board = np.zeros((board.shape[0]+shape_x - 1, board.shape[1]), int)
      new_board[shape_x-1:,:] = board
      new_board[fall_count:fall_count + shape_x,c:c+shape_y][shape != 0] = np.reshape(shape[shape!=0], (shape != 0).sum())
      if (new_board != 0).sum() != board_size:
        break
      res.append(new_board[shape_x-1:,:])
    if len(res) >= shape_x:
      return res[shape_x-1:]
    else: return []
def animate_clear(board):
    x, y = board.shape
    pointing_rows = x - 1
    new_board = np.array(board)
    new_board[((new_board !=0).sum(1) == y),:] = 0
    count_zero_lines = ((new_board == 0).sum(1) == y).sum()
    if (new_board == board).all(): return []
    res = [np.array(new_board)]
    if new_board[:count_zero_lines,:].sum() == 0:
      return res
    while True:
      pointing_row = new_board[pointing_rows]
      if (pointing_row==0).sum() == y:
        new_board[pointing_rows] = new_board[pointing_rows-1]
        new_board[pointing_rows-1] = np.zeros_like(pointing_row)
      pointing_rows -= 1
      if pointing_rows == 0 :
        res.append(np.array(new_board))
        if new_board[:count_zero_lines,:].sum() == 0:
          break
        else:
          pointing_rows = x -1
    return res    
    pass

xxx121xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 02, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 02],
       [1, 1, 0, 8, 8, 02],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0TypeError("'type' object is not subscriptable")
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0TypeError("'type' object is not subscriptable")
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0TypeError("'type' object is not subscriptable")
[[]]
bytecount: {'code': 580, 'const': 324, 'code+const': 904}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], []]
import numpy as np
def get_score(board):
  b=board
  a = b==0
  c = np.sum(a,axis=1)
  d = c==0
  e = np.sum(d,axis=0)
  return (e*40)
def get_time_cap(board, time_caps):
    t = time_caps
    b=board
    r,c = b.shape
    a = b.reshape(len(t),int(r*c/len(t)))
    e = np.sum(a,axis=1)
    r1 = np.arange(len(e))
    k = e!=0
    n= r1[k]
    if sum(e) != 0:
        return (t[n[0]])
    else: return (t[-1])
def rotate_right(shape):
    s=shape
    rr = s[::-1,:]
    return rr.T
def rotate_left(shape):
    s=shape
    rl = s[:,::-1]
    return rl.T
def animate_drop(board, shape, c):
    l=[]
    r,s = board.shape
    test = np.zeros((r,s),int)
    for i in range(r):
        new_board = np.array(board)
        new_shape = np.array(shape)
        if len(new_board[i,c:])==new_shape.shape[1] and list(new_board[i,c:])==list(test[i,c:]):
            new_board[i,c:]=new_shape[0,:]
            l.append(new_board)
    return l
def animate_clear(board):
  r,s = board.shape
  new_board = np.array(board)
  te1= new_board==0
  te2 = np.sum(te1,axis=1)
  te3 =te2!=0
  new = te3.reshape(r,1)*new_board
  return list[new]

xxx024xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 956, 'const': 338, 'code+const': 1294}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('For', 24)]]
import numpy as np
def get_score(board):
  a = board > 0
  b = np.sum(a,axis = 1)
  c = b == a.shape[1]
  s = np.ones((a.shape[0],1),int)
  return np.sum(s[c]*40)
def get_time_cap(board, time_caps):
  a = board != 0
  b = np.sum(a,axis=1)
  c = b != 0
  s = np.arange(a.shape[0])
  s = s[c]
  if len(s) == 0:
    return time_caps[-1]
  k = s[0] // (a.shape[0]//len(time_caps))
  return(time_caps[k])
def rotate_right(shape):
  a = shape.T
  return a[:,::-1]
def rotate_left(shape):
  a = shape.T
  return a[::-1,:]
def animate_drop(board, shape, c):
  a = np.zeros_like(board,int)
  b = []
  for i in range(a.shape[0]):
    if i < shape.shape[0]-1:
      x = board[:i+1,c:shape.shape[1]+c] == 0
      y = shape[shape.shape[0]-i-1:] != 0
      z = x & y
      if np.sum(z) != np.sum(y):
        return(b)
    else:
      a[i-shape.shape[0]+1:i+1,c:shape.shape[1]+c] = shape
      d = board + a
      x = d[i-shape.shape[0]+1:i+1,c:shape.shape[1]+c] == shape
      y = shape != 0
      z = x & y
      if np.sum(z) == np.sum(y):
        b.append(d)
        a = np.zeros_like(board,int)
      else:
        break
  return(b)
def animate_clear(board):
  z = []
  nboard = np.array(board)
  a = np.sum(board!=0,axis = 1)
  b = a == board.shape[1]
  d = np.arange(board.shape[0])
  e = d[b]
  nboard[e] = 0
  x = np.array(nboard)
  if len(e) != 0:
    z.append(x)
  else:
    return(z)
  c = np.sum(nboard!=0,axis = 1)
  if np.sum(nboard) == 0:
    return z
  f = c == 0
  g = d[f]
  h = d[(~f)]
  j = g > h[0]
  g = g[j]
  k = np.arange(len(g))
  g = g[::-1] + k
  for i in g:
    nboard[1:i+1] = nboard[:i]
    nboard[0] = 0
    x = np.array(nboard)
    z.append(x)
  return(z)

xxx219xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score0.0
[40, 4120]
test_get_time_cap0.0
[56, 56, 56, 56, 45, 45, 456]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (3,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (3,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (2,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 764, 'const': 352, 'code+const': 1116}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('For', 15)]]
import numpy as np
def get_score(board):
    res= np.sum(board>0,axis=1)
    return sum(res==5)*40
def get_time_cap(board, time_caps):
    r,c = board.shape
    p = r//len(time_caps)
    s = board.sum(axis=1)
    pos = np.arange(r)
    pos = pos[s!=0]
    if pos.shape[0]!= 0 and pos[0] != 0:
        return time_caps[pos[0]//p]
    else:
        return time_caps[-1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    if c > board.shape[1]-shape.shape[1] or board.shape[1] < shape.shape[1]:
        return []
    out = []
    l_s = shape.shape[1]
    for i in range(board.shape[0]):
        new_board = np.array(board)
        if np.sum(new_board[i,c:c+l_s])==0:
            new_board[i,c:c+l_s] = shape
            out.append(new_board)
        else:
            break
    return out
def animate_clear(board):
    out = []
    r,c = board.shape
    new_board = np.array(board)
    s = np.sum(new_board>0,axis=1)
    pos = np.arange(r)[s==c]
    if pos.shape[0] == 0:
      return out
    new_board[pos] = 0
    f = np.array(new_board)
    out.append(f)
    s = np.sum(new_board==0,axis=1)
    pos = np.arange(r)[s==c][::-1]
    for e in range(pos.shape[0]):
      s = np.sum(new_board==0,axis=1)
      pos = np.arange(r)[s==c][::-1]
      new_board[1:pos[0]+1] =  new_board[0:pos[0]]
      new_board[0,:] = 0
      x = np.array(new_board)
      if np.sum(x[:pos[0]+1]!=0)==0:break 
      out.append(x)
    return out

xxx022xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[56, 56, 56, 56, 45, 45, None45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 910, 'const': 366, 'code+const': 1276}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 14)], [('While', 12)]]
import numpy as np
def get_score(board):
    A = np.min(board,axis = 1)
    B = A//1 != 0
    C = sum(B)*40
    return C
def get_time_cap(board, time_caps):
    A = np.max(board, axis = 1)
    if sum(list(A)) != 0 and 0 in A:
        i = abs(list(A)[::-1].index(0)-board.shape[0]) 
        g = board.shape[0]//len(time_caps)
        n = (i+g)// g 
        return time_caps[n-1]
    if 0 not in A:
        pass 
    else:
        return time_caps[-1]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    zenbu = []
    ros,cos = shape.shape[0],shape.shape[1]
    new_board = np.array(board)
    B = new_board[:ros,c:c+cos] != 0
    S = shape != 0
    d = {}
    if True in B&S:
        return []
    else:
        new_board[:ros,c:c+cos] += shape
        zenbu.append(new_board)
        d[ros-1] = new_board
        for i in range(ros,board.shape[0]):
            B = board[i-(ros-1):i+1,c:c+cos] != 0
            if True in B&S:
                break
            else:
                d[i] = np.array(d[i-1])
                d[i][i-ros:i,c:c+cos] -= shape
                d[i][i-(ros-1):i+1,c:c+cos] += shape
                zenbu.append(d[i])
    return zenbu
def animate_clear(board):
    new_board = np.array(board)
    B = np.min(board,axis=1) != 0
    zenbu = []
    if True in B:
        new_board[B] *= 0
        zenbu.append(np.array(new_board))
    else:
        return []
    rest = np.sum(np.sum(new_board, axis =1) != 0)
    p = np.arange(len(board))
    while True:
        i = np.sum(new_board,axis =1) == 0
        move = p[i][-1]
        if move != len(board):
            new_board[1:move+1] = new_board[0:move]
            new_board[0] = 0
            zenbu.append(np.array(new_board))
        if np.sum(np.sum(new_board[-rest:],axis =1)!= 0) == rest:
            break
    return zenbu

xxx200xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[array([[2, 0, 0, 0],
       [1, 0, 1, 1]])],
 [array([[0, 2, 0, 0],
       [1, 0, 1, 1]]), array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 0, 05, 5, 0, 0, 0],
       [0, 1, 1, 0, 0, 0, 0, 0],
       [0, 2, 2, 2, 0, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]]),
  array([[01, 1, 0, 5, 5, 0, 0, 0],
       [0, 1, 1, 0, 5, 0, 0, 0],
       [0, 2, 2, 2, 05, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[0, 0, 2, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 0, 0, 2, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 2, 2, 2, 0, 0 ... (more)
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 2, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 0, 0, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1088, 'const': 384, 'code+const': 1472}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 23)], [('While', 16)]]
import numpy as np
def get_score(board):
    a = (board != 0).sum(axis=1)
    b = a[a == board.shape[1]]
    return b.shape[0] * 40
def get_time_cap(board, time_caps):
    if board.reshape(board.shape[0] * board.shape[1]).sum() != 0:
        a = (board != 0).sum(axis=1)
        b = np.arange(a.shape[0])
        row = b[a != 0][0] + 1
        c = len(time_caps)
        d = board.shape[0]
        e = np.arange(int(d/c),d+1,int(d/c))
        f = np.arange(e.shape[0])
        g = f[e >= row][0]
        return time_caps[g]
    return time_caps[-1]
def rotate_right(shape):
    a = shape.T
    return a[::,::-1]
def rotate_left(shape):
    a = shape.T
    return a[::-1,:]
def animate_drop(board, shape, c):
    a = shape.shape[1]
    b = board[::,c:c+a]
    d = b != 0
    stop = d.argmax(axis=0)
    e = shape[::-1,:]
    f = e != 0
    g = f.argmax(axis=0)
    stop = stop + g
    h = b == 0
    l = h.sum(axis=0)
    m = np.arange(l.shape[0])
    n = board.shape[0]
    o = m[l == n]
    p = np.zeros_like(stop)
    p[o] = n
    stop = stop + p
    stop = stop.min()
    new = np.zeros_like(board)
    j = -1
    k = 0
    r = []
    for i in range(stop):
        new = np.zeros_like(board)
        new[0+k:i+1,c:c+a] = shape[j:]
        j -= 1
        if i + 1 >= shape.shape[0]:
            k += 1
        out = board + new
        r.append(out)
    return r
def animate_clear(board):
    r = []
    a = board != 0
    b = a.sum(axis=1)
    c = np.arange(b.shape[0])
    d = c[b != board.shape[1]]
    new = np.zeros_like(board)
    new[d,:] = board[d,:]
    if (new != board).sum(axis=0).sum() == 0:
        return []
    else:
        r.append(new)
        i = -1
        out = np.array(new)
        zero = np.zeros_like(out[0])
        while True:
            if i == -1:
                check = np.array(out)
            e = out[i]
            f = e != 0
            g = f.sum()
            if g == 0 and i > -new.shape[0]:
                out[i] = out[i-1]
                out[i-1] = zero
            i -= 1
            h = out != check
            l = h.sum(axis=0)
            m = l.sum()
            if i == -new.shape[0] and m == 0:
                break
            elif i == -new.shape[0]:
                i = -1
                z = np.array(out)
                r.append(z)
        return r

xxx017xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (3,3) (2,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 976, 'const': 370, 'code+const': 1346}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 17)], [('While', 21)]]
import numpy as np
def get_score(board):
    mins = np.min(board, axis=1)
    nozero = mins[ mins>0 ]
    return len(nozero)*40
def get_time_cap(board, time_caps):
    maxs = np.max(board, axis=1)
    have = np.arange(0,len(maxs))[ maxs>0 ]
    if len(have) == 0:
        return time_caps[-1]
    else:
        n = board.shape[0] // len(time_caps)
        return time_caps[have[0]//n]
def rotate_right(shape):
    return shape.T[:, ::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    s = shape>0
    s1 = np.sum(s, axis=0)
    s2 = np.sum(s, axis=1)
    srows = shape.shape[0]
    rows = int(srows)
    scols = shape.shape[1]
    start = 0
    place = board[start:srows, c:c+scols]
    p = place<1
    t = s&p
    t1 = np.sum(t, axis=0)
    t2 = np.sum(t, axis=1)
    row = (s1==t1)
    col = (s2==t2)
    result = []
    while (np.sum(row) == scols) and (np.sum(col) == rows):
        new_board = np.array(board)
        new_board[start:srows, c:c+scols] += shape
        result.append(new_board)
        start += 1
        srows += 1
        place = board[start:srows, c:c+scols]
        p = place<1
        t = s&p
        t1 = np.sum(t, axis=0)
        t2 = np.sum(t, axis=1)
        row = (s1==t1)
        col = (s2==t2)
    return result
def animate_clear(board):
    mins = np.min(board, axis=1)
    nozero = np.arange(0,len(mins))[mins>0]
    result = []
    if len(nozero) == 0:
        return result
    else:
        new_board = np.array(board)
        new_board[nozero] = 0
        result.append(new_board)
        nboard = np.array(new_board)
        maxs = np.max(nboard, axis=1)
        have = np.arange(0,len(maxs))[maxs>0]
        nboard = nboard[have[0]:]
        nmaxs = np.max(nboard, axis=1)
        nallzero = np.arange(0,len(nmaxs))[nmaxs<1]
        drops = len(nallzero)
        allzero = np.arange(0,len(maxs))[maxs<1]
        s = 0
        count = 0
        while count < drops:
            new_board1 = np.array(new_board)
            new_board1[1:allzero[-1]+1] = new_board1[:allzero[-1]]
            new_board1[s] = 0
            result.append(new_board1)
            maxs = np.max(new_board1, axis=1)
            allzero = np.arange(0,len(maxs))[maxs<1]
            s += 1
            count += 1
            new_board = np.array(new_board1)
        return result

xxx029xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 01, 01]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 01, 01]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [01, 0, 02, 04],
       [10, 0, 21, 41]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 922, 'const': 440, 'code+const': 1362}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 10)], [('While', 15)]]
import numpy as np
def get_score(board):
    yo = np.sum((board > 0), axis = 1)
    final = np.sum(((yo == board.shape[1])), axis = 0)
    final = final * 40
    return final
def get_time_cap(board, time_caps):
    if board.shape != (0,):
        yo = np.sum((board > 0), axis = 1)
        final = yo > 0
        if True in final:
            pattern = len(board) // len(time_caps)
            hey = np.arange(len(board))
            hey = list(hey[final])
            finale = time_caps[hey[0] // pattern]
        elif True not in final:
            finale = time_caps[-1]
    else:
        finale = time_caps[-1]
    return finale
def rotate_right(shape):
    one = np.array(shape[::-1,...])
    one = one.T
    return one
def rotate_left(shape):
    one = np.array(shape[...,::-1])
    one = one.T
    return one
def animate_drop(board, shape, c):
    final = []
    new_board = np.array(board)
    new_shape = np.array(shape)
    comparing = new_shape > 0
    twocom = np.zeros_like(new_shape,int)[comparing]
    num = new_shape[comparing]
    if c <= (new_board.shape[1] - shape.shape[1]):
        for i in range(0,len(new_board) - shape.shape[0] + 1):
            if np.sum(new_board[i:i+shape.shape[0], c:c+shape.shape[1]][comparing] > 0) == 0:
                mid = np.array(new_board)
                mid[i:i+shape.shape[0], c:c+shape.shape[1]][comparing] = num[0]
                final.append(mid)
            else:
                break
    return final
def animate_clear(board):
    final = []
    new_board = np.array(board)
    allzero = np.array([0] * board.shape[1])
    yay = new_board > 0
    yay = np.sum(yay,axis = 1) >= board.shape[1]
    turning = np.arange(len(yay))[yay]
    if turning.shape != (0,):
        new_board[turning] = allzero
        final.append(new_board)
    wait = ~(np.sum(new_board > allzero , axis = 1) > 0)
    wait = np.sum(wait)
    newer_board = np.array(new_board)
    while np.sum(newer_board[:wait,...] != np.zeros((wait,board.shape[1]))) > 0:
        newer_board = np.array(newer_board)
        findzeros = newer_board > 0
        findzeros = ~(np.sum(newer_board,axis = 1) >= board.shape[1])
        posi = np.arange(0,len(findzeros))[findzeros]
        where = posi[-1]
        newer_board[1:where+1] = newer_board[0:where]
        newer_board[0] = allzero
        final.append(newer_board)
    return final

xxx035xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 746, 'const': 338, 'code+const': 1084}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 5)], [('While', 9)]]
import numpy as np
def get_score(board):
    return np.sum(np.min(board != 0, axis=1) * 40)
def get_time_cap(board, time_caps):
    return time_caps[np.argmax(np.max(board != 0, axis=1)) // (board.shape[0] // len(time_caps))] if np.sum(board != 0) else time_caps[-1]
def rotate_right(shape):
    return shape.T[:, ::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    drop_animation = []
    d = 1 - shape.shape[0]
    while True:
        if d < 0:
            if not np.min((board[:d + shape.shape[0], c:c + shape.shape[1]] == 0) | (shape[-d:] == 0)):
                return []
        else:
            if d + shape.shape[0] <= board.shape[0] and np.min((shape == 0) | (board[d:d + shape.shape[0], c:c + shape.shape[1]] == 0)):
                copy_board = np.array(board)
                copy_board[d:d + shape.shape[0], c:c + shape.shape[1]] += shape
                drop_animation.append(copy_board)
            else:
                return drop_animation
        d += 1
def animate_clear(board):
    if np.min(np.max(board == 0, axis=1)):
        return []
    clear_animation = []
    new_board = board * np.max(board == 0, axis=1).reshape((board.shape[0], 1))
    clear_animation.append(new_board)
    d = new_board.shape[0] - np.argmax(np.min(new_board == 0, axis=1)[::-1]) - 1
    while np.sum(new_board[:d] != 0):
        new_board = np.array(new_board)
        new_board[1:d + 1] = new_board[:d]
        new_board[0] = 0
        clear_animation.append(new_board)
        d = new_board.shape[0] - np.argmax(np.min(new_board == 0, axis=1)[::-1]) - 1
    return clear_animation

xxx209xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[56, 56, 56, 456, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 654, 'const': 322, 'code+const': 976}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 10)]]
import numpy as np
def get_score(board):
    return np.sum(np.min(board, axis=1)!=0)*40
def get_time_cap(board, time_caps):
    a = np.sum(np.sum(board, axis=1)==0)
    if a == 0:
        return (time_caps[int(int((a)*len(time_caps)/len(board)))])
    else:
        return (time_caps[int(int((a-1)*len(time_caps)/len(board)))])
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    ans = []
    row,col = np.shape(shape)
    for i in range(len(board)-(row-1)):
        check = board[i:i+row,c:c+col]*shape
        newboard = np.array(board)
        newboard[i:i+row,c:c+col] += shape
        if np.max(check) == 0:
            ans.append(newboard)
        else:
            break
    return ans
def animate_clear(board):
    ans = []
    count = 0
    newboard = np.array(board)
    x = np.min(board,axis=1) != 0
    newboard[x] = np.zeros(np.shape(board)[1])
    ans.append(newboard)
    i = len(board)-1
    while i>0:
        editboard = np.array(newboard)
        if np.sum(newboard[i]) == 0:
            editboard[1:i+1] = newboard[0:i]
            editboard[0] = np.zeros(np.shape(board)[1])
            if np.sum(editboard != newboard) == False:
                break
            newboard = editboard
            count += 1
            ans.append(newboard)
        else:
            i -= 1
    if count == 0:
        return []
    return ans

xxx202xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1122, 'const': 518, 'code+const': 1640}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 9)], [('While', 10)]]
import numpy as np
def get_score(board):
  b = np.min(board, axis = 1)
  c = b > 0
  d = np.sum(c)
  return d*40
def get_time_cap(board, time_caps):
  b = np.max(board, axis = 1)
  c = b > 0
  if not True in c:
    ans = time_caps[-1]
    return ans
  else:
    d = np.argmax(c)
  t1 = len(time_caps)
  t2 = len(board)
  t = t2 / t1
  d = int(d//t)
  ans = time_caps[d]
  return ans
def rotate_right(shape):
  t = shape.T
  right = t[::1,::-1]
  return np.array(right)
def rotate_left(shape):
  t = shape.T
  left = t[::-1,::1]
  return np.array(left)
def animate_drop(board, shape, c):
  ans = []
  s1 = len(shape)
  s2 = len(shape[0])
  ch = 0
  c_board = (board[0:s1-1,c:c+s2] * shape[-1]) > 0
  if True in c_board :
    return []
  for i in range(len(board)-s1+1):
    new_board = np.array(board)
    c_shape = shape > 0
    c_board = board[i,c:c+s2] > 0
    check = board[i:i+s1,c:c+s2] > 0
    checkk = (c_shape%2) + (check%2)
    check2 = checkk < 2 
    if not False in check2 and ch == 0 and not True in c_board:
      new_board[i:i+s1,c:c+s2] += shape
      ans.append(new_board)
    else :
      ch = 2
  return ans
def animate_clear(board):
  i,c,c1 = 0,0,0
  f = len(board)
  f1 = len(board[0])
  ro = list(range(0, f))
  l1,med = 0,0
  a = {}
  new_board = np.array(board)
  ans = []
  while True:
    if c == 0:
      check = board[i] > 0
      if not False in check :
        new_board[i] = np.zeros(len(board[i]))
        ro.remove(i)
        c1 = 1
      if not True in check :
        ro.remove(i)
      i+=1
      if i >= len(board):
        c = 1
        new = np.array(new_board)
        n = np.array(new)
        if c1 != 0 :
          ans.append(n)
    elif c == 1 :
      if len(ro) == 0:
        c = 2
        break
      if ro[-1] == f-1:
        ro.remove(ro[-1])
        f-=1
        med,l1 = 0,0
        a = {}
      else:
        if med == 0:
          l = len(ro)
          a[ro[l1]] = new[ro[l1]]
          l1+=1
          if l1 == l:
            med = 1
            l1 = len(ro)-1
        if med == 1:
          new[ro[l1]+1] = a[ro[l1]]
          new[ro[l1]] = np.zeros(f1)
          a[ro[l1]+1] = a[ro[l1]]
          ro[l1]+=1
          l1-=1
          if l1 < 0:
            med = 0
            l1 = 0
            n=np.array(new)
            ans.append(n)
    else :
      break
  return ans

xxx034xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 822, 'const': 350, 'code+const': 1172}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('While', 7)]]
import numpy as np
def get_score(board):
    board_min = np.min(board,axis=1)
    board_min = board_min != 0
    score = np.sum(board_min) * 40
    return score
def get_time_cap(board, time_caps):
    board_max = np.max(board,axis=1) == 0
    is_all_zero = all(board_max)
    if is_all_zero:
        return time_caps[-1]
    index = np.argmax(board_max == False)
    c = len(board)//len(time_caps)
    time_cap = time_caps[index//c]
    return time_cap
def rotate_right(shape):
    shape = shape.T
    return shape[:,::-1]
def rotate_left(shape):
    shape = shape.T
    return shape[::-1,:]
def animate_drop(board, shape, c):
    res = []
    shape_size = shape.shape
    for i in range(1-shape_size[0],len(board)+1-shape_size[0]):
        myboard = np.array(board)
        myshape = np.array(shape)
        if i < 0:
            sliced = myboard[0:shape_size[0]+i,c:c+shape_size[1]]
            sliced_sum = sliced.sum()
            sliced_shape = myshape[-i:,:]
            myshape_sum = sliced_shape.sum()
            sliced[sliced_shape != 0] = sliced_shape[sliced_shape != 0]
            if sliced.sum() == sliced_sum + myshape_sum:
                pass
            else:
                break
        else:
            sliced = myboard[i:i+shape_size[0],c:c+shape_size[1]]
            sliced_sum = sliced.sum()
            myshape_sum = myshape.sum()
            sliced[shape != 0] = shape[shape != 0]
            if sliced.sum() == sliced_sum + myshape_sum:
                res.append(myboard)
            else:
                break
    return res
def animate_clear(board):
    res = []
    myboard = np.array(board)
    shape = myboard.shape
    i=0
    while True:
        before = np.array(myboard)
        myboard = np.array(myboard)
        full_row = myboard.min(axis=1) != 0
        if any(full_row):
            myboard[myboard.min(axis=1) != 0] = 0
        elif any(myboard.max(axis=1) == 0):
            index = shape[0] - (myboard[::-1,:].max(axis=1)).argmin() - 1
            myboard[1:index+1,:] = myboard[0:index,:]
            myboard[0,:] = 0
        if (before == myboard).min() == 1:
            break
        res.append(myboard)
        i+=1
    return res

xxx019xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 872, 'const': 352, 'code+const': 1224}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 11)]]
import numpy as np
def get_score(board):
  checkall = board != 0
  sumtrue = np.sum(checkall,axis=1)
  nozero = sumtrue == board.shape[1]
  score = np.sum(nozero,axis=0) * 40
  return score
def get_time_cap(board, time_caps):
  time = board.shape[0]//len(time_caps)
  checkall = board != 0
  sumnozero = np.sum(checkall,axis=1)
  ind = np.arange(sumnozero.shape[0])[sumnozero!=0]
  if len(ind) != 0:
    row = np.min(ind)
    indexcaps = row//time
  else:
    indexcaps = -1
  return time_caps[indexcaps]
def rotate_right(shape):
  s1 = shape[::-1,::]
  return s1.T
def rotate_left(shape):
  s1 = shape[::,::-1]
  return s1.T
def animate_drop(board, shape, c):
    rowshape = shape.shape[0]
    colshape = shape.shape[1]
    out = []
    number = np.sum(board != 0) + np.sum(shape != 0)
    for i in range(-1*rowshape,board.shape[0]-rowshape+1):
      new_board = np.array(board)
      if i<0:
         new_board[0:-i,c:c+colshape] += shape[i:]
         if number-np.sum(shape[:i]!=0) != np.sum(new_board!=0):
           return []
      else:
        new_board[i:i+rowshape,c:c+colshape] += shape
        if number != np.sum(new_board!=0):
          break
        out.append(np.array(new_board))
    return out
def animate_clear(board):
    nozero = np.sum(board ==0,axis=1)
    clear_row = nozero == 0
    new_board = np.array(board)
    new_board[clear_row,:] = 0
    out = []
    out.append(np.array(new_board))
    havenum = np.sum(new_board,axis=1) !=0
    n = np.sum(havenum)
    row = np.arange(new_board.shape[0])
    while True:
      zero = np.sum(new_board,axis=1) ==0
      if np.sum(zero) ==0 :
        return []
      lastr = row[zero][-1]
      if lastr != new_board.shape[0]:
        new_board[1:lastr+1,::] = new_board[:lastr,::]
        new_board[0,::] = 0 
        out.append(np.array(new_board))
      if np.sum(new_board[:new_board.shape[0]-n,::]) == 0:
        break
    return out

xxx218xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 850, 'const': 352, 'code+const': 1202}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 6)], [('While', 12)]]
import numpy as np
def get_score(board):
  return sum(np.min(board,axis=1) != 0)*40
def get_time_cap(board, time_caps):
  a = len(board) ; b = len(time_caps)
  if  True in list(np.max(board,axis=1) != 0): m = list(np.max(board,axis=1) != 0).index(True)
  else: return time_caps[-1]
  return time_caps[(int((m+1)/(a/b)) if (m+1)/(a/b)%1 == 0 else int((m+1)/(a/b)+1))-1]
def rotate_right(shape):
  return np.array(shape[::-1]).T
def rotate_left(shape):
  return np.array(shape[:]).T[::-1]
def animate_drop(board, shape, c):
  b = np.array(board)
  k = np.sum(b > 0) + np.sum(shape > 0)
  p=[];count = 0
  while True:
    b = np.array(board)
    if count < len(board)-(len(shape)-1):
      b[count:count+shape.shape[0],c:c+shape.shape[1]] += shape
    if np.sum(b > 0) != k:
      break
    bb = np.array(b)
    p.append(np.array(bb))
    count += 1
  return p
def animate_clear(board):
  b = np.array(board)
  b[np.min(board,axis=1) != 0] = [0]
  bb = np.array(b)
  k = -1;p = []
  c = (sum(np.sum(bb, axis=1)==0))
  if c == 0: return []
  p.append(bb)
  if sum(np.sum(bb[:c], axis=1)==0) == c:
    return p
  while True:
    if np.max(b[k]) == 0:
      if k != -1:
        b[1:k+1] = b[:k]
      else:
        b[1:] = b[:k]
      b[0] = [0]
      bb = np.array(b)
      k = 0
      p.append(bb)
      if list(np.array(sorted(list(np.sum(p[0],axis=1))))==0) == list(np.array((list(np.sum(p[-1],axis=1))))==0):
        break
    k -= 1
  return p

xxx215xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 830, 'const': 354, 'code+const': 1184}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 13)]]
import numpy as np
def get_score(board):
  new_board = np.array(board)
  l= np.min(new_board,axis=1)
  k= np.sum(l != 0)*40
  return k
def get_time_cap(board, time_caps):
  new_board = np.array(board)
  l= np.max(new_board,axis=1)
  n= np.arange(len(l))
  ln= n[l != 0]
  if len(ln) != 0:
    ln = int(ln[0])
    i = len(board)//len(time_caps)
    p = round((ln+1)/i + 0.4)
    return time_caps[p-1]
  else:
    return time_caps[-1]
def rotate_right(shape):
  new_shape = np.array(shape.T[::,::-1])
  return new_shape
def rotate_left(shape):
  new_shape = np.array(shape.T[::-1,::])
  return new_shape
def animate_drop(board, shape, c):
  lo,le=shape.shape
  new_board = np.array(board)
  new_shape = np.array(shape)
  l=[]
  n0= np.sum(new_board != 0) + np.sum(new_shape != 0)
  for i in range(len(new_board)+1-lo):
    new_new_board = np.array(board)
    new_new_board[i:i+lo,c:c+le] += shape
    if np.sum(new_new_board != 0) != n0:
      break
    l.append(np.array(new_new_board))
  return l
def animate_clear(board):
  nb=np.array(board)
  n= np.arange(len(nb))
  r=[]
  k=1
  j=0
  new_board = np.array(board)
  l= np.min(new_board,axis=1)!=0
  new_board[l]=0
  s=np.sum(np.sum(new_board,axis=1)!=0)
  r.append(np.array(new_board))
  while True:
    i = np.sum(new_board,axis=1) == 0
    if np.sum(i) == 0:
      return []
    u=n[i][-1]
    if u != len(nb):
      new_board[k:u+k] = new_board[j:u]
      new_board[0]=0
      jjj = np.array(new_board)
      if np.sum(jjj == r[0]) == jjj.shape[0] * jjj.shape[1]:
        return r 
      r.append(jjj)
    if np.sum(np.sum(new_board[-s:],axis=1)!= 0) == s:
      break
  return r

xxx029xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 332, 'const': 240, 'code+const': 572}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
import numpy as np
def get_score(board):
    g= np.min(board, axis=1)
    pos = np.arange(g.shape[0])
    t= pos[ g==0 ]
    h= board[t,:]
    m= h.shape[0]
    b= board.shape[0]
    w= (b-m)*40
    return w
def get_time_cap(board, time_caps):
  q= len(time_caps)
  row= board.shape[0]
  le= row//q
  pos = np.arange(0,row)
  su= np.sum(board, axis=1)
  if pos[su>0].shape[0]==0:
    return time_caps[-1]
  posrow= pos[su>0][0]
  f= posrow//le
  return time_caps[f]
def rotate_right(shape):
    f= shape.T[:,::-1]
    return f
def rotate_left(shape):
    g= shape.T[::-1]
    return g
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
    pass

xxx035xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 982, 'const': 348, 'code+const': 1330}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 14)], [('For', 19)]]
import numpy as np
def get_score(board):
    a = 0 != board
    b = a==False
    c = np.sum(b,axis=1)
    d = c==0
    e = c[list(d)]
    return len(e)*40
def get_time_cap(board, time_caps):
    a = 0 != board
    b = 0 != np.sum(a,axis=1)
    nrow = board.shape[0]
    ncol = board.shape[1]
    n = len(time_caps)
    c = nrow-len(b[list(b)])
    if len(b[list(b)])==0:
        return time_caps[-1]
    return time_caps[c//int(nrow/n)]
def rotate_right(shape):
    rotate_right = shape[::-1]
    return rotate_right.T
def rotate_left(shape):
    rotate_left = shape.T[::-1]
    return rotate_left
def animate_drop(board, shape, c):
    nrow_board = board.shape[0]
    ncol_board = board.shape[1]
    nrow_shape = shape.shape[0]
    ncol_shape = shape.shape[1]
    animate_drop = []
    n=0
    m=nrow_board-nrow_shape
    if str(board[0:nrow_shape,c:ncol_shape+c])!=str(np.zeros((nrow_shape,ncol_shape),int)):
        return animate_drop
    board_for_shape = np.zeros((nrow_board,ncol_board),int)
    board_for_shape[n:nrow_shape+n,c:ncol_shape+c] = shape
    for b in board[0:m+1]:
        value_board1 = np.sum(0!=shape)
        value_board2 = np.sum(0!=(board[n:nrow_shape+n,c:ncol_shape+c]))
        sum_part = np.sum(0!=(board[n:nrow_shape+n,c:ncol_shape+c]+shape))
        if value_board2+value_board1==sum_part:
            board_for_shape = np.zeros((nrow_board,ncol_board),int)
            board_for_shape[n:nrow_shape+n,c:ncol_shape+c] = shape
            animate_drop.append(board+board_for_shape)
            n+=1
    return animate_drop
def animate_clear(board):
    nrow_board = board.shape[0]
    ncol_board = board.shape[1]
    n=0
    animate_clear = []
    if get_score(board)==0:
        return animate_clear
    a = 0 != board
    b = a==False
    c = np.sum(b,axis=1)
    d = c!=0
    e = np.zeros((nrow_board,ncol_board),int)+d.reshape((nrow_board,1))
    first_board = np.array(e*board)
    n = nrow_board-1
    board_clear = np.array(first_board)
    last_board_clear = np.ndarray((nrow_board,ncol_board),int)
    animate_clear.append(first_board)
    for b in first_board:
        if str(board_clear[n]) == str(np.array([0]*ncol_board)):
            board_clear[1:n+1] = board_clear[0:n]
            board_clear[0] = np.zeros((1,ncol_board),int)
            if str(last_board_clear) != str(np.array(board_clear)):
                animate_clear.append(np.array(board_clear))
            last_board_clear = np.array(board_clear)
        else:
            n-=1
    return animate_clear

xxx035xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[20, 2, 2, 02],
       [1, 02, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 02, 0, 0, 0],
       [0, 0, 02, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 02, 0, 8, 0],
       [1, 1, 02, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 02, 8, 8, 0],
       [1, 1, 02, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 02, 0, 0],
       [0, 0, 0, 02, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 2, 2, 2, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 2, 2, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [array([[0, 0, 2, 2, 2, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 02],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0,  ... (more)
test_animate_drop_30.0
[[],
 [array([[0, 2, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]]),
  array([[0, 0, 0, 0],
       [1, 1, 0, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 0, 0, 1],
       [1, 1, 1, 0]]),
  array([[0, 0, 0, 0],
       [1, 1, 0, 0],
       [1, 0, 2, 0],
       [1, 0, 0, 1],
       [1, 1, 1, 0]]),
  array([[0, 0, 0, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 0, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 0, 0],
       [1, 0, 2, 0],
       [1, 0, 0, 0],
       [1, 0, 0, 1],
       [1, 1, 1, 0]]),
  array([[0, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 0, 2, 0],
       [1, 0, 0, 1],
       [1, 1, 1, 0]]),
  array([[0, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 0, 0, 0],
       [1, 0, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 05, 05, 04],
       [01, 0, 05, 04],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 04],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 924, 'const': 390, 'code+const': 1314}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 9)], [('While', 15)]]
import numpy as np
def get_score(board):
    A = np.sum(0 != board,axis = 1)
    B = np.sum(len(board[0]) == A)*40
    return B
def get_time_cap(board, time_caps):
    A = np.arange(len(board))[np.sum(board,axis = 1) != 0]
    B = (A)//(len(board)/len(time_caps))
    if len(B) == 0 :
        return time_caps[-1]
    else :
        return time_caps[int(B[0])]
def rotate_right(shape):
    return shape.T[::,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    if c > len(board)-len(shape) or c < 0 :
        return []
    else :
        S = []
        q = 0
        k = 0
        while k <= len(board)-1 :
            new_board = np.array(board)
            new_shape = np.array(shape)
            if sum(board[[k],list(range(c,c+(len(shape.T)),1))] != 0) == 0 :
                new_board[[k],list(range(c,c+(len(shape.T)),1))] = new_shape.T[0:len(new_shape.T):1,0]
                q = q+1
                S.append(new_board)
            else :
                pass
            k = k+1
        if q == 0 :
            return []
        else :
            return S
def animate_clear(board):
    new_board = np.array(board)
    A = np.min(abs(new_board),axis = 1) != 0
    new_board01 = np.array(new_board)
    new_board01[np.arange(len(A))[A == 1]] = new_board01[np.arange(len(A))[A == 1]]*0
    if np.sum(new_board01 != new_board) == 0 :
        return []
    else :
        S = []
        S.append(new_board01)
        Q = np.array(new_board01)
        B = locate(new_board01)
        W = np.zeros_like(new_board01,int)
        while len(B) != 0 :
            R = np.zeros_like(Q,int)
            R[len(R)-1] = R[len(R)-1] + Q[len(R)-1]
            R[B+1] = R[B+1] + Q[B]
            S.append(R)
            W = np.array(R)
            Q = np.array(R)
            B = locate(Q)
        return S
def locate(board) :
    A = np.array(board)
    B = np.arange(len(A))[np.sum(abs(A),axis = 1) !=0]
    C = B[B < len(A)-1]
    D = C[np.sum(abs(A[C+1]),axis = 1) == 0]
    return D

xxx043xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (3,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (3,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (2,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 760, 'const': 324, 'code+const': 1084}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 10)], [('While', 11)]]
import numpy as np
def get_score(board):
    boards = board.min(axis=1)
    ck = boards[boards>0]
    return len(ck)*40
def get_time_cap(board, time_caps):
    ss = len(board)//len(time_caps)
    pos = np.arange(len(board))
    boards = board.max(axis=1)
    ck = pos[boards>0]
    pos = 0
    if len(ck)>0:
        pos = ck[0]
    else:
        pos=len(board)-1
    return time_caps[pos//ss]
def rotate_right(shape):
    shapes = shape
    shapes = shapes.T
    shapes = shapes[::,::-1]
    return shapes
def rotate_left(shape):
    shapes = shape
    shapes = shapes.T
    shapes = shapes[::-1,::]
    return shapes
def animate_drop(board, shape, c):
    boards = np.array(board)
    shapes = np.array(shape)
    col = board.shape[1]
    ck = np.arange(board.shape[0])
    ss = get_time_cap(board[::,c:c+shape.shape[1]:],ck)
    li = []
    cur=0
    while(ss>0):
        boards = np.array(board)
        boards[cur,c:c+shape.shape[1]:]=shape
        li.append(boards)
        ss-=1
        cur+=1
    return li
def animate_clear(board):
    po = np.arange(board.shape[0])
    ck = po[board.min(axis=1)>0]
    boards = np.array(board)
    boards[ck,::]=0
    li = []
    cs = len(po[boards.max(axis=1)==0])
    if cs>0:
        bs = np.array(boards)
        li.append(bs)
    while(cs>0):
        ck = po[boards.max(axis=1)==0][-1]
        tmp = np.array(boards[0:ck:,::])
        boards[1:ck+1:,::]=0
        boards[0,::]=0
        boards[1:ck+1:,::]=tmp
        if(sum(tmp.sum(axis=1))==0):
           break
        bs = np.array(boards)
        cs-=1
        li.append(bs)
    return li

xxx038xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 724, 'const': 338, 'code+const': 1062}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('While', 12)]]
import numpy as np
def get_score(board):
    POINT = 40
    s = np.min(board, axis=1)
    s = s[s > 0]
    s = (s // s) * POINT
    return np.sum(s)
def get_time_cap(board, time_caps):
    s = np.sum(board, axis=1)
    pos = np.arange(board.shape[0])[s == 0]
    pos = 0 if pos.shape[0] == 0 else pos[-1] + 1
    pos = pos // (board.shape[0] // len(time_caps))
    return time_caps[-1] if pos >= len(time_caps) else time_caps[pos]
def rotate_right(shape):
    return shape.T[:, ::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    animated = []
    board_row, _ = board.shape
    shape_row, shape_col = shape.shape
    for i in range(board_row-shape_row + 1):
        if np.sum(board[i:i+shape_row, c:c+shape_col] * shape) != 0:
            break
        new_board = np.array(board)
        new_board[i:i+shape_row, c:c+shape_col] += shape
        animated.append(new_board)
    return animated
def animate_clear(board):
    animated = []
    board_row, board_col = board.shape
    clear_board = np.min(board, axis=1) == 0
    clear_board = clear_board.reshape(board_row, 1)
    clear_board = board * clear_board
    if np.sum(clear_board != board) == 0:
        return []
    animated.append(np.array(clear_board))
    cur_index = -1
    while True:
        if np.sum(clear_board[cur_index, :]) == 0:
            new_board = np.zeros_like(board, int)
            if cur_index < -1:
                new_board[cur_index+1:] = clear_board[cur_index+1:]
            new_board[1:cur_index + 1 + board_row] = clear_board[:cur_index]
            if np.sum(new_board != board) == 0:
                break
            animated.append(new_board)
            clear_board = np.array(new_board)
            if np.sum(clear_board[:cur_index]) == 0:
                break
        else:
            cur_index -= 1
    return animated

xxx217xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [1, 2, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 718, 'const': 434, 'code+const': 1152}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('While', 9), ('For', 25)]]
import numpy as np
def get_score(board):
    new_board = np.array(board)
    return new_board[new_board.min(axis=1) != 0].shape[0] * 40
def get_time_cap(board, time_caps):
    len_ = len(time_caps)
    index = board.max(axis=1).reshape((len_,-1)).sum(axis=1) != 0
    if np.array(time_caps)[index].shape == (0,):
        return time_caps[-1]
    return np.array(time_caps)[index][0]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    list_ = []
    board_check = board[:,c:c+shape.shape[1]]
    for i in range(board_check.shape[0]+1-shape.shape[0]):
        check_board = (board_check[i:i+shape.shape[0]] != 0)
        check_shape = (shape != 0)
        if (check_board & check_shape).sum() == 0:
            new = np.array(board,dtype=int)
            new[:,c:c+shape.shape[1]][i:i+shape.shape[0]] += shape
            list_.append(new)
    return list_
def animate_clear(board):
    list_ = []
    new = np.array(board)
    if ((new==0).sum(axis=1) == 0).sum() == 0:
        return []
    new[(new==0).sum(axis=1) == 0] =np.zeros(board.shape[1])
    list_.append(new)
    while True:
        not_zero = ((new != 0).sum(axis=1) ==0)
        if new[:not_zero.sum()].sum() == 0:
            break
        remove_zero = np.arange(new.shape[0],dtype=int)[not_zero][-1]
        drop = new[:remove_zero]
        zeross = np.zeros(new.shape)
        zeross[remove_zero:] = new[remove_zero:]
        aaa = animate_drop(zeross,drop,0)
        new = aaa[-1]
        list_.extend(aaa[1:])
    return list_

xxx044xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0., 1., 5., 5., 0., 0., 0., 0.],
       [0., 1., 1., 5., 5., 0., 0., 0.],
       [0., 2., 2., 2., 5., 2., 2., 2.],
       [3., 3., 3., 3., 0., 4., 4., 4.]])]]
test_animate_drop_20.0
[[array([[2., 2., 2., 0., 0., 0.],
       [0., 0., 2., 0., 0., 0.],
       [0., 0., 2., 0., 8., 0.],
       [1., 1., 0., 8., 8., 0.],
       [1., 1., 0., 0., 8., 0.]]),
  array([[0., 0., 0., 0., 0., 0.],
       [2., 2., 2., 0., 0., 0.],
       [0., 0., 2., 0., 8., 0.],
       [1., 1., 2., 8, 8, 0],
       [1, 1, 0, 0, 8., 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8., 0.],
       [1., 1., 2, 8, 8, 0.],
       [1, 1, 2, 0., 8., 0.]])],
 [array([[0., 2., 2., 2., 0., 0.],
       [0., 0., 0., 2., 0., 0.],
       [0., 0., 0., 2., 8., 0.],
       [1., 1., 0., 8., 8., 0.],
       [1., 1., 0., 0., 8., 0.]])],
 [],
 [array([[0., 0., 0., 2., 2., 2.],
       [0., 0., 0., 0., 0., 2.],
       [0., 0., 0., 0., 8., 2.],
       [1., 1., 0., 8., 8., 0.],
       [1., 1., 0., 0., 8., 0.]]),
  array([[0., 0., 0., 0., 0., 0.],
       [0., 0., 0., 2., 2., 2.],
       [0., 0., 0., 0., 8., 2.],
       [1., 1., 0., 8., 8., 2.],
       [1., 1., 0., 0., 8., 0.]])]]
test_animate_drop_30.0
[[array([[1., 1., 2., 2.],
       [1., 1., 0., 0.]])],
 [array([[0., 2., 2., 0.],
       [1., 1., 2., 0.],
       [1., 2., 2., 0.],
       [1., 1., 0., 1.],
       [1., 1., 1., 0.]])],
 [array([[0., 0., 2., 0.],
       [1., 1., 2., 0.],
       [1., 0., 2., 0.],
       [1., 2., 2., 1.],
       [1., 1., 1., 0.]])],
 [array([[0., 1., 2., 0.],
       [1., 0., 2., 0.],
       [1., 0., 2., 0.],
       [1., 2., 2., 1.],
       [1., 1., 1., 0.]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0., 0., 0., 0.],
       [0., 5., 5., 4.],
       [1., 0., 5., 4.],
       [1., 0., 2., 4.]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0., 0., 0., 0.],
       [0., 5., 5., 4.],
       [0., 0., 0., 0.],
       [0., 0., 0., 0.]]),
  array([[0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 5., 5., 4.],
       [0., 0., 0., 0.]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0., 0., 0., 0.],
       [1., 2., 0., 0.],
       [0., 0., 0., 0.],
       [1., 0., 2., 4.],
       [0., 0., 0., 0.],
       [0., 0., 1., 1.]]),
  array([[0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [1., 2., 0., 0.],
       [0., 0., 0., 0.],
       [1., 0., 2., 4.],
       [0., 0., 1., 1.]]),
  array([[0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [1., 2., 0., 0.],
       [1., 0., 2., 4.],
       [0., 0., 1., 1.]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 852, 'const': 310, 'code+const': 1162}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [], [('any', 16)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 10)]]
import numpy as np
def get_score(board):
    return np.sum(np.min(board, axis=1)!=0) * 40
def get_time_cap(board, time_caps):
    cnt_space = min(np.sum(np.sum(board, axis=1)==0), board.shape[0]-1)
    return time_caps[int(cnt_space * len(time_caps)/(board.shape[0]))]
def rotate_right(shape):
    return shape[::-1,:].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    animate = []
    total_sum = np.sum(board != 0) + np.sum(shape != 0)
    loop_time = board.shape[0]- shape.shape[0]
    for row in range(0, loop_time ) :
        temp = np.zeros(board.shape)
        temp[row:row+shape.shape[0], c:c+shape.shape[1]] = shape
        temp = board + temp
        if np.sum(temp != 0) == total_sum : 
          animate.append(temp)
        else :
          break
    return animate
def animate_clear(board):
    animate  = []
    new_board = np.array(board)
    new_board[np.min(new_board, axis=1)!=0] = [0]
    if(np.sum(new_board)==np.sum(board)): return animate
    animate.append(np.array(new_board))
    tb = [0,board.shape[0]-1]
    while(tb[0]!=tb[1]-1) :
      bottom_board = np.zeros(board.shape)
      bottom_board[tb[1]:board.shape[0],:]= new_board[tb[1]:board.shape[0],:]
      upper_board = np.zeros(board.shape)
      upper_board[1:tb[1]+1,:]= new_board[0:tb[1],:]
      temp = bottom_board + upper_board
      if np.sum(temp != 0) == np.sum(new_board != 0) and (temp != new_board).any():
        new_board = np.array(temp)
        animate.append(temp)
        if np.sum(np.min(new_board, axis=1)!=0) != 0 :
          new_board[np.min(new_board, axis=1)!=0] = [0]
          animate.append(new_board)
          tb[1] = board.shape[0]-1
          tb[0]-=1
        tb[0]+=1
      else:
        tb[1]-=1
    return animate

xxx019xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [], []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1620, 'const': 396, 'code+const': 2016}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 12)], [('For', 15)]]
import numpy as np
def get_score(board):
    return len(np.array(board)[np.min(board,axis = 1)!= 0])*40
def get_time_cap(board, time_caps):
    a = np.max(board,axis = 1)!=0
    a = np.max(a.reshape((len(time_caps),len(board)//len(time_caps))),axis = 1)
    if a.max() == False:
        return time_caps[-1]
    return time_caps[np.argmax(a)]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    ans=[]
    num=np.max(shape)
    amount=np.sum(shape==num)
    new_board = np.array(board)
    i = 1
    new_board[0:0+len(shape),c:len(shape[0])+c] += shape
    if np.sum(new_board[0:0+np.argmax(np.min(shape,axis=1)),c:len(shape[0])+c] == shape[0:0+np.argmax(np.min(shape,axis=1)),0:len(shape[0])]) != new_board[0:0+np.argmax(np.min(shape,axis=1)),c:len(shape[0])+c].shape[0]*new_board[0:0+np.argmax(np.min(shape,axis=1)),c:len(shape[0])+c].shape[1]:
        return []
    ans.append(np.array(new_board))
    while np.sum(new_board[i-1:i-1+len(shape),c:len(shape[0])+c]==num)>=amount and np.sum(new_board[i-1:i,c:len(shape[0])+c][0]) == np.sum(shape[0]) and (i + len(shape))<=len(board):
        new_board[i:i+len(shape),c:len(shape[0])+c] += shape
        new_board[i-1:i-1+len(shape),c:len(shape[0])+c] -= shape
        ans.append(np.array(new_board))
        i+=1
    if (i + len(shape))>=len(board) and np.sum(new_board[i-1:i-1+len(shape),c:len(shape[0])+c]==num)>=amount:
            return ans
    else:return ans[:-1]
def animate_clear(board):
    ans = []
    realans=[]
    new_board = np.array(board)
    new_board2 = np.zeros((board.shape[0],board.shape[1]),int)
    if np.sum(np.min(new_board,axis = 1) != 0) == 0:
        return([])
    y = np.arange(0,len(board))
    y = list(y)
    x = y*(np.sum(np.max(new_board,axis =1)==0)+1+np.sum(np.min(new_board,axis =1)!=0))
    c = 1
    a = 1
    b = 0
    for i in x:
        if np.max(board[:a]) == 0 and a <= len(board):
            b = a
        if np.min(new_board[i]) != 0 and c == 1:
            new_board[i] = np.zeros((1,board.shape[1]),int)[0]
        if i == len(board)-1 and c == 1:
            realans.append(np.array(new_board))
        new_board2 = np.zeros((board.shape[0],board.shape[1]),int)
        if np.max(new_board[i]) == 0 and c!=1:
            new_board2[1:i+1,:] += new_board[:i,:]
            new_board2[i+1:,:] += new_board[i+1:,:]
            ans.append(new_board2)
        if i == len(board)-1 and c!=1:
            new_board = np.array(ans[-1])
            if np.sum(realans[-1] == ans[-1]) != board.shape[0]*board.shape[1]:
                realans.append(np.array(ans[-1]))
        if i == len(board)-1:
            c+=1
        a += 1
    return realans

xxx214xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('operands could not be broadcast together with shapes (4,) (6,) ')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (6,) (9,) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('operands could not be broadcast together with shapes (4,) (7,) ')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0UnboundLocalError("local variable 'start_row' referenced before assignment")
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1124, 'const': 254, 'code+const': 1378}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep:
   [[('For', 4)], [('While', 6)], [], [], [('For', 8), ('For', 12), ('For', 9)], [('For', 7), ('For', 21), ('While', 30), ('For', 22), ('For', 34)]]
import numpy as np
def get_score(board):
  board_copy = board
  n=0
  for e in board_copy:
    if 0 not in e:
      n+=1
  return n*40
def get_time_cap(board, time_caps):
  board_copy = board
  i=0
  n=0
  t = int(len(board_copy)/len(time_caps))
  while i<len(board_copy):
    sum=np.sum(board[i:i+t])
    if sum!=0:break
    i+=t
    n+=1
  if n==len(time_caps):
    return time_caps[n-1]
  return time_caps[n]
def rotate_right(shape):
  shape_copy=shape
  return shape_copy[::-1].T
def rotate_left(shape):
  shape_copy=shape
  return shape_copy[::,::-1].T
def animate_drop(board, shape, c):
  out=[]
  if c ==0:
    sh=[]
  else:
    sh=[0]*c
  for i in range(len(shape)):
    for j in range(len(shape[i])):
      sh.append(shape[i][j])
  sh_new =np.array(sh)
  for i in range(len(board)):
    preout=np.zeros((int(len(board)),int(len(board.T))),int)
    if board[i,c]==0:
      new = board[i]+sh_new
      if i!=0:
        preout[:i]=board[:i]
      preout[i]=new
      preout[i+1:]=board[i+1:]
    else:
      preout=[]
    if preout!=[]:
      out.append(preout)
  return out
def animate_clear(board):
  out=[]
  preout=np.zeros((int(len(board)),int(len(board.T))),int)
  k=0
  TF2=False
  for i in range(len(board)):
    if 0 not in board[i]:
      new = np.zeros((1,len(board.T)))
      if i!=0:
        preout[k:i]=board[k:i]
      preout[i]=new
      k=i+1
      preout[k:]=board[k:]
      TF2=True
  if TF2==True:
    out.append(preout)
  else:
    return out
  loop=False
  for i in range(len(preout)):
    for j in range(len(preout[i])):
      if preout[i,j]!=0:
        start_row = i
        loop=True
        break
    if loop==True:break
  k=0
  i=0
  while i<len(preout)-k-start_row:
    use= out[-1][::-1]
    tf=True
    pre_out=np.zeros((int(len(board)),int(len(board.T))),int)
    for j in range(len(use[i])):
      if use[i,j]!=0:
        tf=False
        break
    if tf==True:
      if i!=1:
        pre_out[:i]=use[:i]
      else:
        pre_out[0]=use[0]
      pre_out[i:-1]=use[i+1:]
      out.append(pre_out[::-1])
      k+=1
      i=0
    i+=1
  return out

xxx042xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[2, 2, 2, 4],
       [1, 5, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [2, 2, 2, 4],
       [1, 5, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [2, 2, 2, 4],
       [1, 5, 2, 4]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [10, 10, 50, 40],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [10, 10, 50, 40],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 1, 5, 4]])],
 [array([[5, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [50, 50, 50, 40],
       [0, 0, 0, 0],
       [0, 25, 25, 4]])],
  [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [50, 50, 50, 40],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [20, 20, 20, 40],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [20, 20, 20, 40],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [20, 0, 0, 20],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1312, 'const': 474, 'code+const': 1786}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 19)], [('For', 30)]]
import numpy as np
def get_score(board):
  s = 0
  n = len(board)
  x = np.min(board, axis=1)
  x1 = x != 0
  su = np.sum(x1)
  return su*40
def get_time_cap(board, time_caps):
  l = len(board[0])
  lt = len(time_caps)
  n = int(len(board)/lt)
  x = np.max(board, axis=1)
  x1 = x == 0
  su = np.sum(x1)//n
  return time_caps[su]
def rotate_right(shape):
  n = len(shape)
  if n == 1:
    return shape.T
  elif n == 4:
    s = shape.T
    s = s[0][::-1]
    return s
  elif n == 2 or n == 3:
    shape = shape[::-1]
    s = shape.T
    return s
def rotate_left(shape):
  n = len(shape)
  if n == 1:
    s = shape.T
    s = s[::-1]
    return s
  elif n == 4:
    return shape.T
  elif n == 2 or n == 3:
    s = shape.T
    return s[::-1]
def animate_drop(board, shape, c):
  s = []
  b = board
  sh = shape
  ls = len(shape)
  ls0 = len(shape[0])
  ln = len(b[0])
  lb = len(b)
  a = np.array([[0]*(ls*ls0)])
  a = a.reshape((ls,ls0))
  bc = b[:ls, c:ls0+c] == 0
  if False in bc:
    return []
  else:
      if False not in bc:
        b[:ls, c:ls0+c] = sh
        s.append(np.array(b))
        for i in range(1,lb):
          bc1 = b[i:ls+i, c:ls0+c] == 0
          if False not in bc1:
            b[i:ls+i, c:ls0+c] = sh
            b[i-1:ls+i-1, c:ls0+c] = a
            s.append(b)
  return s
def animate_clear(board):
  s = []
  b = board
  ln = len(b[0])
  b1 = list(np.min(b, axis=1) != 0)
  b1a = b1[::-1]
  c = 0
  if True in b1a:
    id = b1a.index(True)
    b[-id-1] = np.array([[0]*ln])
    c = id+1
    if c <= len(b):
      if True in b1a[c:]:
        id = b1a[c:].index(True)
        b[-id-1-c] = np.array([[0]*ln])
        c = id +1
    if c <= len(b):
      if True in b1a[c:]:
        id = b1a[c:].index(True)
        b[-id-1-c] = np.array([[0]*ln])
        c = id +1
    if c <= len(b):
      if True in b1a[c:]:
        id = b1a[c:].index(True)
        b[-id-1-c] = np.array([[0]*ln])
        c = id +1
    s.append(b)
    n = 0
    for i in range(len(b)):
      bl = list(b)
      if np.max(bl[-(i+1-n)]) == 0:
        bl.pop(-(i+1-n))
        bl.insert(0, np.array([0]*ln))
        bl = np.array(bl)
        b1 = list(np.max(b, axis=1))
        b2 = list(np.max(bl, axis=1))
        if b1 != b2:
          b = np.array(bl)
          s.append(b)
          n += 1
  else: 
    pass
  return s

xxx212xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (4,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (6,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (3,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[2, 2, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [2, 2, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [2, 2, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [20, 20, 20, 40]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[5, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
   ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 880, 'const': 338, 'code+const': 1218}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('For', 20)]]
import numpy as np
def get_score(board):
    row , col = board.shape
    count = board != 0
    tot_count = np.sum(count, axis=1)
    check = tot_count == col
    return np.sum(check)*40
def get_time_cap(board, time_caps):
    if np.sum(board) != 0 :
        part = len(time_caps)
        row , col = board.shape      
        count = board == 0
        tot_count = np.sum(count, axis=1)
        check = tot_count == col
        index_fr = np.sum(check) + 1
        index = index_fr//part
        if (index_fr%part==0) and (index_fr//part != 0) :
            return time_caps[index-1]
        elif index == 0 :
            return time_caps[0]
        elif (index_fr%part != 0) and (index_fr//part != 0):
            return time_caps[index+1]
    else : return time_caps[-1]
def rotate_right(shape):
    row , col = shape.shape
    if row == 1 :
        return shape.reshape((col,row))
    else : return shape.T[: , ::-1]
def rotate_left(shape):
    new_shape = rotate_right(shape)
    return new_shape[::-1 , ::-1]
def animate_drop(board, shape, c):
    row , col = board.shape
    out = []
    new_board = np.array(board)
    for i in range(0,row) :
        if board[i,c] != 0 :
            return out
        else :
            new_board[i,c:] = shape[:,:]
            out.append(new_board)
            new_board = np.array(board)
    return out
def animate_clear(board):
    row , col = board.shape
    ir = np.arange(0,row,1)
    out = []
    z_board = np.array(board)
    count = np.sum(z_board != 0, axis=1)
    check = count == col
    index = (check*ir)[check*ir != 0]
    if np.sum(check) == 0 : return out
    else:
        z_board[index, :] = 0
        out.append(z_board)
    z = np.array(z_board)
    count = np.sum(z == 0, axis=1)
    check = count == col
    index = (check*ir)[check*ir != 0]
    new_board = np.array(z)
    bottom = index[::-1]
    for i in range(bottom.shape[0]):
        new_board [1:bottom[i]+1, :] = z[0:bottom[i] ,:]
        new_board[0,:] = np.zeros((1,col))
        bottom = bottom + 1
        out.append(new_board)
        new_board = np.array(new_board)
        z = np.array(new_board)
    return out

xxx039xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 984, 'const': 230, 'code+const': 1214}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 17)]]
import numpy as np
def get_score(board):
    z = np.zeros((1,board.shape[1]),int)
    c = board!=z
    v_of_lo = np.sum(c,1)
    bonus = np.sum(v_of_lo == board.shape[1])
    ans = bonus*40
    return ans
def get_time_cap(board, time_caps):
    z = np.zeros((1,board.shape[1]),int)
    lo = np.sum(board==z,1)
    lo2 = lo!=board.shape[1]
    n_s = lo2.reshape(len(time_caps),int(board.shape[0]/len(time_caps)))
    v_of_ns = np.sum(n_s,1)
    lo_vofns = v_of_ns>0
    np_ans = np.array(time_caps)[lo_vofns]
    if len(np_ans) >0:
        ans = int(np_ans[0])
    elif len(np_ans) == 0:
        ans = time_caps[-1]
    return ans
def rotate_right(shape):
    ns1 = shape[::-1,:]
    ns2 = ns1.T
    return ns2
def rotate_left(shape):
    ns1 = shape[:,::-1]
    ns2 = ns1.T
    return ns2
def animate_drop(board, shape, c):
    ans = []
    for i in range((board.shape[0]-shape.shape[0])+1):
        ana_board = board[i:shape.shape[0]+i,c:c+shape.shape[1]]
        lo = (shape+ana_board)==shape
        if np.sum(lo) == (shape.shape[0]*shape.shape[1]):
            nb = np.array(board)
            rest_data = nb[i:shape.shape[0]+i,c:c+shape.shape[1]] + shape
            nb[i:shape.shape[0]+i,c:c+shape.shape[1]] = rest_data
            ans.append(nb)
        else:
            return ans
    return ans
def animate_clear(board):
    ans = []
    nb = np.array(board)
    nb_zero = np.zeros_like(nb)
    lo_notzero = np.sum(board!=0,1) == board.shape[1]
    posi_full = np.arange(board.shape[0])[lo_notzero]
    if len(posi_full) == 0:
        return ans
    nb[posi_full,:] = 0
    lo_zero = np.sum(nb==0,1) == board.shape[1]
    num_zero = sum(lo_zero)
    posi_number = np.arange(board.shape[0])[lo_zero]
    real_posi = posi_number[::-1]
    ans.append(nb)
    i = real_posi[0]
    while i != (num_zero-1):
        if sum(nb[i]) == 0:
            under_zero = np.zeros_like(nb)
            under_zero[i+1:,:] = nb[i+1:,:]
            upper_zero = np.zeros_like(nb)
            upper_zero[1:i+1,:] = nb[0:i,:]
            nb = under_zero + upper_zero
            ans.append(nb)
        else:
            i += -1
    return ans

xxx021xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 786, 'const': 324, 'code+const': 1110}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 12)]]
import numpy as np
def get_score(board):
    z = board == 0
    s = np.sum(z, axis=1)
    return sum(s==0)*40
def get_time_cap(board, time_caps):
    z = board != 0
    s = np.sum(z, axis=1)
    p = np.arange(board.shape[0])
    if p[s>0].shape[0] == 0:
        return time_caps[-1]
    else:
        rp = np.min(p[s>0])
        mp = board.shape[0]/len(time_caps)
        pos = int(rp//mp)
        return time_caps[pos]
def rotate_right(shape):
    z = shape.T
    return z[:,::-1]
def rotate_left(shape):
    z = rotate_right(shape)
    return z[::-1,::-1]
def animate_drop(board, shape, c):
    list_nb = []
    for i in range(board.shape[0]-shape.shape[0]+1):
      new_board = np.array(board)
      new_shape = np.array(shape)
      space = new_board[i:i+new_shape.shape[0],c:c+new_shape.shape[1]]
      cspace = space != 0
      if np.sum(cspace*shape) != 0:
        break
      new_board[i:i+new_shape.shape[0],c:c+new_shape.shape[1]]+=new_shape
      list_nb.append(np.array(new_board))
    return list_nb
def animate_clear(board):
    list_nb = []
    new_board = np.array(board)
    z = np.sum(new_board == 0, axis=1)
    p = np.arange(new_board.shape[0])
    clear = p[z == 0]
    if clear.shape[0] != 0:
      new_board[clear,:] = 0
      list_nb.append(np.array(new_board))
    c = new_board.shape[0]-1
    while c>0:
      if np.sum(new_board[c,:]) == 0 and np.sum(new_board[:c,:]) != 0:
        new_board[1:c+1,:] = new_board[:c,:]
        new_board[0,:] = 0
        list_nb.append(np.array(new_board))
      else:
        c -= 1
    return list_nb

xxx043xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[]]
bytecount: {'code': 1044, 'const': 432, 'code+const': 1476}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('For', 15)]]
import numpy as np
def get_score(board):
    s = np.min(board,axis=1) != 0
    sc = board[s].shape[0]*40
    return sc
def get_time_cap(board, time_caps):
    s = np.max(board,axis=1) != 0
    a = np.arange((s.shape[0]))
    f = a[s]  
    if len(f) > 0:
        ff = f[0]  
        return time_caps[ff//(board.shape[0]//len(time_caps))]
    return time_caps[-1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    nb = np.array(board)  
    ns = np.array(shape)  
    l = []
    if not can(board[0:shape.shape[0],c:c+len(ns[0])],np.ones(shape.shape)):
        return l
    for k in range(nb.shape[0]-len(ns)+1):
        if not can(board[k:k+len(ns),c:c+len(ns[0])],ns):
            return l
        if k>0 :
            nb[k-1,c:c+len(ns[0])] = 0
        cnb = np.array(nb)
        nb[k:k+len(ns),c:c+len(ns[0])] = ns
        cnb[k:k+len(ns),c:c+len(ns[0])] = np.zeros((ns.shape))
        nb += board - cnb
        l.append(np.array(nb))
    return l
def animate_clear(board):
    nb = np.array(board)
    s = np.min(board,axis=1) != 0
    nb[s] = np.zeros((1,nb.shape[1]))
    c = np.arange(s.shape[0])[s]
    l = [np.array(nb)] if len(c) > 0 else []
    r = np.max(nb,axis=1) != 0
    index_r = np.arange(r.shape[0])[r]
    nb2 = nb[index_r[0]:]
    c_nb2 = np.max(nb2,axis=1) == 0
    for i in range(sum(c_nb2)):
        s = np.max(nb,axis=1) == 0
        index_c = np.arange(s.shape[0])[s]
        nb = slice_down(nb,index_c[-1]-1)
        l.append(np.array(nb))
    return l
def can(array1,array2):
    check = np.ndarray(array1.shape)
    check = check[(array1>0)&(array2>0)]
    if len(check) > 0:
        return False
    return True
def slice_down(nb,k):
    nb2 = np.zeros(nb.shape,int)
    nb2[-1:k+1:-1] = nb[-1:k+1:-1]
    nb2[k+1] = nb[k]
    if k > 0:
        nb2[1:k+1] = nb[:k]
    return nb2

xxx033xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0ValueError('cannot reshape array of size 24 into shape (2,8)')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], None[array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None,
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 20, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 730, 'const': 304, 'code+const': 1034}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 8)], [('While', 11)]]
import numpy as np
def get_score(board):
    return np.sum(np.min(board != 0, axis=1) * 40)
def get_time_cap(board, time_caps):
    is_zero_row = np.max(board.reshape(len(time_caps),  board.shape[1]+board.shape[1]),1)==0
    is_zero_row = list(is_zero_row)
    try: return time_caps[is_zero_row.index(False)]
    except: return time_caps[len(time_caps)-1]
def rotate_right(shape):
    return shape.T[:, ::-1]
def rotate_left(shape):
    return shape.T[::-1, :]
def animate_drop(board, shape, c):
    a = []
    row_i=0
    shape_r, shape_c = shape.shape
    if np.sum(board[:shape_r, c:c+shape_c][shape!=0]) != 0:
        return a
    while row_i+shape_r <= board.shape[0]:
        new_board = np.array(board)
        new_board[row_i:row_i+shape_r,c:c+shape_c] += shape
        if np.sum(new_board[row_i:row_i+shape_r,c:c+shape_c][shape!=0] != shape[shape!=0]) != 0:
            return a
        row_i+=1
        a.append(np.array(new_board))
def animate_clear(board):
    a = []
    if board[np.min(board, axis=1) != 0].shape[0] != 0:
        board[np.min(board, axis=1) != 0, :] = 0
        a.append(np.array(board))
    if np.min(np.sum(board, axis=1)) != 0:
        return a
    board_r, board_c = board.shape
    new_board = np.array(board)
    while(1):
        zero_idx = board_r-np.argmin(np.sum(new_board, axis=1)[::-1])
        new_board[1:zero_idx] = new_board[:zero_idx-1]
        new_board[0] = 0
        if len(a) > 0 and not np.max(a[-1] != new_board):
            return a
        a.append(new_board)
        new_board = np.array(new_board)

xxx032xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1214, 'const': 414, 'code+const': 1628}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 8)], [('While', 13)]]
import numpy as np
def get_score(board):
    return np.sum((np.sum(board!=0,axis=1))==board.shape[1])*40
def get_time_cap(board, time_caps):
    a=np.sum(board,axis=1)
    b=a[a==0]
    interval=board.shape[0]//len(time_caps)
    if b.shape[0]==board.shape[0]: return time_caps[-1]
    else: return time_caps[(b.shape[0])//interval]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    result=[]
    i,j=0,0
    s=np.zeros((board.shape[0]+shape.shape[0],board.shape[1]),int)
    s[shape.shape[0]:,:]=board
    first_check=True
    while np.sum((board[i:i+shape.shape[0],c:c+shape.shape[1]]==0)|(shape==0))==(shape.shape[0]*shape.shape[1]):
        if first_check:
            k=np.array(s)
            if np.sum((k[j:j+shape.shape[0],c:c+shape.shape[1]]==0)|(shape==0))!=(shape.shape[0]*shape.shape[1]):
                return []
            else:
                k[j:j+shape.shape[0],c:c+shape.shape[1]]=(k[j:j+shape.shape[0],c:c+shape.shape[1]])|(shape)
                j+=1
                if np.sum(k[:shape.shape[0],:]!=0)==0:
                    first_check=False
        else :
            b=np.array(board)
            b[i:i+shape.shape[0],c:c+shape.shape[1]]=(board[i:i+shape.shape[0],c:c+shape.shape[1]])|(shape)
            result.append(b)
            i+=1
            if np.sum(np.sum(board[-1]|b[-1]))!=np.sum(np.sum(board[-1])): break
    return result
def animate_clear(board):
    result=[]
    b=np.array(board)
    index=np.arange(0,board.shape[0])[np.sum(board!=0,axis=1)==board.shape[1]]
    if index.shape[0]==0: return []
    else:
        b[index,:]=np.zeros((1,board.shape[1]))
        result.append(np.array(b))
    i=-1
    while np.sum((np.sum(b[:-1,:],axis=1)!=0) & ((np.sum(b[1:,:],axis=1)==0)))!=0:
        if np.sum(b[i])==0:
            b[i,:]=b[i-1,:]
            b[i-1,:]=np.zeros((1,b.shape[1]))
        i-=1
        if i==-b.shape[0]:
            i=-1
            result.append(np.array(b))
    if np.sum((result[-1] != b))!=0:
        result.append(np.array(b))
    return result

xxx200xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score0.0
[40, 4120]
test_get_time_cap0.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (3,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (3,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (2,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 438, 'const': 280, 'code+const': 718}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], []]
import numpy as np
def get_score(board):
    board_TF = ( board != 0 )
    a = np.sum(board_TF,axis=1)
    b = sum(a==5)
    return b*40
def get_time_cap(board, time_caps):
    n = len(time_caps)
    time_caps = np.array(time_caps)
    if np.sum(board) == 0 :
      tcp = time_caps[-1]
    else :
      row = board.shape[0]
      BOARD = board[0::row//n,:]+board[1::row//n,:]
      sumaxisx = ( np.sum(BOARD,axis=1) != 0 )
      tcp = time_caps[sumaxisx][0]
    return tcp
def rotate_right(shape):
    return shape[::-1,::].T
def rotate_left(shape):
    return shape[::,::-1].T
def animate_drop(board, shape, c):
    w,l = shape.shape
    result = []
    for i in range (board.shape[0]+1-w) :
      new_board = np.array(board)
      if np.sum(new_board[i,c:c+l] == [0]*l) == l :
        new_board[i,c:c+l] = shape
        result.append(new_board)
      else :
        break
    return result
def animate_clear(board):
    pass

xxx216xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1350, 'const': 384, 'code+const': 1734}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 7)], [('While', 16)]]
import numpy as np
def get_score(board):
    return 40*np.sum([np.sum(board == 0,axis = 1)==0])
def get_time_cap(board, time_caps):
    new_range = np.arange(len(time_caps))
    rowboard = np.arange(board.shape[0])
    if len(rowboard[np.sum(board,axis = 1) != np.zeros((board.shape[0]))]) > 0 :
        findrow = rowboard[np.sum(board,axis = 1) != np.zeros((board.shape[0]))][0]
        return time_caps[findrow//(board.shape[0]//len(time_caps))]
    else :
        return time_caps[-1]
def rotate_right(shape):
    nshape = shape[::-1]
    return nshape.T
def rotate_left(shape):
    shapet = shape.T
    return shapet[::-1]
def animate_drop(board, shape, c):
    newboard = []
    xboardx = np.array(board)
    shape_line = np.arange(shape.shape[0])
    i = 0
    while np.sum((board[i:i+shape.shape[0],c:c+shape.shape[1]]*shape) == np.zeros_like(shape))==np.sum(np.ones_like(shape)) :
            if np.sum(board[i:i+shape.shape[0],c:c+shape.shape[1]] != np.zeros_like(shape))>0 and i == 0:
                line = np.sum(board[i:i+shape.shape[0],c:c+shape.shape[1]]!= np.zeros_like(shape),axis = 1)
                if shape_line[np.sum(shape,axis=1)==np.max(np.sum(shape,axis=1),axis = 0)][-1] > shape_line[line>=1][0] :
                    break
                if shape_line[np.sum(shape,axis=1)==np.max(np.sum(shape,axis=1),axis = 0)][-1] == shape_line[line>=1][0] :
                    ind = [board[shape_line[line>=1][0],c:c+shape.shape[1]]==0]
                    if np.sum(shape[shape_line[line>=1][0]]*[ind])!=np.sum(shape[shape_line[line>=1][0]]) :
                        break
            xboardx = np.array(board)
            xboardx[i:i+shape.shape[0],c:c+shape.shape[1]] += shape
            newboard.append(xboardx)
            i+=1
            if i+shape.shape[0] > board.shape[0] :
                break
    return newboard
def animate_clear(board):
    listboard = []
    new_board = np.array(board)
    new_board[np.sum(board == 0,axis = 1)==0] = np.zeros_like(board.shape[1])
    new_b2 = np.array(new_board)
    if np.sum(board == new_board) != np.sum(np.ones_like(board)) :
        listboard.append(new_board)
        new_range = np.arange(board.shape[0])
        if len(new_range[np.sum(new_b2,axis = 1) == np.zeros((board.shape[0]))]) > 0 :
                zerorow = new_range[np.sum(new_b2,axis = 1) == np.zeros((board.shape[0]))][-1]
        if len(new_range[np.sum(new_b2,axis = 1) != np.zeros((board.shape[0]))]) > 0 :
                firstelem = new_range[np.sum(new_b2,axis = 1) != np.zeros((board.shape[0]))][0]
        else :
            return [np.zeros_like(board)]
        while zerorow > firstelem:
            new_b2[1:zerorow+1] = new_board[:zerorow]
            new_b2[0] = np.zeros_like(board.shape[1])
            new_board = np.array(new_b2)
            listboard.append(new_board)
            zerorow = new_range[np.sum(new_b2,axis = 1) == np.zeros((board.shape[0]))][-1]
            firstelem = new_range[np.sum(new_b2,axis = 1) != np.zeros((board.shape[0]))][0]
    return listboard

xxx211xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 950, 'const': 326, 'code+const': 1276}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 8)], [('While', 14)]]
import numpy as np
def get_score(board):
    zeroboard = np.zeros_like(board)
    compareboard=np.sum(zeroboard==board,axis=1)
    zerocompareboard = np.zeros_like(compareboard)
    pts=np.sum(zerocompareboard==compareboard)*40
    return pts
def get_time_cap(board, time_caps):
    ntimes=np.shape(board)[0]//len(time_caps)
    splitboard=np.reshape(board, (len(time_caps),np.shape(board)[1]*ntimes))
    line=np.arange(len(time_caps))
    linenotzero=line[np.sum(splitboard,axis=1)!=0]
    if len(linenotzero)==0:
      return time_caps[-1]
    else:
      firstlinenotzero=linenotzero[0]
      return time_caps[firstlinenotzero]
def rotate_right(shape):
    newshape = shape[::-1,::]
    return newshape.T
def rotate_left(shape):
    newshape = shape[::,::-1]
    return newshape.T
def animate_drop(board, shape, c):
    new_shape = np.array(shape)
    new_board = np.array(board)
    place=0
    maxplace=(np.shape(new_board)[0])-(np.shape(new_shape)[0])+1
    out=[]
    while maxplace!=place:
      shouldbezero=new_board[place:place+np.shape(new_shape)[0]:,c:c+np.shape(new_shape)[1]:][new_shape!=np.zeros_like(new_shape)]
      if  np.sum(shouldbezero) == 0  :
        new_board[place:place+np.shape(new_shape)[0]:,c:c+np.shape(new_shape)[1]:][new_shape!=np.zeros_like(new_shape)]=new_shape[new_shape!=np.zeros_like(new_shape)]
        out.append(np.array(new_board))
        place+=1
        new_board = np.array(board)
        new_shape = np.array(shape)
      else:
        break
    return out
def animate_clear(board):
    new_board = np.array(board)
    out=[]
    zeroboard = np.zeros_like(new_board)
    compareboard=np.sum(zeroboard==new_board,axis=1) 
    zerocompareboard = np.zeros_like(compareboard)
    new_board[zerocompareboard==compareboard,::]=0 
    out.append(np.array(new_board))
    checkat=np.shape(new_board)[0]-2
    downcount=0
    if np.sum(zerocompareboard==compareboard)==0:
      return []
    while True:
      if np.sum(new_board[checkat+1,::])==0 and np.sum(new_board[checkat,::])!=0:
        new_board[checkat+1,::]=new_board[checkat,::]
        new_board[checkat,::]=0
        downcount+=1
      if checkat==0 and downcount!=0:
        out.append(np.array(new_board))
        checkat=np.shape(new_board)[0]-1
        downcount=0
      elif checkat==0 and downcount==0:
        break
      checkat-=1
    return out

xxx036xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 772, 'const': 338, 'code+const': 1110}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 10)], [('While', 10)]]
import numpy as np
def get_score(board):
    score = board != 0
    score = np.sum(np.mean(score,axis=1) == 1) * 40
    return score
def get_time_cap(board, time_caps):
    sumboard1 = np.sum(board,axis=1)
    lentime = len(time_caps)
    lenboard = len(board)
    lenn = lenboard//lentime
    sumboard1 = sumboard1.reshape(len(board)//lenn,lenn)
    sumboard1 = np.sum(sumboard1,axis=1) != 0
    listsum = list(sumboard1)
    if True in listsum:
        T = listsum.index(True)
        return time_caps[T]
    else:
        return time_caps[-1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    nshape = np.array(shape)
    nboard = np.array(board)
    hshape,wshape = nshape.shape
    nnboard = np.array(nboard)
    nnnboard = nnboard[:,c:c+wshape] == 0
    boolshape = shape != 0
    list1 = []
    for i in range(len(nboard)-hshape+1):
        nboard = np.array(board)
        if np.sum((nnnboard[i:i+hshape] & boolshape)) == np.sum(boolshape):
            nboard[i:i+hshape,c:c+wshape] += nshape
            list1.append(nboard)
        else:
            break
    return list1
def animate_clear(board):
    nboard = np.array(board)
    nboard[np.mean(nboard != 0 , axis= 1) == 1] = np.zeros_like( nboard[np.mean(nboard != 0 , axis= 1) == 1])
    list1 = []
    i = len(nboard) - 1
    list1.append(nboard)
    if np.mean(nboard == board) == 1:
        return []
    while True:
        nboard = np.array(nboard)
        if np.mean(nboard[i] == np.zeros_like(nboard[i])) == 1:
            nboard[1:i+1] = nboard[0:i]
            nboard[0] = np.zeros_like(nboard[0])
            list1.append(nboard)
            i = i + 1
        if np.mean(nboard[0:i-1] == np.zeros_like(nboard[0:i-1])) == 1:
            break
        i = i - 1
    return list1

xxx028xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 922, 'const': 522, 'code+const': 1444}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('While', 11)]]
import numpy as np
def get_score(board):
    a= board==0
    b= np.sum(a,axis=1)==0
    c= np.sum(b)
    return c*40
def get_time_cap(board, time_caps):
    a= board!=0
    b= np.sum(a,axis=1)!=0
    c=list(b)
    if True in c:
        p=c.index(True)
        n=board.shape[0]//len(time_caps)
        return time_caps[int(p/n)]
    else:
        return time_caps[-1]
def rotate_right(shape):
    a=shape.T
    return a[:,::-1]
def rotate_left(shape):
    a= shape.T
    return a[::-1,:]
def isok(board,shape,c,i):
    a=board[i:i+shape.shape[0]][:,c:c+shape.shape[1]]
    if a.shape== shape.shape:
        b=(shape!=0)
        c=np.sum(a[b])
        if c==0:
            return True
    return False
def replace(board,shape,c,i):
    board[i:i+shape.shape[0]][:,c:c+shape.shape[1]]+=shape
    return board
def animate_drop(board, shape, c):
    ns = np.array(shape)
    a=[]
    for i in range(board.shape[0]):
        nb = np.array(board)
        if isok(nb,ns,c,i):
            a.append(replace(nb,ns,c,i))
        else:
            break
    return a
def cut0(board):
    a=board!=0
    c=np.sum(a,axis=1)==0
    p=np.arange(1,len(c))
    e=c[:len(c)-1]==False
    f=c[1:]
    g=(e&f)
    d=p[g][::-1]
    if len(d)!=0:
        r=d[0]
        k=np.array(list(np.zeros((1,board.shape[1]),int))+list(board[:r])+list(board[r+1:]))
        return  k
    else:
        return []
def animate_clear(board):
    e=[]
    nb = np.array(board)
    a= nb==0
    b= np.sum(a,axis=1)!=0
    if sum(b==False)!=0:
        c= np.zeros((nb.shape[0],nb.shape[1]),int)
        c[b]=nb[b]
        e.append(c)
        while True:
            h=cut0(c)
            if len(h)!=0:
                e.append(h)
            else:
                break
            c=h
        return e
    return e

xxx216xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1340, 'const': 350, 'code+const': 1690}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [('transpose', 2)], [('transpose', 2)], [('transpose', 32), ('transpose', 30)], []]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('For', 17)]]
import numpy as np
def get_score(board):
    count = np.sum((board[:,:] != 0),axis = 1)
    max = len(board[0])
    score = count[count==max]
    score = len(score)*40
    return score
def get_time_cap(board, time_caps):
    depth = len(time_caps)
    hight = board.shape[0]*board.shape[1]//depth
    temp = np.reshape(board, (depth, hight, 1))
    temp = np.sum(temp, axis = 1)
    temp = 0**temp
    temp.reshape(len(temp))
    temp = list(np.sum(temp, axis = 1))
    try:
        index = temp.index(0)
    except:
        index = -1
    return time_caps[index]
def rotate_right(shape):
    return np.transpose(shape)[:,::-1]
def rotate_left(shape):
    return np.transpose(shape[:,::-1])
def animate_drop(board, shape, c):
    temp_board = np.array(board)
    temp_shape = np.array(shape)
    shape_height = temp_shape.shape[0]
    shape_width = temp_shape.shape[1]
    result = []
    for vertical_index in range(len(board)):
        if c > (len(board[0]) - len(shape[0])):
            return result
        exp1 = [0]*c*shape_height
        exp2 = list(rotate_right(shape).reshape(shape_height*shape_width))
        exp3 = [0]*(board.shape[1]-c-shape_width)*shape_height
        exp4 = np.array(exp1+exp2+exp3)
        exp4 = exp4.reshape(board.shape[1],shape_height)
        exp5 = rotate_left(exp4)
        try:
            temp_board[vertical_index:vertical_index+shape_height,:] += exp5
        except ValueError:
            temp_board[vertical_index:vertical_index+shape_height,:] += exp5[0:len(temp_board[vertical_index:vertical_index+shape_height,:])]
        argument1 = temp_board[vertical_index:vertical_index+shape_height,c:c+shape_width] == shape
        argument2 = temp_board[vertical_index:vertical_index+shape_height,c:c+shape_width] == board[vertical_index:vertical_index+shape_height,c:c+shape_width]
        argument = argument1|argument2
        if False in argument:
            return result
        result.append(temp_board)
        temp_board = np.array(board)
    return result
def animate_clear(board):
    result = []
    temp_board = np.array(board)
    clear_board = np.min(temp_board, axis = 1)
    index = np.arange(0,board.shape[0])
    index = index[clear_board > 0]
    if len(index) == 0:
        return result
    clear_board = temp_board
    clear_board[index] = [0]*board.shape[1]
    result.append(clear_board)
    check_board = np.sum(temp_board, axis = 1)
    check_board = 0**check_board
    index = np.argmin(check_board)
    counter = temp_board.shape[0] - index
    for i in range(index, index + counter):
        statement = np.max(clear_board[i:], axis = 1)
        if all(statement):
            return result
        temp = np.max(clear_board[i:], axis = 1)
        temp = temp[::-1]
        temp_index = np.argmin(temp)
        exp1 = list([0]*temp_board.shape[1])
        width = clear_board[:-temp_index-1].shape[1]
        height = clear_board[:-temp_index-1].shape[0]
        exp2 = list(clear_board[:-temp_index-1].reshape(width*height))
        width = clear_board[-temp_index:].shape[1]
        height = clear_board[-temp_index:].shape[0]
        if temp_index != 0:
            exp3 = list(clear_board[-temp_index:].reshape(width*height))
        else:
            exp3 = []
        exp4 = exp1 + exp2 + exp3
        exp4 = np.array(exp4)
        exp4 = exp4.reshape(board.shape[0], board.shape[1])
        clear_board = exp4
        result.append(clear_board)
    return result

xxx026xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[None56, None56, None56, None56, None45, None45, None45]
test_rotate_right0.0
[array([[40, 01],
       [30, 52],
       [25, 03],
       [10, 04]]),
 array([[01, 40],
       [52, 30],
       [03, 25],
       [04, 10]])]
test_rotate_left0.0
[array([[04, 10],
       [03, 25],
       [52, 30],
       [01, 40]]),
 array([[10, 04],
       [25, 03],
       [30, 52],
       [40, 01]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 164, 'const': 168, 'code+const': 332}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
import numpy as np
def get_score(board):
    N = np.min(board, axis = 1)
    return np.sum(N != 0)*40
def get_time_cap(board, time_caps):
    pass
def rotate_right(shape):
    a = shape.T[::-1,::]
    return a
def rotate_left(shape):
    a = shape.T[::,::-1]
    return a
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
    pass

xxx037xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 1008, 'const': 338, 'code+const': 1346}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 9)], [('For', 11)]]
import numpy as np
def get_score(board):
    r,c = board.shape
    m = board[:,:] != 0
    a = np.sum(m,axis = 1)
    a[:]=  a[:] == c
    return np.sum(a)*40
def get_time_cap(board, time_caps):
    r,c = board.shape
    nb = board.reshape((len(time_caps),-1))
    m = nb[:,:] != 0
    a = np.sum(nb,axis = 1)
    b = np.arange(0,a.shape[0])[a[0:] != 0]
    if b.shape[0] == 0 :
        return time_caps[-1]
    else :
        return time_caps[np.min(b)]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    o = []
    ro,co = board.shape
    cb = board[:,:] == 0
    s = np.zeros((shape.shape[0],co),int)
    s[:,c:c+shape.shape[1]] =  shape[:,:]
    sc = s != 0
    for i in range(board.shape[0]-s.shape[0]+1) :
        nb = np.array(board)
        t = np.sum(cb[i:i+s.shape[0]] | ~sc) == np.sum( np.zeros_like(s) == 0)
        if t :
            nb[i:i+s.shape[0],0:s.shape[1]] += s[:,:]
            o.append(nb)
        else :
            break
    return o
def animate_clear(board):
    o = []
    nb = np.array(board)
    bc = nb == 0
    a = np.sum(bc, axis = 1)
    b = np.arange(a.shape[0])[a == 0]
    nb[b,] = np.zeros((1,board.shape[1]))
    if np.sum(nb == board) != board.shape[0]*board.shape[1] :
        o.append(nb)
    for i in range(nb.shape[0]) :
        s = np.sum(nb == 0,axis = 1 )
        n = np.arange(s.shape[0])[s == nb.shape[1]]
        zb = np.zeros_like(nb,int)
        if n.shape[0] == 0:
            break
        ln = n[-1]
        zb[1:ln+1],zb[ln+1:] = nb[0:ln],nb[ln+1:]
        nb = zb
        if len(o) != 0 :
            if np.sum(o[-1] == nb) == nb.shape[0]*nb.shape[1]:
                break
        o.append(nb)
    return o

xxx035xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 514, 'const': 266, 'code+const': 780}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], []]
import numpy as np
def get_score(board):
    x = board==0
    y = np.sum(x,axis=1)
    ans = np.sum((y==0)*40)
    return ans
def get_time_cap(board, time_caps):
    if np.sum(board) > 0:
      x = board > 0
      ind_row = np.arange(board.shape[0])
      p = board.shape[0] // len(time_caps)
      y = np.sum(x,axis = 1)
      ind = y > 0 
      r = ind_row[ind]
      a = r[0]
      ans = time_caps[a // p]
    else:
      ans = time_caps[-1]
    return ans
def rotate_right(shape):
    ans = shape[::-1,::].T
    return ans
def rotate_left(shape):
    ans = shape[::,::-1].T
    return ans
def animate_drop(board, shape, c):
    ans = []
    piece = np.array(shape)
    for n in range(board.shape[0]):
      new_board = np.array(board)
      if (new_board[n : n + piece.shape[0] , c : c + piece.shape[1]]).shape == piece.shape : 
        if np.max(new_board[n : n + piece.shape[0] , c : c + piece.shape[1]]) != 0: 
          return ans
        else:
          new_board[n : n + piece.shape[0] , c : c + piece.shape[1]] += shape
          ans.append(new_board)
      else:
        return ans
def animate_clear(board):
    pass

xxx034xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[56, 456, 456, 456, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('cannot reshape array of size 8 into shape (4,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('cannot reshape array of size 18 into shape (6,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('cannot reshape array of size 12 into shape (4,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 790, 'const': 324, 'code+const': 1114}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('While', 8)]]
import numpy as np
def get_score(board):
  a = board.min(axis = 1)[board.min(axis = 1) != 0]
  return int(np.dot(a, (1/a))) * 40
def get_time_cap(board, time_caps):
  if np.sum(board) == 0: return time_caps[-1]
  step = int(np.shape(board)[0] / len(time_caps))
  index = board.argmax(axis = 1)[board.argmax(axis = 1) != 0][0]
  return time_caps[index // step]
def rotate_right(shape):
  return shape.T[:, ::-1]
def rotate_left(shape):
  return shape.T[::-1, :]
def animate_drop(board, shape, c):
  new_shape = np.zeros((shape.shape[0], board.shape[1]), int)
  new_shape[:, c:c+shape.shape[1]] += shape
  animate = []
  for row in range(0, board.shape[0], shape.shape[0]):
    new_board = np.array(board)
    shape_space = new_shape != 0
    new_board_frame = new_board[row:row+new_shape.shape[0], :]
    new_board_check = new_board_frame + new_shape
    if (not (new_board_check[shape_space] ==  new_shape[shape_space]).min()): break
    new_board[row:row+shape.shape[0], :] += new_shape.reshape(board.shape[1])
    animate.append(new_board)
  return animate
def animate_clear(board):
  new_board = np.array(board)
  if not (new_board.min(axis=1) != 0).max(): return []
  new_board[new_board.min(axis=1) != 0] *= 0
  current_row = new_board.shape[0] - 1
  animate = []
  animate.append(np.array(new_board))
  while (current_row != 0):
    if (new_board[current_row, :].max() != 0): current_row -= 1
    elif (new_board[:current_row, :].max() == 0): break
    else:
      temp = np.array(new_board[:current_row, :])
      new_board[0, :] = np.zeros(new_board.shape[1])
      new_board[1:current_row+1, :] = temp
      animate.append(np.array(new_board))
  return animate

xxx042xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 786, 'const': 338, 'code+const': 1124}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('For', 11)]]
import numpy as np
def get_score(board):
    rowmin = np.min(board,axis = 1)
    bsum = np.sum(rowmin != 0)
    return bsum*40
def get_time_cap(board, time_caps):
    rowsum = np.sum(board,axis = 1)
    pos = np.arange(board.shape[0])
    if len(pos[rowsum != 0]) != 0:
        rownum = pos[rowsum != 0][0]
        rowpsec = (board.shape[0])/(len(time_caps))
        return time_caps[int(rownum//rowpsec)]
    return time_caps[-1]
def rotate_right(shape):
    return shape.T[::,-1::-1]
def rotate_left(shape):
    return shape.T[-1::-1,::]
def animate_drop(board, shape, c):
    ans = []
    for i in range(board.shape[0]- shape.shape[0] +1):
        new_board = np.array(board)
        a = new_board[i:i+shape.shape[0],c:c+shape.shape[1]]
        b = np.array(shape)
        if np.sum((a == 0) | ((a != 0)&(b == 0))) == (shape.shape[0]*shape.shape[1]):
            new_board[i:i+shape.shape[0],c:c+shape.shape[1]] += b
            ans.append(new_board)
        else: break
    return ans
def animate_clear(board):
    new_board = np.array(board)
    ans = []
    pos = np.arange(board.shape[0])
    if len(new_board[(np.min(new_board,axis = 1) != 0),::]) == 0:
        return ans
    new_board[(np.min(new_board,axis = 1) != 0),::] *= np.array([0]*board.shape[1])
    ans.append(new_board)
    boardlist = list(new_board)
    for i in range(board.shape[0]):
        zerofrombt = pos[np.sum(new_board,axis = 1) == 0]
        if len(zerofrombt) != 0:
            boardlist.pop(zerofrombt[-1])
            boardlist.insert(0,[0]*board.shape[1])
            new_board = np.array(boardlist)
            if np.sum(new_board != ans[-1]) != 0:
                ans.append(new_board)
            else: break
        else: break
    return ans

xxx032xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 960, 'const': 338, 'code+const': 1298}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 15)]]
import numpy as np
def get_score(board):
    temp = np.sum([board != 0], axis=0)
    true_count = temp.sum(axis=1)
    res = true_count[true_count == board.shape[1]].shape[0]
    return res*40
def get_time_cap(board, time_caps):
    temp = np.sum([board != 0], axis=0)
    true_count = temp.sum(axis=1)
    pos = np.arange(board.shape[0])
    positions = pos[true_count != 0]
    if len(positions) == 0:
        return time_caps[-1]
    target = pos[true_count != 0][0]
    range_len = board.shape[0] // len(time_caps)
    idx = target // range_len
    return time_caps[idx]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:, ::-1].T
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    res = []
    shape_height = new_shape.shape[0]
    for i in range(new_board.shape[0]-shape_height+1):
        temp = np.array(new_board)
        temp_shape = np.array(new_shape)
        target_nums = temp[i:i+shape_height, c:c+new_shape.shape[1]]
        target_space = (target_nums == 0) & (temp_shape != 0)
        shape_space = temp_shape != 0
        if target_space.shape == shape_space.shape and np.sum(target_space!=shape_space) == 0:
            target_nums = temp[i:i+shape_height, c:c+new_shape.shape[1]]
            if len(target_nums[(target_nums != 0) & (temp_shape == 0)]) != 0:
                temp_shape[(temp_shape == 0) & (target_nums != 0)] = target_nums[(target_nums != 0) & (temp_shape == 0)]
            temp[i:i+shape_height, c:c+new_shape.shape[1]] = temp_shape
            res.append(temp)
        else:
            break
    return res
def animate_clear(board):
    new_board = np.array(board)
    temp = np.sum([new_board != 0], axis=0)
    true_count = temp.sum(axis=1)
    pos = np.arange(new_board.shape[0])
    target = pos[true_count == new_board.shape[1]]
    new_board[target] = np.zeros(new_board.shape[1])
    if board.shape == new_board.shape and np.sum(board!=new_board) == 0:
        return []
    res = [np.array(new_board)]
    prev_board = np.array([])
    while True:
        temp = new_board.sum(axis=1)
        pos = np.arange(new_board.shape[0])
        target = pos[temp == 0]
        new_board[1:target[-1]+1] = new_board[:target[-1]]
        new_board[0] = np.zeros(new_board.shape[1])
        if prev_board.shape == new_board.shape and np.sum(prev_board!=new_board) == 0:
            break
        res.append(np.array(new_board))
        prev_board = np.array(new_board)
    return res

xxx202xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 810, 'const': 366, 'code+const': 1176}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('For', 11)]]
import numpy as np
def get_score(board):
    sumrow=np.sum(board==0,axis=1)  
    return 40*np.sum(sumrow==0)     
def get_time_cap(board, time_caps):
    cut=len(time_caps)
    i,j=board.shape
    if np.sum(board!=0) == 0:     
        return time_caps[-1]
    sumrow=np.sum(board==0,axis=1)
    numorow=np.argmin(sumrow==board.shape[1])  
    return time_caps[numorow//(i//cut)]  
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    listdrop=[]
    i,j=shape.shape
    x,y=board.shape
    for k in range(x):
        new_board = np.array(board)   
        fshape = shape[-1:-2-k:-1][::-1]!=0  
        comt = fshape & (new_board[:k+1:,c:c+j:][-i::]==0)   
        if fshape.shape == comt.shape and np.sum(fshape!=comt) == 0: 
            if fshape.shape == shape.shape:    
                new_board[:k+1:,c:c+j:][-i::][fshape]=shape[fshape]
                listdrop.append(np.array(new_board))
        else:
            break
    return listdrop
def animate_clear(board):
    listclear=[]
    cut_board = np.array(board)
    sumrow=np.sum(board==0,axis=1)  
    cut_board[sumrow==0]=[[0]*board.shape[1]]   
    if not(cut_board.shape == board.shape and np.sum(cut_board!=board) == 0):  
            listclear.append(np.array(cut_board))
    else:
        return listclear
    for i in range(board.shape[0]):
        new_board = np.array(cut_board)
        sumrow=list(np.sum(cut_board!=0,axis=1))[::-1]
        if sumrow.count(0)==0:
            return listclear
        indexzero=-(sumrow.index(0)+1)+len(sumrow)
        cut_board[1:indexzero+1:1]=new_board[0:indexzero:1]
        cut_board[0]=new_board[indexzero]
        if not(cut_board.shape == new_board.shape and np.sum(cut_board!=new_board) == 0):  
            listclear.append(np.array(cut_board))
    return listclear

xxx025xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1126, 'const': 350, 'code+const': 1476}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 11)], [('For', 31)]]
import numpy as np
def get_score(board):
    count = board == 0
    ans = np.sum(count,axis=1)
    ans1 = sum(ans == 0)*40
    return ans1
def get_time_cap(board, time_caps):
    count = np.sum(board,axis=1)
    x = board.shape[0]
    a = sum(count == 0)
    b = len(time_caps)
    c = x/b
    d = int(a // c)
    if d+1 > b:
        ans = time_caps[-1]
    else:
        ans = time_caps[d]
    return ans
def rotate_right(shape):
    shape1 = shape[::-1,::]
    ans = shape1.T
    return ans
def rotate_left(shape):
    shape1 = shape[::,::-1]
    ans = shape1.T
    return ans
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    x = new_shape.shape[0]
    y = new_shape.shape[1]
    bx = new_board.shape[0]
    by = new_board.shape[1]
    ans = []
    i = 0
    while True:
        board1 = new_board[i::,c:c+y:]
        board2 = board1[:x:]
        board2t = board2 != 0
        shape1 = new_shape == 0
        if board2.shape[0] < new_shape.shape[0]:
            break
        board3 = board2t & shape1
        ch = board2t != board3
        ch1 = np.sum(ch)
        if ch1 != 0:
            break
        else:
            aa = np.zeros_like(board2,int) + new_shape
            emp = np.zeros((bx,by),int)
            emp[i:i+x:,c:c+y:] = aa
            new = new_board + emp
            ans.append(new)
        i += 1
    return ans
def animate_clear(board):
    new_board = np.array(board)
    ans = []
    a = new_board == 0
    aa = np.sum(a,axis=1)
    aa1 = aa == 0
    ch = sum(aa1)
    if ch == 0:
        return []
    bx = new_board.shape[0]
    by = new_board.shape[1]
    b0 = np.zeros((1,by),int)
    new_board[aa1] = b0
    ans.append(new_board)
    i = 0
    bb = new_board[::-1,::]
    num = np.arange(0,bx,1)
    bb1 = np.sum(bb,axis=1)
    ch1 = bb1 == 0
    copyflip = ch1 == False
    copyflip = copyflip[::-1]
    numflip = num[::-1]
    stop = numflip[copyflip]
    if len(stop) == 0:
        return new_board
    stop1 = stop[0]
    ch2 = num[ch1]
    ch3 = ch2 < stop1
    ch2 = ch2[ch3]
    for e in ch2:
        if e == 0:
            new3 = bb[e+1::,::]
            new3x = new3.shape[0]
            new33 = np.zeros_like(new_board,int)
            new33[:new3x:] = new3
            bb = new33
            ans.append(new33[::-1,::])
        else:
            new1 = bb[:e-i:,::]
            new1x = new1.shape[0]
            new11 = np.zeros_like(new_board,int)
            new11[:new1x:] = new1
            new2 = bb[e+1-i::,::]
            new2x = new2.shape[0]
            new22 = np.zeros_like(new_board,int)
            new22[new1x:new1x+new2x:] = new2
            newnew = new11 + new22
            bb = newnew
            ans.append(newnew[::-1,::])
        i += 1 
    return ans

xxx037xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[array([[2, 0, 0, 0],
       [1, 0, 1, 1]])], [array([[0, 2, 02, 02],
       [1, 02, 1, 1]])],
 [array([[0, 1, 05, 05, 50, 0, 0, 0],
       [0, 1, 1, 05, 05, 0, 0, 0],
       [0, 2, 2, 2, 05, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 02, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [02, 02, 2, 0, 0, 0],
       [0, 0, 02, 0, 8, 0],
       [1, 1, 02, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [02, 02, 2, 0, 8, 0],
       [1, 1, 02, 8, 8, 0],
       [1, 1, 02, 0, 8, 0]])],
 [array([[0, 0, 0, 2, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 02, 0, 0],
       [0, 0, 0, 02, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [array([[0, 0, 0, 0, 2, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, ... (more)
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]]),
  array([[0, 0, 0, 0],
       [1, 1, 0, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 2, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 0, 0, 1],
       [1, 1, 1, 0]]),
  array([[0, 0, 0, 0],
       [1, 1, 0, 0],
       [1, 2, 2, 0],
       [1, 0, 0, 1],
       [1, 1, 1, 0]]),
  array([[0, 0, 0, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 0, 0],
       [1, 2, 2, 0],
       [1, 0, 0, 0],
       [1, 0, 0, 1],
       [1, 1, 1, 0]]),
  array([[0, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 2, 2, 0],
       [1, 0, 0, 1],
       [1, 1, 1, 0]]),
  array([[0, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 0, 0, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 454, 'const': 262, 'code+const': 716}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], []]
import numpy as np
def get_score(board):
    x = (board ==0)
    y = np.sum(x, 1)
    z = np.sum(y==0)
    return z*40
def get_time_cap(board, time_caps):
    a = (board>0)
    b = np.array(a[::2,::] + a[1::2,::])
    c = np.sum(b, axis=1)
    if(np.sum(c) == 0):
        return time_caps[-1]
    else:
        d = np.argmax(c>0)
        return time_caps[d]
def rotate_right(shape):
    rShape = shape[::-1]
    t_rShape = rShape.T
    return t_rShape
def rotate_left(shape):
    tShape = shape.T
    reversed_tShape = tShape[::-1]
    return reversed_tShape
def animate_drop(board, shape, c):
    ans = []
    i = 0
    for row in board:
        newBoard = np.array(board)
        newRow = np.array(row)
        sumRow = np.sum(row[c:c+len(shape[-1]):1])
        if sumRow == 0:
            newRow[c:c+len(shape[-1]):1] = newRow[c:c+len(shape[-1]):1] + shape[-1]
            newBoard[i] = newRow
            ans.append(newBoard)
        i= i+1
    return ans
def animate_clear(board):
    return []

xxx216xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (4,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (5,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0IndexError('index 2 is out of bounds for axis 0 with size 2')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 870, 'const': 352, 'code+const': 1222}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 14)], [('While', 10)]]
import numpy as np
def get_score(board):
  nb=np.min(board,axis=1)
  nb=nb>0
  nb=np.sum(nb)*40
  return nb
def get_time_cap(board, time_caps):
  nb=np.sum(board,axis=1)
  if np.sum(board)==0:
    return time_caps[len(time_caps)-1]
  nb=nb==0
  nb=nb[::-1]
  nb=board.shape[0]-np.argmax(nb)
  l=board.shape[0]//len(time_caps)
  return time_caps[int(nb)//l]
def rotate_right(shape):
    shape = shape.T[::,::-1]
    return shape
def rotate_left(shape):
    shape = shape.T[::-1,::]
    return shape
def animate_drop(board, shape, c):
  nb = np.array(board)
  i=0
  l_v=[]
  arr=[]
  k=1
  ls=np.sum(shape>0)
  ne = np.array(board)
  ne[0,c:c+ls:]=shape
  ne=np.sum(ne==0)
  nc=np.sum(board==0)
  if nc-ne!=ls:
    return []
  while 1:
    nb = np.array(board)
    nb[i,c:c+ls:]=shape
    v=np.sum(nb==0)
    if k==0:
      if v!=l_v[-1] and k==0:
        break
    if k==1:
      k=0
    arr+=[nb]
    l_v+=[v]
    i+=1
  return arr
def animate_clear(board):
    nb = np.array(board)
    i=1
    board[np.min(board,axis=1)>0] = 0
    arr=[]
    arr+=[board]
    cO = np.max(board,axis=1)>0
    if np.min(cO==1):
      return []
    while 1:
      nb = np.array(board)
      m = np.max(nb,axis=1)[::-1]
      if np.min(m)==0:
        m = board.shape[0]-np.argmin(m)-1
      else:
        break
      nb[i:m+i:,::]=board[:m:,::]
      nb[:i:]=0
      if len(arr)>0:
        c =np.argmax(np.max(arr[-1],axis=1)>0)
        cn=np.argmax(np.max(nb,axis=1)>0)
        if c==cn:
          return arr
      arr+=[nb]
      if i:
        pass
      else:
        i+=1
      board=np.array(nb)

xxx215xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('cannot reshape array of size 3 into shape (6,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 1106, 'const': 370, 'code+const': 1476}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 28)], [('While', 11)]]
import numpy as np
def get_score(board):
    return np.sum(np.min(board,axis=1)!=0)*40
def get_time_cap(board, time_caps):
    if(np.max(np.max(board,axis=0))==0):
      return time_caps[len(time_caps)-1]
    return time_caps[ np.arange(len(time_caps))[(np.max(board.reshape(len(time_caps),board.shape[1]*int(board.shape[0]/len(time_caps))),axis=1)!=0)][0]   ]
def rotate_right(shape):
    return shape[::-1,::].T
def rotate_left(shape):
    return shape[::,::-1].T
def animate_drop(board, shape, c):
    out = []
    n = np.array(board)
    shapeh = shape.shape[0]
    shapew = shape.shape[1]
    oshape = shape.reshape(shapeh*shapew)
    tshape = np.array(shape)
    lshape = np.argmax(shape,axis=0)
    n = n[:shapeh,c:c+shapew]
    n[n!=0] = -1
    m = np.min(n,axis=0)
    n = np.argmin(n,axis=0)
    rshape = shape[::-1,::]
    slre = np.argmax(rshape,axis=0)
    slre = shapeh-slre-1
    up = 0
    cshape = np.arange(shapeh*shapew)[oshape!=0]
    e = np.sum((n<slre)&(m!=0))!=0 or np.sum(np.array(board)[up:up+shapeh,c:c+shapew].reshape(shapeh*shapew)[cshape])!=0
    if(e):
      return []
    n = np.array(board)
    n[:shapeh,c:c+shapew] = n[:shapeh,c:c+shapew] + shape
    out.append(n)
    n = np.array(board)
    up = 1
    check = np.sum(n[up:up+shapeh,c:c+shapew].reshape(shapeh*shapew)[cshape])==0
    while(check):
      n[up:up+shapeh,c:c+shapew] = n[up:up+shapeh,c:c+shapew] + shape
      out.append(n)
      up = up+1
      n = np.array(board)
      if(up+shapeh<=board.shape[0]):
        check = np.sum(n[up:up+shapeh,c:c+shapew].reshape(shapeh*shapew)[cshape])==0
      else:
        break
    return out
def animate_clear(board):
    out = []
    n = np.array(board)
    n[np.min(n,axis=1)!=0] = 0
    tw = np.sum(np.max(n,axis=1)!=0)
    if(tw==board.shape[0]):
      return []
    si = board.shape[0]-1
    out.append(n)
    while(tw!=0):
      if(np.max(n[si])==0):
        n = np.array(n)
        rev = np.arange(-1,si)
        rev[0] = si
        n[:si+1] = n[rev]
        out.append(n)
      else:
        tw-=1
        si-=1
    return out

xxx016xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 920, 'const': 338, 'code+const': 1258}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('For', 10)]]
import numpy as np
def get_score(board):
    count = np.sum(board != 0, axis=1)
    total_row = np.sum(count == board.shape[1])
    return total_row * 40
def get_time_cap(board, time_caps):
    time = time_caps * (board.shape[0] // len(time_caps))
    time_array = np.array(sorted(time))
    m = np.max(board != 0, axis=1)
    v = time_array[m]
    return time_caps[-1] if len(v) == 0 else v[0]
def rotate_right(shape):
    return shape.T[:, ::-1]
def rotate_left(shape):
    return shape.T[::-1, :]
def animate_drop(board, shape, c):
    new_shape = np.array(shape)
    l = []
    for i in range(1 - new_shape.shape[0], board.shape[0] - new_shape.shape[0] + 1):
        new_board = np.array(board)
        if i < 0:
            z = new_shape[-i:, :]
            x = new_board[0 : z.shape[0], c : z.shape[1] + c]
            y = z * x
            if np.sum(y != np.zeros_like(x)) != 0:
                return l
        else:
            copy_board = np.zeros_like(board)
            x = new_board[i : new_shape.shape[0] + i, c : new_shape.shape[1] + c]
            y = new_shape * x
            if np.sum(y != np.zeros_like(x)) == 0:
                copy_board[
                    i : new_shape.shape[0] + i, c : new_shape.shape[1] + c
                ] += new_shape
                new_board += copy_board
                l.append(new_board)
            else:
                return l
    return l
def animate_clear(board):
    t = np.array(board)
    copy_board = np.zeros_like(board)
    check = np.min(t != 0, axis=1)
    if np.sum(check) == 0:
        return []
    copy_board[check] = t[check]
    t -= copy_board
    l = [t]
    for i in range(t.shape[0]):
        skate_board = np.zeros_like(board)
        t_reverse = np.array(t[::-1, :])
        s = np.sum(t_reverse, axis=1) == 0
        a = np.argmax(s)
        pos = t.shape[0] - a - 1
        skate_board[1 : pos + 1, :] = t[0:pos, :]
        skate_board[pos + 1 :, :] = t[pos + 1 :, :]
        if np.sum(l[-1] != skate_board) == 0:
            break
        l.append(skate_board)
        t = skate_board
    return l

xxx022xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1098, 'const': 390, 'code+const': 1488}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 12)], [('For', 15)]]
import numpy as np
def get_score(board):
    Min = board.min(axis=1)
    Mark = np.sum(Min != 0)
    return Mark*40
def get_time_cap(board, time_caps):
    Sum = board.sum(axis=1)
    if np.sum(Sum == 0) == board.shape[0]: return time_caps[-1]
    Find = (Sum != 0)
    Row = np.arange(0,board.shape[0],1)
    Where = Row[Find][0]
    Ratio = board.shape[0]//len(time_caps)
    return time_caps[Where//Ratio]
def rotate_right(shape):
    return shape.T[::,::-1]
def rotate_left(shape):
    return shape.T[::-1,::]
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    value_shape = new_shape!=0
    if shape.shape[0] > board.shape[0] or c+shape.shape[1] > board.shape[1]:
        return []
    if np.sum((new_board[0:shape.shape[0],c:c+shape.shape[1]][value_shape] == np.zeros_like(shape)[value_shape])==False) != 0 :
        return []
    else:
        Ans = []
        for i in range(new_board.shape[0]):
            if i < shape.shape[0] :
                a = new_board[:i+1,c:c+shape.shape[1]][value_shape[-1-i:]] == np.zeros_like(new_board[:i+1,c:c+shape.shape[1]])[value_shape[-1-i:]]
                if np.sum((a == False)) != 0:
                    return []
            if i+shape.shape[0] <= board.shape[0]:
                if np.sum((new_board[i:i+shape.shape[0],c:c+shape.shape[1]][value_shape] == np.zeros_like(shape)[value_shape])==False) == 0:
                    new_board[i:i+shape.shape[0],c:c+shape.shape[1]][value_shape] = new_shape[value_shape]
                    Ans.append(new_board)
                    new_board = np.array(board)
                else: break
            else: break
        return Ans
def animate_clear(board):
    Ans = []
    new_board = np.array(board)
    value = np.min(new_board,axis=1) != 0
    if True in value:
        new_board[value,:] = 0
    else:
        return []
    Ans.append(new_board)
    if np.sum((new_board==0)) == np.sum(np.zeros_like(new_board,int)): return Ans
    Sum = new_board.sum(axis=1)
    Find = np.sum(Sum == 0)
    Row = np.arange(0,board.shape[0],1)
    for i in range(Find):
        Sum = np.sum(Ans[-1],axis=1)
        Where = Row[Sum == 0][-1]
        new_board = np.array(Ans[-1])
        new_board[1:Where+1,:] = new_board[0:Where,:]
        new_board[0,:] = 0
        if np.sum((new_board == Ans[-1]) == False) != 0: Ans.append(new_board)
    return Ans

xxx040xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[456, 456, 456, 456, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 05, 05, 04],
       [01, 0, 05, 04],
       [01, 0, 02, 04],
       [0, 0, 0, 0]])],
 [ array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
  [array([[0, 05, 05, 04],
       [0, 50, 50, 40],
       [10, 0, 0, 5, 40],
       [10, 0, 20, 40]])],
 [ array([[0, 0, 0, 0],
       [0, 05, 05, 04],
       [0, 50, 50, 40],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 50, 50, 40],
       [0, 05, 05, 04]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[01, 2, 0, 0],
       [2, 2, 2, 0],
       [1, 1, 0, 0]])],
 [array([[0, 0],
       [1, 0, 02, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [01, 02, 0, 0],
       [0, 0, 0, 0],
       [1, 20, 02, 04],
       [10, 0, 0, 2, 40],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [01, 02, 0, 0],
       [10, 20, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 1014, 'const': 366, 'code+const': 1380}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 9)], [('For', 9)]]
import numpy as np
def get_score(board):
    board0 = np.zeros_like(board)
    check0 = np.sum(board0==board,axis=1)
    count = np.sum(check0==0)
    return 40*count
def get_time_cap(board, time_caps):
    width = board.shape[0]//len(time_caps)
    board0 = np.zeros_like(board)
    check0 = np.sum(board0==board,axis=1)
    not0 = np.array(check0<5)
    time = time_caps*width
    time.sort()
    timea = np.array(time) 
    if np.sum(not0) == 0:
        return max(time_caps)
    else:
        q = min(timea[not0])
        return q
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    listofboard = []
    width = 0
    if len(shape.shape)==1:
        width += shape.shape[0]
    elif len(shape.shape)==2:
        width += shape.shape[1]
    for i in range(board.shape[0]-shape.shape[0]+1):
        newboard = np.array(board)
        if np.sum(newboard[i:i+shape.shape[0],c:c+shape.shape[1]])==0:
            newboard[i:i+shape.shape[0],c:c+shape.shape[1]] = shape
            listofboard.append(newboard)
        else:
            q = np.array(newboard[i+shape.shape[0]-1,c:c+shape.shape[1]]==np.zeros_like(board[i+shape.shape[0]-1,c:c+shape.shape[1]]))
            p = np.array(shape[-1]==0)
            if np.sum(p|q)==width:
                newboard[i:i+shape.shape[0],c:c+shape.shape[1]] += shape
                listofboard.append(newboard)
            break
    return listofboard
def animate_clear(board):
    listofboard = []
    board0 = np.zeros_like(board)
    newboard = np.array(board)
    check = np.sum(newboard==board0,axis=1)
    newboard[check==0] = board0[0]
    listofboard.append(newboard)
    for i in range(board.shape[0]-1,-1,-1):
        if np.sum(newboard[i]==board0[i])==board.shape[1]:
            newboard[1:i+1] = newboard[0:i] 
            newboard[0] = board0[0]
            listofboard.append(newboard)
        if np.sum(newboard[i]==board0[i])==board.shape[1]:
            newboard[1:i+1] = newboard[0:i] 
            newboard[0] = board0[0]
            listofboard.append(newboard)
        if np.sum(newboard[:i]==board0[:i])==i*board.shape[1]:
            break
    return listofboard

xxx018xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 02],
       [1, 21, 20, 0]]),
       array([[1, 1, 0, 10],
       [1, 1, 12, 02]])],
 [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1158, 'const': 390, 'code+const': 1548}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 6)]]
import numpy as np
def get_score(board):
    points=board[::]!=0
    check=np.sum(points,axis=1)
    return np.sum(check[::]==board.shape[1])*40
def get_time_cap(board, time_caps):
    new=board[::]!=0
    check=np.sum(new,axis=1)
    if np.sum(check)!=0:
        checker=np.array(check!=0)
        index=np.arange(board.shape[0])
        tindex=index[checker]
        range=board.shape[0]//len(time_caps)
        level=index.reshape((len(time_caps),range))
        ans=np.sum(level==tindex[0],axis=1)
        tc_index=np.arange(ans.shape[0])
        answer=ans==1
        real=time_caps[tc_index[answer==True][0]]
        return real
    else:
        return(time_caps[-1])
def rotate_right(shape):
    new=shape.T
    right=new[::,::-1]
    return right
def rotate_left(shape):
    new=shape.T
    left=new[::-1]
    return left
def animate_drop(board, shape, c):
    answer=[]
    for i in range(board.shape[0]):
        if c not in np.arange(board.shape[0]-shape.shape[0]):
            break
        newboard=np.array(board)
        board0=np.zeros((newboard.shape[0],newboard.shape[1]),int)
        shape0=np.zeros((shape.shape[0],newboard.shape[1]),int)
        shape0[::-1,c:c+shape.shape[1]:]=shape[::-1]
        if i+shape0.shape[0]<=board0.shape[0]:
            board0[i:i+shape0.shape[0]:]=shape0
        newboard+=board0
        boolcheck=newboard==board
        if np.sum(newboard[boolcheck==False])!=np.sum(shape0):
            break
        else:
            answer.append(newboard)
    return answer
def animate_clear(board):
    newboard=np.array(board)
    ans=[]
    i=1
    while True:
        newboard=np.array(newboard)
        points=newboard[::]!=0
        check=np.sum(points,axis=1)
        newboard[check==board.shape[1]]=np.zeros((newboard[check==board.shape[1]].shape[0],board.shape[1]),int)
        if len(ans)==0 or False not in (newboard!=board):
            ans.append(np.array(newboard))
        elif False not in (newboard!=ans[-1]):
            ans.append(np.array(newboard))
        board0=np.zeros((newboard.shape[0],newboard.shape[1]),int)
        shape0=np.zeros((1,newboard.shape[1]),int)
        shape0[0]=newboard[-i-1]
        if False in (newboard[-i-1]==np.zeros((newboard.shape[1]),int)) and False not in (newboard[-i]==np.zeros((newboard.shape[1]),int)):
            newboard[-i]=shape0
            newboard[-i-1]=np.zeros((1,newboard.shape[1]),int)
        if i<board.shape[0]-1:
            i+=1
        else:
            if len(ans)!=0 and (np.sum(( newboard!=ans[-1])))==0:
                break
            ans.append(newboard)
            i=1
    if False not in (ans==board):
        return []
    return ans

xxx212xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0ValueError('operands could not be broadcast together with shapes (0,) (4,) ')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1008, 'const': 372, 'code+const': 1380}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 10)], [('While', 10)]]
import numpy as np
def get_score(board):
    a = board.min(axis = 1)
    return int((sum(a != 0))*40)
def get_time_cap(board, time_caps):
    pos = np.arange(board.shape[0])
    phase = int(board.shape[0]/len(time_caps))
    data = ((pos[(board.max(axis = 1)) != 0 ]))
    if len(data) == 0: return time_caps[-1]
    num = int(((min(data)+1+phase-0.5)//phase))
    return int(time_caps[num-1])
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    nboard = np.array(board)
    revboard = np.array(board)
    answ = []
    deep = shape.shape[0]
    wide = shape.shape[1]
    data = sum(sum([(nboard[:,c:c+wide].max(axis = 1)) == 0 ]))
    d = 0
    if (sum(sum((nboard) == 0))) + (sum(sum((shape) != 0)))  == (sum(sum((board) == 0))) and (sum(sum((nboard[d:d+deep,c:c+wide]) != 0))) != 0 : return []
    while True:
        nboard[d:d+deep,c:c+wide] += shape
        paste = np.zeros_like(board,int)
        paste[d:d+deep,c:c+wide] += shape
        if (sum(sum((nboard) == 0))) + (sum(sum((shape) != 0)))  != (sum(sum((board) == 0))) or d+deep == nboard.shape[0]: break
        answer = np.array(nboard)
        answ.append(answer)
        nboard = np.array(board)
        d+=1
    if (sum(sum((nboard) == 0))) + (sum(sum((shape) != 0)))  == (sum(sum((board) == 0))):
        answer = np.array(nboard)
        answ.append(answer)
    return answ
def animate_clear(board):
    ans = []
    nboard = np.array(board)
    num = np.arange(board.shape[0])
    position = num[nboard.min(axis = 1) != 0]
    if len(position) == 0 : return []
    nboard[position] = np.zeros_like(nboard[position],int)
    answer = np.array(nboard)
    ans.append(answer)
    while True:
        npos = [nboard.max(axis = 1) != 0]
        bars = nboard[tuple(npos)]
        row = num[tuple(npos)]
        maxi = num[-len(row):]
        key = (num[tuple(npos)] - maxi)
        realrow = row[key < 0]
        if len(realrow) == 0: break
        newblock = nboard[realrow]
        nboard[realrow] = np.zeros_like(nboard[realrow ],int)
        nboard[realrow +1] = newblock
        answer = np.array(nboard)
        ans.append(answer)
    return ans

xxx026xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1024, 'const': 310, 'code+const': 1334}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [('any', 2)], [], [], [], [('all', 9)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('For', 19)]]
import numpy as np
def get_score(board):
    nb = np.zeros_like (board, int)
    rose = (nb == board)
    s = np.sum(rose,1)
    ns = np.zeros_like (s, int)
    r = (ns == s)
    ss = np.sum(r,0)
    ans = ss*40
    return(int(ans))
def get_time_cap(board, time_caps):
    if board.any() == False :
        return(time_caps[-1])
    nb = np.zeros_like (board, int)
    rose = (nb != board)
    s = np.sum(rose,1)
    ns = np.zeros_like (s, int) 
    r = (ns != s)
    x = np.arange(0, len(r),)
    a = x[r]
    i = a[0]
    ans = i//(board.shape[0]/len(time_caps))
    return(time_caps[int(ans)])
def rotate_right(shape):
    z = np.array(shape[::-1,::])
    rose = z.T
    return(rose)
def rotate_left(shape):
    z = shape.T
    rose = np.array(z[::-1,::])
    return(rose)
def animate_drop(board, shape, c):
    l = []
    nb = np.array(board)
    ns = np.array(shape)
    size = ns.shape
    for i in range(nb.shape[0]-ns.shape[0]+1) :
        cb = nb[i:size[0]+i,c:size[1]+c]
        cp = np.zeros_like (cb, int)
        cc = (cb == cp)
        zs = np.zeros_like (ns, int)
        nss = (ns == zs)
        x = (nss | cc)
        if False in x :
            break
        else :
            nb[i:size[0]+i,c:size[1]+c] += ns
            l.append(nb)
            nb = np.array(board)
    return(l)
def animate_clear(board):
    ans = []
    c = 0
    nb = np.array(board)
    cc = (nb == np.zeros_like(nb))
    s = np.sum(cc,1)
    cs = (s == (np.zeros_like(s)))
    nb[cs] = np.array([0])
    if (nb == board).all() :
        return([])
    ans.append(nb)
    nbd = np.array(board)
    se = nbd != np.array([0])
    czo = np.sum(se,axis=1)
    x = czo == nbd.shape[1]
    if True in x:
        nbd[x] = np.zeros_like(nbd.shape[1])
    nsbd = np.array(nbd)
    for i in range(1,board.shape[0]+1):
        if False not in (nbd[-i] == np.zeros_like(nbd.shape[1])):
            if False in (nbd[0:-i] == np.zeros_like(nbd.shape[1])):
                c += 1
                nsbd[1:nbd.shape[0]-i+c,::] = nsbd[0:nbd.shape[0]-i-1+c,::]
                nsbd[0,::] = np.zeros_like(nbd.shape[1])
                gg = np.array(nsbd)
                ans.append(gg)
    return ans

xxx218xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 872, 'const': 338, 'code+const': 1210}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('For', 12)]]
import numpy as np
def get_score(board):
    check = board != 0
    a = np.array(check,int)
    b = np.min(a,axis=1)
    c = sum(b)*40
    return c
def get_time_cap(board, time_caps):
    check = board != 0
    b = np.max(check,axis=1)
    k = np.arange(board.shape[0])
    c = k[b]
    if len(c)==0 :
      return time_caps[-1]
    time = time_caps[(c[0])//(len(board)//len(time_caps))]
    return time
def rotate_right(shape):
    shape_transpote = shape.T
    shape_right = shape_transpote[:,::-1]
    return shape_right
def rotate_left(shape):
    shape_transpote = shape.T
    shape_left = shape_transpote[::-1,:]
    return shape_left
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    check = new_shape != 0
    result = []
    for i in range(new_board.shape[0]-new_shape.shape[0]+1):
        slice_board = new_board[i:i+new_shape.shape[0]:,c:c+new_shape.shape[1]:]
        if np.sum(slice_board[check]) == 0:
            decorated = slice_board + new_shape
            very_new_board = np.array(new_board)
            very_new_board[i:i+new_shape.shape[0]:,c:c+new_shape.shape[1]:] = decorated
            result.append(very_new_board)
        else: break
    return result
def animate_clear(board):
    check = board != 0
    b = np.min(check, axis = 1)
    k = np.arange(board.shape[0])
    c = k[b]
    result = []
    cleared_board = np.array(board)
    cleared_board[c] = 0
    if len(c) != 0:
        result.append(np.array(cleared_board))
    for e in range (cleared_board.shape[0]):
        check_zero = np.sum(cleared_board, axis = 1)
        column = np.arange(cleared_board.shape[0])
        temp = column[check_zero == 0]
        if len(temp) == 0 or len(temp) == cleared_board.shape[0] :
          break
        j = temp[np.sum(cleared_board[temp-1] == 0, axis = 1) != cleared_board.shape[1]]
        cleared_board[1:j[-1]+1] = cleared_board[0:j[-1]]
        cleared_board[0] = 0
        cop = cleared_board.copy()
        result += [cop]
        if np.sum(cop[:len(temp)] == np.zeros_like(cop[:len(temp)],int)) == cop[:len(temp)].shape[0]*cop.shape[1]:
          break
    return result

xxx021xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 870, 'const': 404, 'code+const': 1274}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 12)]]
import numpy as np
def get_score(board):
    zero_board=np.zeros((board.shape),int)    
    check_board=(zero_board==board).sum(axis=1)    
    return ((check_board==0).sum()*40)
def get_time_cap(board, time_caps):
    section=len(board)//len(time_caps)
    zero_board=np.zeros((board.shape),int)  
    check_board=(zero_board!=board).sum(axis=1)
    no_of_zero=(check_board==0).sum()
    nd_board=np.ndarray(len(time_caps)+1)
    nd_board[:len(time_caps)]=time_caps
    nd_board[-1]=time_caps[-1]    
    first_row=no_of_zero
    return int(nd_board[first_row//section])
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    ans=[]
    new_shape = np.array(shape)
    space = (board != 0)
    for r in range(len(board)-len(shape)+1):        
        new_board = np.array(board)
        new_board[r:r+len(shape),c:c+len(shape[0])]=(new_board[r:r+len(shape),c:c+len(shape[0])] + new_shape)        
        if np.sum(board == (new_board*space)) == (len(board)*len(board[0])) :
            ans.append(np.array(new_board))
        else :
            break
    return ans
def animate_clear(board):
    ans=[]
    zero_board=np.zeros((board.shape),int)
    index_zero_check=np.arange((board.shape[0])) 
    new_board = np.array(board)
    check_board= (board==zero_board).sum(axis=1) 
    row_clear = index_zero_check[check_board==0] 
    new_board[row_clear]=np.zeros(new_board[row_clear].shape) 
    ans.append(new_board)
    while not ((new_board)==(move(new_board))).sum() == np.ones((board.shape),int).sum():
        new_board=move(new_board)
        ans.append(new_board)
    if len(ans) > 1 :return ans
    else: return []
def move(board):
    zero_board=np.zeros((board.shape),int)
    index_zero_check=np.arange((board.shape[0])) 
    check_board= (board!=zero_board).sum(axis=1) 
    new_board =zero_board
    if (check_board==0).sum() != 0:
        new_board[1:(index_zero_check[check_board==0][-1]+1)]=board[:index_zero_check[check_board==0][-1]]
        new_board[(index_zero_check[check_board==0][-1]+1):]=board[(index_zero_check[check_board==0][-1]+1):]
        return new_board
    else:
        return board

xxx205xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 874, 'const': 350, 'code+const': 1224}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 20)]]
import numpy as np
def get_score(board):
    a = board == 0
    a = np.sum(a,axis=1) == 0
    return np.sum(a) * 40
def get_time_cap(board, time_caps):
    n = board.shape[0]//len(time_caps)
    x = np.arange(0,board.shape[0])
    a = board != 0
    a = np.sum(a,axis=1) != 0
    if np.sum(a) == 0 :
        return time_caps[-1]
    s = x[a][0]//n
    return time_caps[s]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    x = np.sum(board != 0)
    y = np.sum(shape != 0)
    s = []
    for i in range(board.shape[0] - shape.shape[0] + 1 ) :
        b = np.array(board)
        t = np.array(shape != 0)
        S = np.array(b[i:i + shape.shape[0],c:c+shape.shape[1]])
        S[shape != 0] = shape[t]
        b[i:i + shape.shape[0],c:c+shape.shape[1]] = S[:,:]
        if x + y == np.sum(np.array(b) != 0) :
            s.append(b)
        else : break
    return s
def animate_clear(board):
    d = np.sum(board == 0,axis = 1) == 0
    board[d,:] = 0
    d = np.sum(board == 0,axis = 1) == board.shape[1]
    if np.sum(d) == 0:
        return []
    x = []
    x.append(np.array(board))
    first_zero = np.sum(board,axis=1) == 0
    count = np.arange(0,first_zero.shape[0])
    if np.sum(first_zero == False) == 0 :
        return x
    n_zero = count[first_zero == False][0]
    board = board[::-1]
    n = np.sum(np.sum(board,axis=1) == 0) - n_zero
    i = 0
    c = 0
    new_b = np.array(board)
    while c < n :
        if sum(board[i]) == 0 :
            board[i:-1] = board[i+1:]
            board[-1] = 0
            c += 1
            x.append(np.array(board[::-1]))
        else :
            i += 1
    return x

xxx206xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 848, 'const': 322, 'code+const': 1170}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 11)]]
import numpy as np
def get_score(board):
  a = np.min(board,axis = 1)
  b = np.ones_like(a)
  c = b[a >= 1]
  return len(c)*40
def get_time_cap(board, time_caps):
  a = board.reshape((len(time_caps),len(board[0])*int(len(board)/len(time_caps))))
  b = np.max(a,axis = 1)
  d = np.array(time_caps)
  c = d[b > 0]
  if len(c) == 0:
    return max(time_caps)
  else:
    return np.min(c)
def rotate_right(shape):
  a = shape[::-1]
  b = a.T
  return b
def rotate_left(shape):
  a = shape[::-1,::-1]
  b = a.T
  c = b.T
  d = c.T
  return d[:,::-1]
def animate_drop(board, shape, c):
    l = []
    new_board = np.array(board)
    new_shape = np.array(shape)
    for i in range(board.shape[0]-(len(shape)-1)):
        if False not in ((new_shape[:,:] * new_board[i:len(new_shape)+i,c:len(new_shape[0])+c]) == 0):
            new_board[i:len(new_shape)+i,c:len(new_shape[0])+c] += new_shape[:,:]
            l.append(new_board)
            new_board = np.array(board)
        else:
            return l
    return l
def animate_clear(board):
    l = []
    new_board = np.array(board)
    if False not in (np.min(new_board , axis = 1) == 0):
        return l
    new_board[(np.min(new_board , axis = 1) != 0)] = 0
    l.append(new_board)
    i = 1
    ne_board = np.array(new_board)
    while True:
        if np.max(ne_board[-i,:]) == 0:
            if False not in (ne_board[1:len(ne_board)-i+1,:] == ne_board[0:len(ne_board)-i,:]):
                break
            ne_board[1:len(ne_board)-i+1,:] = ne_board[0:len(ne_board)-i,:]
            ne_board[0,:] = 0
            n_board = np.array(ne_board)
            l.append(n_board)
            i = 1
        else:
            i += 1
    return l

xxx022xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[56, 56, 56, 56, 45, 45, 456]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 762, 'const': 374, 'code+const': 1136}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 11)], [('While', 9)]]
import numpy as np
def get_score(board):
  return np.sum(np.min(board, axis=1) != 0)*40
def get_time_cap(board, time_caps):
  z = np.argmin(np.max(board, axis=1) == 0)
  n = board.shape[0]/len(time_caps)
  if z != 0:
    return time_caps[int(z//n)]
  else:
    return time_caps[-1]
def rotate_right(shape):
  return shape.T[::,-1::-1]
def rotate_left(shape):
  return rotate_right(rotate_right(rotate_right(shape)))
def animate_drop(board, shape, c):
  nb = np.array(board)
  sl = shape.shape[1]
  sr = shape.shape[0]
  sc = shape != 0
  out = []
  if np.sum((board[:sr,c:sl+c] != 0) & sc[-1,:]) != 0:
    return []
  n = 0
  while np.sum((board[n:sr+n,c:sl+c] != 0) & sc) == 0:
    nb[n:sr+n,c:sl+c] += shape
    out.append(nb)
    nb = np.array(board)
    n += 1
    if n >= board.shape[0]-sr+1:
      break
  return out
def animate_clear(board):
  out = []
  nb = np.array(board)
  if get_score(board) != 0:
    nb[np.min(board, axis=1) > 0] = np.zeros_like(board[0],int)
    out.append(nb)
    i,n = 1,-1
    while i < board.shape[0]:
      if np.sum(nb[n,:]) != 0:
        n -= 1
        pass
      else:
        nb1 = list(nb[:n,:])
        if n < -1:
          nb1 = nb1 + list(nb[n+1:,:])
        nb2 = list(np.zeros_like(board[0,:]).reshape(1,board.shape[1])) + nb1
        nb = np.array(nb2)
        out.append(nb)
      i += 1
    return out
  else:
    return []

xxx214xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1002, 'const': 526, 'code+const': 1528}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 9)], [('For', 15)]]
import numpy as np
def get_score(board):
    bboard=np.array(board)
    not_zero=np.array( np.min(bboard, axis=1) !=0)
    score=len(bboard[not_zero])*40
    return int(score)
def get_time_cap(board, time_caps):
    time=list()
    time.append(time_caps[-1])
    bboard=np.array(board)
    bboard=bboard.reshape( (len(time_caps), int(bboard.shape[1]*(len(board)/len(time_caps)))) )
    not_zero=np.array( np.max(bboard, axis=1) !=0)
    time_=list(np.array(time_caps)[not_zero])+time
    return int(time_[0])
def rotate_right(shape):
    sshape=np.array(shape)
    sshape=sshape[::-1,:]
    return sshape.T
def rotate_left(shape):
    sshape=np.array(shape)
    sshape=sshape[:,::-1]
    return sshape.T
def animate_drop(board, shape, c):
    bboard=np.array(board)
    sshape=np.array(shape)
    out=list()
    board_is_zero=np.array(board==0, dtype='bool')
    shape_not_zero=np.array(shape==0, dtype='bool')
    for i in range(bboard.shape[0]):
      bboard=np.array(board)
      j=i
      k=i+1-sshape.shape[0]
      if k<0:
        k=0
      if j>sshape.shape[0]:
        j=sshape.shape[0]-1
      bool_=(board_is_zero[np.arange(k,i+1),c:c+sshape.shape[1]] | shape_not_zero[-1:-(j+2):-1,:][::-1,])
      if False not in bool_:
        bboard[np.arange(k,i+1),c:c+sshape.shape[1]]+=sshape[-1:-(j+2):-1,:][::-1,:]
        if i>=sshape.shape[0]-1:
          out.append(bboard)
      else:
        break
    return out
def animate_clear(board):
    bboard=np.array(board)
    out=list()
    backupline=list()
    re=0
    clear=np.array( np.min(bboard, axis=1) !=0, dtype='bool')
    if True in clear:
      bboard[clear]=np.array([0])
      out.append(bboard)
    else:
      return out
    shift=np.array( np.max(bboard, axis=1) ==0, dtype='bool')
    line=list(np.arange(bboard.shape[0]))
    for i in range(-1,-len(shift),-1):
      if shift[i]:
        if not (False in (shift[-len(shift):i:1])):
          break
        pop_=line.pop(i+re)
        backupline.append(pop_)
        bboard_=bboard[np.array(backupline+line), : ]
        out.append(bboard_)
        re+=1
    return out

xxx009xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 698, 'const': 362, 'code+const': 1060}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('For', 13)]]
import numpy as np
def get_score(board):
  a = board.min(axis=1)
  b = sum(a != 0)
  return b*40
def get_time_cap(board, time_caps):
  r = board.shape[0]
  l = len(time_caps)
  s = r/l
  a = board.max(axis=1)
  pos = np.arange(r)
  p = pos[a != 0]
  if len(p) != 0:
    return time_caps[p[0]//int(s)]
  else:
    return time_caps[-1]
def rotate_right(shape):
  return shape.T[:,::-1]
def rotate_left(shape):
  return shape.T[::-1]
def animate_drop(board, shape, c):
  R,C = board.shape
  s,h = shape.shape
  x = []
  new_board = np.array(board)
  for i in range(R-s+1):
    if False not in ((board[i:i+s,c:c+h] == 0) | (shape == 0)):
      new_shape = np.zeros((R,C),int)
      new_shape[i:i+s,c:c+h] = shape
      new_board2 = new_board + new_shape
      x.append(new_board2)
    else: break
  return x
def animate_clear(board):
  x = []
  R,C = board.shape
  pos = np.arange(R)
  s = board.min(axis=1)
  new_board = np.array(board)
  if len(pos[s != 0]) != 0:
    p = pos[s != 0]
    z = np.zeros((1,C),int)
    new_board[p] = z
    x.append(new_board) 
    for i in range(R):
      s1 = new_board.sum(axis=1)
      pl = pos[s1 == 0][-1]
      if False not in (new_board[:pl].sum(axis=1) == np.array([0]*len(new_board[:pl]))): break
      else:
        new_board2 = np.array(new_board)
        new_board2[0] = z
        new_board2[1:pl+1] = new_board[0:pl]
        x.append(new_board2)
        new_board = new_board2
  return x

xxx017xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 20, 20, 20],
       [0, 0, 2, 0, 0, 20],
       [0, 0, 2, 0, 8, 20],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[20, 20, 20, 2, 2, 2],
       [0, 0, 20, 0, 0, 2],
       [0, 0, 20, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[20, 20, 20, 0, 0, 0],
       [0, 0, 20, 2, 2, 2],
       [0, 0, 20, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 880, 'const': 358, 'code+const': 1238}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 7)]]
import numpy as np
def get_score(board):
    x=np.min(board, axis=1)
    y=x!=0
    score=len(x[y])*40
    return score
def get_time_cap(board, time_caps):
    t=len(time_caps)
    b=board.shape[0]*board.shape[1]
    a=board.reshape((t,b//t))
    ze=np.max(a, axis=1) >0
    try:
        out=np.array(time_caps)[ze][0]
        return out
    except:
        return time_caps[-1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    a=board.copy()
    l=[]
    ze=np.zeros((shape.shape[0],shape.shape[1]),int)
    for i in range(board.shape[0]):
        s=shape==0
        try:
            replace=board[i:shape.shape[0]+i,c:len(shape[0])+c][s]
            ze[s]=replace
        except:
            break
        if str(board[i:shape.shape[0]+i,c:len(shape[0])+c])==str(ze):
            toreplace=board[i:shape.shape[0]+i,c:len(shape[0])+c]+shape
            board[i:shape.shape[0]+i,c:len(shape[0])+c] = toreplace
            l.append(board)
        board=a.copy()
    return l
def clear_board(board):
    x=np.min(board, axis=1)
    y=x!=0
    board[y]=np.zeros((1,board.shape[1]))
    return board
def animate_clear(board):
    x= clear_board(board)
    i=0
    c=0
    output=[]
    while i<x.shape[0]:
        if i ==0:
            output.append(x.copy())
        else:
            if str(x[-i])==str(np.zeros((1,x.shape[1]),int)[0]):
                replaceboard=x[c:-i].copy()
                if replaceboard.shape[0]==0:
                    break
                x[0+c]=0
                c+=1
                x[c:replaceboard.shape[0]+c]=replaceboard.copy()
                output.append(x.copy())
                i-=1
        i+=1
    if len(output)==1:
      output=[]
    return output

xxx121xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (4,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (6,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (3,)')
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 470, 'const': 338, 'code+const': 808}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 3)], []]
import numpy as np
def get_score(board):
    b = np.min(board , axis=1)
    return len(b[b>0])*40
def get_time_cap(board, time_caps):
  b = board.sum(axis=1) == 0
  c = len(b[b==True])
  if len(board) == c: return time_caps[-1]
  n = len(board)/len(time_caps)
  if c%n == 0: return time_caps[int(c/n)]
  elif c/n<1: return time_caps[0]
  else: return time_caps[int((c+1)/n)]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
  ans = []
  for i in range(len(board)):
    n_board = np.array(board)
    if board[i,c] == 0:
      n_board[i,c:] = shape
      ans.append(n_board)
    else: return ans
def animate_clear(board):
  ans = []
  n_board = np.array(board)
  b = np.min(n_board, axis=1) != 0
  if len(b[True]) != 0:
    n_board[b==True] = np.zeros(len(n_board[0]),int)
    ans.append(n_board)
  else: return ans

xxx038xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1078, 'const': 352, 'code+const': 1430}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 4)], [('While', 7)]]
import numpy as np
def get_score(board):
    return len(board[np.arange(len(board))[np.sum(board == 0, axis = 1) == 0]])*40
def get_time_cap(board, time_caps):
    s = np.sum(board != 0, axis = 1) != 0
    if np.sum(s) != 0:
        f = np.arange(len(board))[s][0]
        i1 = np.arange(0,len(board),len(board)//len(time_caps))
        i2 = i1 + ((len(board)//len(time_caps) - 1))
        return np.array(time_caps)[(f >= i1) & (f <= i2)][0]
    else:
        return time_caps[-1]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return (shape.T)[::-1]
def animate_drop(board, shape, c):
    ans = []; b = np.array(board); i = 0; s = -1
    while i != len(board):
        r = np.arange(-1, s-1, -1); sh = shape[r][::-1]
        if len(b[i:i+len(sh):, c:c+len(shape[0])]) != len(sh): break
        if np.sum(b[i:i+len(sh):, c:c+len(shape[0])][sh != 0]) != 0: break
        if s == -1*len(shape):
            b[i:i+len(sh):, c:c+len(shape[0])] += sh; ans.append(np.array(b))
            b = np.array(board); i += 1; s = -1
        else: s -= 1
    return ans
def animate_clear(board):
    b = np.array(board); b[np.arange(len(board))[np.sum(board == 0, axis = 1) == 0]] = np.array([0])
    b1 = np.array(b); b2 = np.array(b1); ze = b2[np.arange(len(board))[np.sum(b2 != 0, axis = 1) == 0]]
    ans = []; i = 0; n = []
    if np.sum(board != b2) == 0: return ans
    while True:
        if np.sum(b[i]) != 0 and np.sum(b[i+1]) != 0:
            n += [b[i]]
        elif np.sum(b[i]) != 0 and np.sum(b[i+1]) == 0:
            n += [b[i]]; b1[i-len(n)+2:i+2:] = np.array(np.array(n)); b1[i+1-len(n)] = np.array([0]);n = []
        i += 1
        if i == len(b) - 1: i = 0; ans.append(np.array(b1)); b = np.array(b1); n = []
        if np.sum(b[:len(ze):]) == np.sum(ze): ans.insert(0, b2); break
    return ans

xxx208xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 726, 'const': 324, 'code+const': 1050}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 15)]]
import numpy as np
def get_score(board):
    return sum(np.min(board,axis=1) != 0) * 40
def get_time_cap(board, time_caps):
    if np.sum(board) != 0:
        r,c = board.shape
        ch = np.sum(board,axis=1) != 0
        ch2 = ch.reshape((len(time_caps),r//len(time_caps)))
        ch3 = np.sum(ch2,axis=1) != 0
        return np.array(time_caps)[ch3][0]
    else:
        return time_caps[-1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    rs,cs = shape.shape
    results = []
    len_loop = len(new_board) - len(new_shape) + 1
    for i in range(len_loop):
        temporary = np.array(new_board)
        pos_put = temporary[i:i+rs,c:c+cs]
        bool_sh = shape != 0
        if sum(pos_put[bool_sh]) == 0:
            temporary[i:i+rs,c:c+cs] = temporary[i:i+rs,c:c+cs] + shape
            results.append(temporary)
        else: break
    return results
def animate_clear(board):
    r,c = board.shape
    new_board = np.array(board)
    ch = np.min(board,axis=1) != 0
    new_board[ch] = np.zeros((c),int)
    start = np.array(new_board)
    results = []
    if np.sum(ch) != 0:
        results.append(start)
    n = board.shape[0] - 1
    a = 0
    while a != r:
        if np.sum(new_board[n]) == 0:
            if np.sum(new_board[:n]) == 0:
                  break
            new_board[1:n+1] = new_board[:n]
            new_board[0] = np.zeros((1,c),int)
            next_array = np.array(new_board)
            results.append(next_array)
        else:
            n -= 1
        a += 1
    return results

xxx209xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (2,3) (3,3) (2,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 712, 'const': 254, 'code+const': 966}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 12)]]
import numpy as np
def get_score(board):
    cond_board = np.sum(board == 0, 1) == 0
    ones = np.ones(board.shape[0])
    return ones[cond_board].shape[0] * 40
def get_time_cap(board, time_caps):
    new_board = board.reshape(len(time_caps), -1)
    cond_board = np.sum(new_board, 1) == 0
    if False in cond_board:
        return time_caps[np.argmin(cond_board)]
    else:
        return time_caps[len(time_caps)-1]
def rotate_right(shape):
    return shape[::-1, :].T
def rotate_left(shape):
    return shape[:, ::-1].T
def animate_drop(board, shape, c):
    drop_animation = []
    shape_h, shape_l = shape.shape[0], shape.shape[1]
    shape_loc = shape > 0
    col_end = c+shape_l
    if np.sum(board[:shape_h,c:col_end]) > 0:
      return []
    for r in range(board.shape[0]):
        row_end = r+shape_h
        new_board = np.array(board)
        board_w_shape = new_board[r:row_end,c:col_end]
        board_w_shape += shape
        if np.sum(board_w_shape[shape_loc] != shape[shape_loc]) > 0:
            return drop_animation
        drop_animation.append(np.array(new_board))
    return drop_animation
def animate_clear(board):
    clear_animation = []
    new_board = np.array(board)
    row_to_0 = (np.min(new_board, 1) != 0)
    if np.sum(row_to_0) > 0:
        new_board[row_to_0] = 0
    else:
        return []
    board_h, board_l = board.shape[0], board.shape[1]
    clear_animation.append(np.array(new_board))
    while 1:
        old_board = np.array(new_board)
        new_board = np.array(new_board)
        row_swap = board_h - np.argmin(np.max(new_board, 1)[::-1])
        if not np.sum(np.max(new_board, 1) == 0):
            return clear_animation
        swap = new_board[:row_swap-1,:]
        new_board[1:row_swap] = swap
        new_board[0] = 0
        clear_animation.append(new_board)
        if np.min(old_board == new_board):
            return clear_animation[:-1]

xxx041xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 482, 'const': 280, 'code+const': 762}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], []]
import numpy as np
def get_score(board):
    zeros = np.zeros(board.shape[1])
    range = np.arange(board.shape[0])
    x = board == zeros
    y = range[np.sum(x,axis = 1) == 0]
    return 40*y.shape[0]
def get_time_cap(board, time_caps):
    zeros = np.zeros(board.shape[1])
    range = np.arange(board.shape[0])
    x = board == zeros
    y = range[np.sum(x,axis = 1) < board.shape[1] ]
    if not y.shape[0]:
      return time_caps[-1]
    return time_caps[y[0]//2]
def rotate_right(shape):
    x = shape.T
    return x[:,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    res = []
    rboard = board.shape[0]
    rshape = shape.shape[0]
    cshape = shape.shape[1]
    for i in range(rboard - rshape+1):
        new_board = np.array(board)
        part = board[i:i+rshape, c:c+cshape]
        if np.dot(part.reshape(rshape*cshape),shape.reshape(rshape*cshape)) == 0:
            new_board[i:i+rshape, c:c+cshape] += shape
            res.append(new_board)
    return res
def animate_clear(board):
    pass

xxx026xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 724, 'const': 338, 'code+const': 1062}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 14)]]
import numpy as np
def get_score(board) :
    a = board != 0
    b = a.sum(axis=1)
    op = (len(b[b == len(board[0])]))*40
    return op
def get_time_cap(board, time_caps):
    a = board != 0
    b = a.sum(axis=1)
    c = b != 0
    if len(c[b != 0]) != 0:
        pos = np.arange(len(b))
        poss = pos[c][0]
        d = len(board)//len(time_caps)
        postc = poss//d
        return time_caps[postc]
    else : return time_caps[-1]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:, ::-1].T
def animate_drop(board, shape, c):
    ans = []
    row_board = board.shape[0]
    row_shape = shape.shape[0]
    col_shape = shape.shape[1]
    cnt = np.sum(board != 0) + np.sum(shape != 0)
    for i in range (0,row_board - row_shape + 1):
      new_board = np.array(board)
      new_board[i:i+row_shape,c:c+col_shape] += shape
      if cnt == np.sum(new_board != 0):
        ans.append(np.array(new_board))
      else:
        break
    return ans
def animate_clear(board):
    ans = []
    new_board = np.array(board)
    row = board.shape[0]
    col = board.shape[1]
    arr = (board != 0)
    sum = np.sum(arr,axis=1)
    chk = (sum==col)
    new_board[chk,:] = 0
    if np.sum(new_board - board) == 0:
      return ans
    ans.append(np.array(new_board))
    while True:
      all_empty_row = np.sum(new_board,axis=1) == 0
      idx = np.arange(row)
      last_row = idx[all_empty_row][-1]
      if np.sum(new_board[:last_row,:]) == 0:
        break
      new_board[1:last_row+1,:] = new_board[0:last_row,:]
      new_board[0] = 0
      ans.append(np.array(new_board))
    return ans

xxx207xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1242, 'const': 350, 'code+const': 1592}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('For', 15)]]
import numpy as np
def get_score(board):
    a = board[np.min(board,axis=1) != 0]
    b = len(a)*40
    return b
def get_time_cap(board, time_caps):
    a = np.argmax(np.max(board,axis=1) != 0)
    if a == 0:
        if np.max(board[0]) == 0:
            return time_caps[-1]
        else:
            return time_caps[0]
    else:
        return time_caps[a//(len(board)//len(time_caps))]
def rotate_right(shape):
    return np.array(shape[::-1,::].T)
def rotate_left(shape):
    return np.array(shape[::,::-1].T)
def animate_drop(board, shape, c):
    l = []
    row = shape.shape[0] 
    col = shape.shape[1] 
    for i in range(len(shape)-1,len(board)):
        test_board = np.array(board)
        k = i+1-row
        if k < 0:
            k = 0
        j = row-1-i
        if j < 0 :
            j = 0
        kar_line = sum(sum(test_board[k:i+1:,c:col+c:]))
        sum_be = sum(test_board[i])+sum(shape[row-1])
        if kar_line == 0:
            test_board[k:i+1:,c:col+c:] = shape[j:row:] 
            sum_af = sum(test_board[i])
            l.append(np.array(test_board))
        else:
            n1 = sum(test_board[k:i+1:,c:col+c:]) 
            n2 = shape[row-1]
            cc = n1+n2
            tt = n1*n2
            if sum(tt) == 0:
                test_board[k:i+1:,c:col+c:] = shape[j:row:]
                test_board[i,c:col+c:] = cc
                sum_af = sum(test_board[i])
                if sum_be == sum_af:
                    l.append(np.array(test_board))
                else:
                    return l
            else:
                return l
    return l
def animate_clear(board):
    l = []
    new_board = np.array(board)
    a = board[np.min(board,axis=1) != 0] 
    b = np.zeros_like(new_board,int)
    if len(a) > 0:
        z = board[np.min(board,axis=1) != 0]
        new_board[np.min(board,axis=1) != 0] = np.zeros_like(z,int)
        l.append(new_board)
        x = new_board[(np.min(board,axis=1)==0)&(np.max(board,axis=1)!=0)]
        for e in range(len(board)-len(x)): 
            test_board = np.array(new_board)
            new_boardz = np.zeros_like(new_board,int)
            test_board[0:-1] = new_board[1:]
            s = (np.sum(new_board*test_board,axis=1))
            d = np.argmin((s.reshape(1,len(s)))[::,::-1].T)
            xx = board.shape[0]-d
            asd = (new_board[(np.sum(new_board*test_board,axis=1))==0])
            arr = new_board[:board.shape[0]-d]
            zero = np.zeros_like(arr,int)
            zero[1:] = new_board[:board.shape[0]-d-1]
            new_boardz[:board.shape[0]-d] = zero
            new_boardz[board.shape[0]-d:] = new_board[board.shape[0]-d:]
            eq = (new_board == new_boardz)
            if (False not in eq):
                return l    
            else:
                l.append(new_boardz)
            new_board = np.array(new_boardz)
        return l
    else:
        return l

xxx210xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [ array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 02, 8, 8, 0],
       [1, 1, 02, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
     2  [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 02],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 10, 8, 02],
       [ 1,  1,  0,  8,  8,  0],
       [ 1,  1,  0,  0,  8,  0]])],
 [ array([[0, 0, 0, 20, 20, 20],
       [0, 0, 0, 02, 02, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 02],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0IndexError('list index out of range')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1342, 'const': 424, 'code+const': 1766}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 11)], [('For', 10)]]
import numpy as np
def get_score(board):
    r = 0 != board
    r = np.sum(r,axis=1)
    r = np.sum(r == board.shape[1])*40
    return r
def get_time_cap(board, time_caps):
    t = time_caps
    a = board != 0
    a = np.sum(a,axis=1) != 0
    a_sum = np.sum(a)
    if a_sum != 0:
        ar = np.arange(board.shape[0])
        b = ar[a][0]//(board.shape[0]//len(t))
        r = t[b]
    else:
        r = t[-1]
    return r
def rotate_right(shape):
    r = shape[::-1].T
    return r
def rotate_left(shape):
    r = shape[::,::-1].T
    return r
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    ar = np.sum(new_board[::,c::] != 0,axis=1)
    list_ar = list(ar)
    ar = np.sum(ar == 0)
    if new_shape.shape[0] > 1:
        ar -= new_shape.shape[0]-(new_shape.shape[0]-1)
    list_r = []
    for i in range(ar):
        new_board = np.array(board)
        if new_shape.shape[0] == 1:
            new_board[i:i+1:,c::] += new_shape
            list_r.append(new_board)
        if new_shape.shape[0] > 1:
            new_board[i:i+new_shape.shape[0]:,c:new_shape.shape[1]+c:] += new_shape
            list_r.append(new_board)
        if list_ar[i] == 0 and list_ar[i+1] != 0:
            ar -= 1
    return list_r
def animate_clear(board):
    new_board = np.array(board)
    zero = np.zeros((1,new_board.shape[1]), int)
    a = np.sum(new_board == 0,axis=1)
    a_list = list(a)
    a_0 = np.sum(a == 0)
    ar = np.sum(a == 4) + a_0*2
    r = []
    for i in range(ar):
        if i < a_0:
            n = a_list.index(0)
            a_list[n] = 1
            new_board[n] = zero
            if i+1 == a_0:
                x = np.array(new_board)
                r.append(x)
        t = True
        if i >= a_0:
            b = np.sum(new_board != 0,axis=1)
            if i-(a_0-1) <= len(b)-1:
                if b[i-a_0] != 0 and b[i-(a_0-1)] == 0:
                    new_board[i-(a_0-1)] = new_board[i-a_0]
                    new_board[i-a_0] = zero
                    t = False
            if i-(a_0-3) <= len(b)-1:
                if b[i-(a_0-2)] != 0 and b[i-(a_0-3)] == 0 and b[i-(a_0-1)] == 0:
                    new_board[i-(a_0-3)] = new_board[i-(a_0-2)]
                    new_board[i-(a_0-2)] = zero
                    b[i-(a_0-3)] = b[i-(a_0-2)]
                    b[i-(a_0-2)] = 0
                    t = False
            if b[i-a_0] != 0 and b[i-(a_0-1)] != 0 and b[i-(a_0-2)] == 0:
                new_board[i-(a_0-2)] = new_board[i-(a_0-1)]
                new_board[i-(a_0-1)] = new_board[i-a_0]
                new_board[i-a_0] = zero
                b[i-(a_0-2)] = b[i-(a_0-1)]
                b[i-(a_0-1)] = b[i-a_0]
                b[i-a_0] = 0
                t = False
            if t == False:
                x = np.array(new_board)
                r.append(x)
    return r

xxx032xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 0., 0., 0.]])],
 [array([[0., 5., 5., 4.],
       [1., 0., 5., 4.],
       [1., 0., 2., 4.],
       [0., 0., 0., 0.]]),
  array([[0., 5., 5., 4.],
       [1., 0., 5., 4.],
       [0., 0., 0., 0.],
       [1., 0., 2., 4.]]),
  array([[0., 5., 5., 4.],
       [0., 0., 0., 0.],
       [1., 0., 5., 4.],
       [1., 0., 2., 4.]]),
  array([[0., 0., 0., 0.],
       [0., 5., 5., 4.],
       [1., 0., 5., 4.],
       [1., 0., 2., 4.]])],
 [array([[0., 5., 5., 4.],
       [0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 0., 0., 0.]]),
  array([[0., 0., 0., 0.],
       [0., 5., 5., 4.],
       [0., 0., 0., 0.],
       [0., 0., 0., 0.]]),
  array([[0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 5., 5., 4.],
       [0., 0., 0., 0.]]),
  array([[0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 5., 5., 4.]])],
 [array([[0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0 ... (more)
test_animate_clear_21.0
[[],
 [array([[1., 2., 0., 0.],
       [0., 0., 0., 0.],
       [1., 0., 2., 4.],
       [0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 0., 1., 1.]]),
  array([[0., 0., 0., 0.],
       [1., 2., 0., 0.],
       [0., 0., 0., 0.],
       [1., 0., 2., 4.],
       [0., 0., 0., 0.],
       [0., 0., 1., 1.]]),
  array([[0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [1., 2., 0., 0.],
       [0., 0., 0., 0.],
       [1., 0., 2., 4.],
       [0., 0., 1., 1.]]),
  array([[0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [1., 2., 0., 0.],
       [1., 0., 2., 4.],
       [0., 0., 1., 1.]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 866, 'const': 380, 'code+const': 1246}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 3)], [('While', 28)]]
import numpy as np
def get_score(board):
    new_array = np.min(board, axis = 1)
    check_zero = new_array > 0
    return sum(check_zero % 2 == 1) * 40
def get_time_cap(board, time_caps):
    board_row = board.shape[0] 
    board_col = board.shape[1] 
    time_caps_length = len(time_caps) 
    range = int(board_row / time_caps_length)
    new_array = board.reshape((int(board_row / range) , board_col * range))
    check_zero = np.sum(new_array, axis = 1) > 0
    if np.sum(check_zero) != 0:
      result = time_caps[np.argmax(check_zero)] 
    else:
      result = time_caps[-1] 
    return result
def rotate_right(shape):
    transpose_array = shape.T
    result = transpose_array[::1  , ::-1] 
    return  result
def rotate_left(shape):
    transpose_array = shape.T
    result = transpose_array[::-1  , ::1] 
    return  result
def animate_drop(board, shape, c):
    result_array = []
    for x in range(0,board.shape[0],shape.shape[0]):
        new_board = board[x: shape.shape[0] + x , c: shape.shape[1] + c]
        check_zero = np.sum(new_board)
        if check_zero == 0:
            temp_board = np.array(board)
            temp_board[x: shape.shape[0] + x , c: shape.shape[1] + c] = shape
            result_array.append(np.array(temp_board))
            temp_board = []
        elif check_zero != 0 and x==0: 
            result_array = []
        elif check_zero !=0 and x>0:
            break
    return result_array
def animate_clear(board):
    result_board = []
    new_array = np.min(board, axis = 1)
    check_zero = new_array == 0
    check_no_replace = new_array > 0
    if np.sum(check_no_replace) == 0:
        return []
    else:
        mul_matrix = check_zero.reshape((check_zero.shape[0], 1)) + np.zeros((board.shape[0], board.shape[1]))
        first_board = mul_matrix * board
        result_board.append(np.array(first_board))
    current_board = np.array(first_board)
    change_board = np.array(first_board)
    x = True
    i = 0
    while True:
        if np.sum(current_board[i]) != 0 and np.sum(current_board[i+1]) == 0:
            temp_board = np.array(change_board)
            temp_board[i] = change_board[i+1]
            temp_board[i+1] = change_board[i]
            change_board = temp_board 
        if i+1 >= change_board.shape[0] - 1:
            if current_board.shape == change_board.shape and np.sum(current_board!= change_board) == 0: 
                break
            else:
                current_board = change_board
                result_board.append(np.array(change_board))
                i = 0
        else:
            i = i + 1
    return result_board

xxx203xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (3,3) (2,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]]),
  array([[1, 1, 0, 0],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 0, 0]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 462, 'const': 266, 'code+const': 728}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('all', 7)], []]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 7)], []]
import numpy as np
def get_score(board):
    mn = np.min(board, axis=1)
    return np.sum(mn != 0) * 40
def get_time_cap(board, time_caps):
    if np.max(board) == 0:
      return time_caps[-1]
    mn = np.max(board, axis=1)
    pos = np.arange(board.shape[0])
    return time_caps[pos[mn != 0][0] // (len(pos) // len(time_caps))]
def rotate_right(shape):
    return shape.T[:, ::-1]
def rotate_left(shape):
    return shape.T[::-1, :]
def animate_drop(board, shape, c):
    r = 0
    b = board == 0
    s = shape == 0
    ret = []
    while r+shape.shape[0]-1 < board.shape[1] and (s | b[r:r+shape.shape[0], c:c+shape.shape[1]]).all():
      new_board = np.array(board)
      new_board[r:r+shape.shape[0], c:c+shape.shape[1]] = new_board[r:r+shape.shape[0], c:c+shape.shape[1]] + shape
      r += 1
      ret.append(new_board)
    return ret
def animate_clear(board):
    pass

xxx202xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 762, 'const': 356, 'code+const': 1118}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('For', 16)]]
import numpy as np
def get_score(board):
    m=np.min(board,axis=1)
    return m[m != 0].shape[0]*40
def get_time_cap(board, time_caps):
        tlen=len(time_caps)
        n_board = board.reshape((tlen, board.shape[1]*board.shape[0]//tlen))
        s=np.sum(n_board,axis=1)
        boo = s!=0
        t=np.array(time_caps)
        res=t[boo]
        if res.shape[0] != 0:
            return res[0]
        else :
            return t[-1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    animate=[]
    for i in range (board.shape[1]):
        new_board=np.array(board)
        new_board[i:i+shape.shape[0],c:c+shape.shape[1]]=shape
        if(np.sum(new_board) != np.sum(shape)+np.sum(board)): break
        animate.append(new_board)
    return animate
def animate_clear(board):
    res=[]
    index=np.arange(board.shape[0])
    mi=np.min(board,axis=1)
    indi=mi != 0
    set_to_zero=index[indi]
    if set_to_zero.shape[0] != 0:
        board[set_to_zero,:]=0
        res.append(board)
    mi=np.sum(board,axis=1)
    indi=mi == 0
    clear=index[indi]
    new_board=np.array(board)
    count=0
    for i in sorted(clear,reverse=1):
        i+=count+1
        cache_board=np.zeros_like(board,int)
        if np.sum(new_board[:i-1,:]) == 0 : break
        cache_board[1:i,:]=cache_board[:i-1,:]+new_board[:i-1,:]
        cache_board[i:,:]=cache_board[i:,:]+new_board[i:,:]
        new_board=cache_board
        res.append(new_board)
        count+=1
    return res

xxx016xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 870, 'const': 338, 'code+const': 1208}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 9)], [('For', 11)]]
import numpy as np
def get_score(board):
    x = np.min(board, axis=1)
    y = np.sum(x != 0)
    return 40*y
def get_time_cap(board, time_caps):
    x = np.max(board, axis=1)
    y = np.arange(board.shape[0])[(x > 0)]
    if y.shape[0] != 0:
        return time_caps[int(y[0]//(board.shape[0]/len(time_caps)))]
    else:
        return time_caps[-1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    ans = []
    count = 0
    check_shape = shape != 0
    x = shape != 0
    if np.sum((board[:shape.shape[0],c:shape.shape[1]+c] != 0) & x[-1,:]) != 0:
        return []
    while True:
        new_board = np.array(board)
        new_shape = np.array(shape)
        check_board = new_board[count:count+new_shape.shape[0],c:c+new_shape.shape[1]]
        if np.sum((check_board != 0) & check_shape) != 0:
            break
        check_board += new_shape
        ans.append(np.array(new_board))
        count += 1
        if count == new_board.shape[0]-(shape.shape[0]-1):
            break
    return ans
def animate_clear(board):
    ans = []
    if get_score(board) == 0:
        return []
    new_board = np.array(board)
    check = np.min(new_board, axis = 1) > 0
    new_board[check] = np.zeros_like(new_board[0], int)
    ans.append(np.array(new_board))
    c = 1
    for i in range(new_board.shape[0]):
        if np.sum(new_board[-c,:], axis = 0) == 0:
            if np.sum(new_board[:-c,:]) != 0:
                if c == 1:
                    new_board[1:,:] = new_board[0:-c,:]
                    new_board[0,:] = np.zeros_like(new_board[0], int)
                else:
                    new_board[1:-c+1,:] = new_board[0:-c,:]
                    new_board[0,:] = np.zeros_like(new_board[0], int)
                ans.append(np.array(new_board))
        else:
            c += 1
    return ans

xxx206xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 774, 'const': 352, 'code+const': 1126}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('For', 12)]]
import numpy as np
def get_score(board):
    shape = board.shape
    min = np.min(board, axis=1)
    ans = np.sum(min != 0)
    return ans*40
def get_time_cap(board, time_caps):
    shape = board.shape
    if np.sum(board) == 0:
        return time_caps[-1]
    min = np.max(board, axis=1)
    r = np.argmax(min > 0)+1
    idx = (r*len(time_caps))/shape[0]
    idx = int(-(-idx//1))
    return time_caps[idx-1]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[::1,::-1].T
def animate_drop(board, shape, c):
    l = []
    sh = shape.shape
    i = 0
    for _ in range(board.shape[0]-sh[0]+1):
        if i == 0:
            temp = board[0, c:c+sh[1]] * shape[-1]
            if np.sum(temp) > 0:
                break
        a = np.array(board[i:i+sh[0], c:c+sh[1]])
        a = a*shape
        if np.sum(a) > 0:
            break
        new_board = np.array(board)
        new_board[i:i+sh[0], c:c+sh[1]] += shape
        l.append(new_board)
        i += 1
    return l
def animate_clear(board):
    l = []
    shape = board.shape
    new_board = np.array(board)
    count = np.sum(new_board > 0, axis=1)
    count = count != shape[1]
    new_board = new_board*count[:, None]
    if np.sum(board == new_board) != shape[0]*shape[1]:
        l.append(np.array(new_board))
    i = shape[0]-1
    for _ in range(shape[0]):
        if np.sum(new_board[i]) != 0:
            i -= 1
        else:
            if np.sum(new_board[:i+1]) == 0:
                break
            new_board[1:i+1] = new_board[:i]
            new_board[0] = 0
            l.append(np.array(new_board))
    return l

xxx040xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 696, 'const': 338, 'code+const': 1034}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 11)]]
import numpy as np
def get_score(board):
    return np.sum(np.sum(board != 0, axis = 1) == board.shape[1])*40
def get_time_cap(board, time_caps):
    n = len(time_caps)
    board_row = board.shape[0]
    factor = board_row//n
    pos = np.arange(board_row)
    new_board = np.array(board)
    check = np.sum(new_board != 0, axis = 1)
    if np.sum(check) == 0 :
        return time_caps[-1]
    x = pos[check != 0][0]
    index = x//factor
    return time_caps[index]
def rotate_right(shape):
    t = shape.T
    return t[::,::-1]
def rotate_left(shape):
    t = shape.T
    return t[::-1,::]
def animate_drop(board, shape, c):
    board_width = board.shape[1]
    board_row = board.shape[0]
    shape_width = shape.shape[1]
    shape_row = shape.shape[0]
    out = []
    for row in range(board_row - shape_row + 1):
        new_board = np.array(board)
        new_shape = np.array(shape)
        new_board[row:row + shape_row, c:c + shape_width] += new_shape
        before = np.sum(board != 0) + np.sum(shape != 0)
        after = np.sum(new_board != 0)
        if before == after :
            out.append(new_board)
        else: break
    return out
def animate_clear(board):
    out = []
    new_board = np.array(board)
    pos = np.arange(board.shape[0])
    x = np.sum(new_board == 0, axis = 1) == 0
    if np.sum(x) == 0:
        return []
    new_board[x] = 0
    out.append(new_board)
    while True:
        index = pos[np.sum(new_board != 0, axis = 1) == 0][-1]
        x = np.arange(new_board.shape[0])
        y = set(x) - {index}
        z = sorted(y)
        new_board = new_board[[index] + z]
        if np.sum(new_board != out[-1]) == 0: break
        out.append(new_board)
    return out

xxx042xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[array([[2, 2, 2, 0],
       [2, 0, 0, 1]])], [array([[0, 2, 2, 2],
       [1, 2, 01, 01]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 01, 5, 5, 0, 0, 0],
       [0, 2, 02, 02, 5, 02, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [ array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 02, 8, 8, 0],
       [1, 1, 02, 0, 8, 0]])],
 [array([[0, 02, 2, 2, 20, 0],
       [0, 0, 0, 02, 20, 0],
       [0, 0, 0, 02, 28, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 08, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]]),
  array([[1, 1, 0, 0],
       [1, 1, 0, 0]])],
 [array([[0, 2, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0Time-out: 5s
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 810, 'const': 364, 'code+const': 1174}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 8)], [('While', 14)]]
import numpy as np
def get_score(board):
    score = np.sum(board != 0, axis = 1)
    score[score != board.shape[1]] = 0
    return np.sum(score) * (40//board.shape[1])
def get_time_cap(board, time_caps):
    r, c = board.shape
    t = len(time_caps)
    d = r//t
    ind = np.arange(board.shape[0])
    if np.sum(board) != 0:
        i = ind[np.sum(board, axis = 1) != 0][0]
        return time_caps[i//d]
    else:
        return time_caps[-1]
def rotate_right(shape):
    return shape.T[:, ::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    animate = [] 
    can_drop = True
    if np.sum(board[0,c:shape.shape[1]]) != 0:
        can_drop = False
    row = 0
    while can_drop:
        new_board = np.array(board)
        new_shape = np.array(shape)
        high, long = shape.shape
        new_board[row:high+row,c:long+c] = shape
        row += 1
        animate.append(new_board)
        if row-1 == board.shape[0] or np.sum(board[row:high+row,c:long+c]) != 0:
            can_drop = False
    return animate
def animate_clear(board):
    animate = []
    new_board = np.array(board)
    check_board = np.sum(new_board != 0, axis = 1)
    ind = np.arange(board.shape[0])
    ind = ind[check_board == board.shape[1]]
    new_board[ind] = 0
    if np.sum(new_board) == np.sum(board):
        return animate
    animate.append(np.array(new_board))
    loop = np.sum(new_board != 0, axis = 1)
    pos = np.arange(1,len(loop)-1)
    while np.sum((loop[pos] > loop[pos-1]) & (loop[pos] > loop[pos+1])) != 0:
        check = np.sum(new_board, axis = 1)
        ind = np.arange(new_board.shape[0])
        ind = ind[check == 0]
        k = ind[-1]
        new_board[1:k+1] = new_board[:k]
        new_board[0] = 0
        loop = np.sum(new_board != 0, axis = 1)
        animate.append(np.array(new_board))
    return animate

xxx041xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[]]
bytecount: {'code': 924, 'const': 380, 'code+const': 1304}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 15)]]
import numpy as np
def get_score(board):
    a = np.min(board, axis=1)
    b = np.array(a)
    c = len(b[b!=0])
    return int(c)*40
def get_time_cap(board, time_caps):
    a = np.max(board, axis=1)
    b = np.array(a)
    pos = np.arange(b.shape[0])
    c = pos[b!=0]
    if b[-1]!=0:
        d = c[0]//(len(board)//len(time_caps))
        return time_caps[d]
    else:
        return time_caps[-1]
def rotate_right(shape):
    a = shape[::-1,::1]
    return np.array(a.T)
def rotate_left(shape):
    a = shape[::1,::-1]
    return np.array(a.T)
def animate_drop(board, shape, c):
    l = []
    new_shape = np.array(shape)
    a = new_shape==0
    for i in range(board.shape[0]-shape.shape[0]+1):
        new_board = np.array(board)
        b = board[i:i+shape.shape[0],c:c+shape.shape[1]:]==0
        d = a|b
        if np.min(d)==True:
            new_board[i:i+shape.shape[0],c:c+shape.shape[1]:]+=new_shape
            l.append(np.array(new_board))
        else:
            return l
    return l
def animate_clear(board):
    l=[]
    new_board = np.array(board)
    a = np.min(board, axis=1)
    pos = np.arange(a.shape[0])
    c = pos[a!=0]
    new_board[c,]=0
    if len(c)!=0:
        l.append(np.array(new_board))
    b = np.max(new_board,axis=1)
    d = pos[b!=0]
    n = len(b[b!=0])
    x=-1
    while d[0]!=(len(board)-n):
        if np.max(new_board[x])==0:
            if x==-1:
                new_board[1:,]=new_board[0:x,]
                new_board[0]=0
                l.append(np.array(new_board))
                m = np.max(new_board, axis=1)
                pos = np.arange(m.shape[0])
                d = pos[m!=0]
            else:
                new_board[1:x+1,]=new_board[0:x,]
                new_board[0]=0
                l.append(np.array(new_board))
                m = np.max(new_board, axis=1)
                pos = np.arange(m.shape[0])
                d = pos[m!=0]
        else:
            x-=1
    return l

xxx027xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1056, 'const': 338, 'code+const': 1394}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 6)], [('While', 10)]]
import numpy as np
def get_score(board):
    x = np.sum(board != 0,axis=1)
    return (board[x == board.shape[1]]).shape[0]*40
def get_time_cap(board, time_caps):
    n = np.arange(0,len(time_caps))
    k = board.shape[0]*board.shape[1]//len(time_caps)
    new_board = board.reshape(len(time_caps),k)
    x = np.sum(new_board == 0,axis=1)
    if n[(x != k) & (x != 0)].shape[0] != 0:
        return time_caps[n[(x != k) & (x != 0)][0]]
    else:
        return time_caps[-1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    d = []
    i = 0
    s = board[i:i+(shape.shape[0]),c:shape.shape[1]+c]
    if np.sum(board[0,c:c+shape.shape[1]]) == 0:
        while i+shape.shape[0] <= board.shape[0]:
            k = s+shape == s
            l = s+shape == shape
            if np.sum(k | l) == shape.shape[0]*shape.shape[1]:
                new_board = np.array(board)
                new_board[i:i+shape.shape[0],c:shape.shape[1]+c] += shape
                d.append(new_board)
                i += 1
                s = board[i:i+shape.shape[0],c:shape.shape[1]+c]
            else: break
    return d
def animate_clear(board):
    d = []
    n = np.arange(1,board.shape[0])
    x = np.sum( board != 0,axis=1)
    new_board = np.array(board)
    if np.sum(x[x == board.shape[1]]) != 0:
        new_board[x == board.shape[1]] = 0
        d.append(new_board)
        r = np.arange(0,board.shape[0])[:-1]
        while True:
            x = np.array(d[-1])
            if r[(np.sum(x[:-1],axis=1) != 0)].shape[0] != 0:
                start = r[(np.sum(x[:-1],axis=1) != 0)][0]
            else:
                break
            if  r[(np.sum(x[:-1],axis=1)!= 0) & (np.sum(x[r+1],axis=1) == 0)].shape[0] != 0 :
                end = r[(np.sum(x[:-1],axis=1)!= 0) & (np.sum(x[r+1],axis=1) == 0)][-1]+1
            else: break
            x[start+1:end+1] = x[start:end]
            x[0:start+1] = 0
            d.append(x)
        return d
    else:
        return d

xxx031xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1006, 'const': 404, 'code+const': 1410}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('For', 15)]]
import numpy as np
def get_score(board):
    x=np.sum(board!=0,axis=1)
    return np.sum(x==board.shape[1])*40
def get_time_cap(board, time_caps):
    p=board.shape[0]//len(time_caps)
    f=np.sum(board,axis=1)!=0 
    if np.sum(f)==0:
        return time_caps[-1]
    z=np.zeros((len(time_caps),p),int)
    b=np.array(time_caps)
    b=b.reshape((b.shape[0],1))
    b=(b+z)
    b=b.reshape((1,len(time_caps)*p))
    f=np.array([f])
    return b[f][0]
def rotate_right(shape):
    if len(shape.shape)==1:
        return shape.reshape((shape.shape[0]),1)
    return shape.T[:,::-1]
def rotate_left(shape):
    if len(shape.shape)==1:
        return shape[::-1].reshape((shape.shape[0]),1)
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    result=[]
    s_board=np.zeros((2*board.shape[0]+shape.shape[0],board.shape[1]),int)
    s_board[board.shape[0]:board.shape[0]+shape.shape[0],c:c+shape.shape[1]]+=shape
    for i in range(board.shape[0]):
        new_board=np.array(board)
        sum_board=s_board[board.shape[0]+shape.shape[0]-i-1:-i-1]
        new_board+=sum_board
        if np.sum(board[new_board!=board])!=0:
            return result
        if i>=shape.shape[0]-1:
            if np.sum(new_board)!=np.sum(board)+np.sum(shape):
                return result
            else:
                result.append(new_board)
    return result
def animate_clear(board):
    result=[]
    x=np.sum(board!=0,axis=1)
    i=(x==board.shape[1])
    new_board=np.array(board)
    new_board[i]=np.zeros(board.shape[1],int)
    if np.sum(new_board==board)==(board.shape[0]*board.shape[1]):
        return result
    n1=np.sum(np.sum(new_board,axis=1)==0)
    n2=np.sum(new_board,axis=1)
    n2[n2!=0]=-1
    n2=np.argmin(n2)
    result.append(new_board)
    for k in range(n1-n2):
        r=np.arange(new_board.shape[0])
        i=r[np.sum(new_board,axis=1)==0][-1]
        new_board=np.array(list([np.zeros(new_board.shape[1],int)])+list(new_board[:i])+list(new_board[i+1:]))
        result.append(new_board)
    return result

xxx121xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (3,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (3,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (2,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 800, 'const': 350, 'code+const': 1150}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 11)]]
import numpy as np
def get_score(board):
    b  = board[(np.min(board,axis = 1) > 0).T]
    return len(b)* 40
def get_time_cap(board, time_caps):
    b = np.zeros_like(board,dtype= int)
    dimention = board.shape[0] *  board.shape[1]
    if np.sum(board) :
        dimention = np.max(board,axis =1)
        b2 = np.arange(len(time_caps)) + 1 < (np.argmax(dimention!=0) + 1) / board.shape[0] * len(time_caps) 
        return time_caps[np.argmin(b2)]
    return time_caps[-1]
def rotate_right(shape):
    s = shape.copy()
    return s.T[:,::-1]
def rotate_left(shape):
    s = shape.copy()
    return s.T[::-1,:]
def animate_drop(board, shape, c):
    list_board = []
    n_col = board.shape[1]
    n_row = board.shape[0]
    n_shape = shape.shape[1]
    filer_board = board[:, c:c+n_shape]
    for i in range(n_row):
      new_board = np.array(board)
      if(np.sum(filer_board[i]) == 0):
        new_board[i, c:c+n_shape] = shape
        list_board.append(new_board)
    return list_board
def animate_clear(board):
    list_board = []
    n_col = board.shape[1]
    n_row = board.shape[0]
    first_board = True
    status_clear = False
    status_drop = False
    count = 0
    new_board = np.array(board)
    while(True):
      if first_board:
        if (np.min(new_board[count,:]) != 0):
          new_board[count:count+1, :] = np.zeros((1, n_col), int)
          status_clear = True
        count += 1
        if count == n_row:
          first_board = False
          count = n_row-1 
          if status_clear:
            list_board.append(np.array(new_board))
      else:
        if(np.sum(new_board[count]) == 0 and np.sum(new_board[count-1]) != 0):
          status_drop = True
          new_board[count, :] = new_board[count-1, :]
          new_board[count-1, :] = np.zeros((1, n_col), int)
        if count == 1:    
          count = n_row-1 
          if status_drop == False:
            break
          list_board.append(np.array(new_board))
          status_drop = False
        count -= 1
    return list_board

xxx215xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 794, 'const': 338, 'code+const': 1132}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('While', 13)]]
import numpy as np
def get_score(board):
  a=np.min(board, axis=1)
  c = a[a>0]
  g=(len(c))*40
  return g
def get_time_cap(board, time_caps):
  a=np.max(board, axis=1)
  c=a[a==0]
  d=a[a>0]
  cc=len(c)
  if len(d)==0:
    return time_caps[-1]
  else:
    gg=time_caps[((cc+2)//2)-1]
    return gg
def rotate_right(shape):
  a=shape[::-1,::]
  d=a.T
  return d
def rotate_left(shape):
  d=shape.T
  a=d[::-1,::]
  return a
def animate_drop(board, shape, c):
  w=shape.shape[0]-1
  an=[]
  for i in range(board.shape[0]-w):
    n=np.array(board)
    x=np.sum(np.array((shape!=0)))
    n[i:i+shape.shape[0]:,c:c+shape.shape[1]:]+=shape
    if np.sum(np.array((n==0)))+x != np.sum(np.array((board==0))):
      break
    elif np.sum(np.array((n==0)))+x == np.sum(np.array((board==0))):
      bb=n
      an.append(np.array(n))
  return an
def animate_clear(board):
  s=board.shape[1]
  zero=np.sum(board!=0,axis=1)
  if len(zero[zero==s])==0:
    return []
  dl=np.arange(0,board.shape[0],1)[zero==s]
  n=np.array(board)
  n[dl,0::]=0
  anc=[]
  anc.append(np.array(n))
  y=board.shape[0]-1
  while y!=len(zero[zero==s])-1:
    if np.sum(n[y])==0 and np.sum(n[:y:])!=0:
      n[1:y+1:]=n[0:y:]
      n[0]=0
      anc.append(np.array(n))
    else:
      y-=1 
  return anc

xxx034xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 796, 'const': 402, 'code+const': 1198}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('For', 10)]]
import numpy as np
def get_score(board):
    return np.sum(np.array(np.sum(np.array(board == 0),axis = 1)==0)) * 40
def get_time_cap(board, time_caps):
    if np.sum(board != 0) == 0:
        return time_caps[-1]
    result = np.arange(0,board.shape[0],1)[np.array(np.sum(np.array(board != 0),axis = 1)!=0)][0]
    return time_caps[int(result//(board.shape[0]/len(time_caps)))]
def rotate_right(shape):
    return shape.T[0::1,-1::-1]
def rotate_left(shape):
    return shape.T[-1::-1,0::1]
def animate_drop(board, shape, c):
    result = []
    for row in range(board.shape[0]):
        new_board = np.array(board)
        taew =shape.shape[0]
        lak = shape.shape[1]
        exp_size=new_board[row:row+taew:1,c:c+lak:1].shape
        eq_0new = np.array(new_board[row:row+taew:1,c:c+lak:1]==0)
        if (exp_size != shape.shape):
            break
        elif np.sum((eq_0new) | (shape==0))==shape.size :
            new_board[row:row+shape.shape[0]:1,c:c+shape.shape[1]:1] += shape 
            result.append(np.array(new_board))
        else:break                  
    return result
def animate_clear(board):
    rows = np.arange(0,board.shape[0],1)[np.sum(board == 0,axis=1) == 0]
    if rows.shape[0] == 0:
        return []
    new_board = np.array(board)
    new_board[rows,0::1] = 0
    index = board.shape[0]-1
    result = [np.array(new_board)] 
    for times in range(board.shape[0]):
        success = False
        experiment = new_board[0:index:1]
        check_new = np.sum(new_board[index]) == 0 
        check_exp = np.sum(experiment) != 0 
        if check_new and check_exp: 
            new_board[1:index+1:1]=experiment 
            new_board[0]=0
            result.append(np.array(new_board))
            success =True
        if success == False: 
            index-=1     
    return result

xxx038xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score0.0
[40, 4120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0Time-out: 5s
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 796, 'const': 352, 'code+const': 1148}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('While', 13)]]
import numpy as np
def get_score(board):
    status = board > 0
    count = sum(np.sum(status, axis = 1) == 5)
    points = count*40
    return points
def get_time_cap(board, time_caps):
    num_row = np.arange(0, len(board))
    needed = int(len(board)/len(time_caps))
    sums = np.sum(board, axis = 1)
    check = sum(sums)
    if check == 0:
        return time_caps[-1]
    else:
        first_row_no_zero = num_row[sums != 0][0]
        wanted = first_row_no_zero//needed
        return time_caps[int(wanted)]
def rotate_right(shape):
    new_shape = shape[::-1,::-1].T
    return new_shape[::-1,::]
def rotate_left(shape):
    new_shape = shape[::-1,::-1].T
    return new_shape[::,::-1]
def animate_drop(board, shape, c):
    new_shape = np.array(shape)
    animations = []
    for i in range(len(board)-len(shape)+1):
        new_board = np.array(board)
        if sum(board[i:len(shape)+i:,c:len(shape[0])+c:][shape != 0]) == 0:
            new_board[i:len(shape)+i:,c:len(shape[0])+c:][shape != 0] = new_shape[shape != 0]
            animations.append(new_board)
        else:
            return animations
    return animations
def animate_clear(board):
    new_board = np.array(board)
    animations = []
    need_clear = np.sum(new_board == 0, axis = 1)
    index = np.arange(0,len(new_board))
    if sum(need_clear == 0) >= 1: 
        new_board[need_clear == 0,::] = 0
        animations.append(new_board)
        newer_board = np.array(new_board)
        zero_check = np.sum(new_board != 0, axis = 1)
        row = index[zero_check == 0][-1]
        while sum(newer_board[row]) == 0:
            newer_board = np.array(newer_board)
            move_needed = newer_board[:row]
            newer_board[1:row+1] = move_needed
            newer_board[0] = 0
            animations.append(newer_board)
            if sum(newer_board[row]) != 0 and np.sum(newer_board[:row]) != 0:
                row -= 1
        return animations  
    else:
        return animations

xxx206xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [0, 0, 0, 0],
       [1, 0, 2, 4]]),
  array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [1, 0, 5, 4],
       [1, 0, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 812, 'const': 338, 'code+const': 1150}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 12)], [('While', 9)]]
import numpy as np
def get_score(board):
    x= board != 0  
    y=np.sum(x,axis=1)
    a=np.shape(board)[1]
    b= y  == a
    return np.sum(b) * 40
def get_time_cap(board, time_caps):
    sum_board = np.sum(board,axis=1)
    tf_board = sum_board != 0
    n=np.argmax(tf_board)
    x=n//2
    if tf_board[n] != 0:
        return time_caps[x]
    else:
        return time_caps[-1]
def rotate_right(shape):
    x=shape.T
    return x[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    ans=[] 
    row = 0
    shape_r,shape_c = np.shape(shape)
    cut_board = board[row:row +shape_r,c:c+shape_c] 
    tf_shape = shape !=0  
    tf_cut_board = cut_board ==0  
    if np.shape(cut_board)[0] < np.shape(shape)[0] :
        return []
    check_shape_cut_board = tf_shape & tf_cut_board  
    while np.sum(tf_shape) == np.sum(check_shape_cut_board) and np.shape(cut_board) == np.shape(shape) :
        x=np.array(board)
        x[row:row +shape_r,c:c+shape_c] = shape + cut_board
        ans.append(x)
        row += 1
        cut_board = board[row:row +shape_r,c:c+shape_c]
        if np.shape(cut_board) != np.shape(shape):
            break
        tf_cut_board = cut_board ==0
        check_shape_cut_board = tf_shape & tf_cut_board
    return  ans
def animate_clear(board):
    ans=[]
    tf_board = board == 0
    a=np.sum(tf_board,axis= 1)
    if 0 in a :
        first_board = board * ((a > 0).reshape((len(a),1)))
        ans.append(first_board)
        while True :
            sum_0_board = np.sum(first_board,axis=1) == 0
            all_row_which_sum_is_0 = np.arange(len(board))[sum_0_board] 
            a=all_row_which_sum_is_0 > 0
            all_row_which_sum_is_0 = all_row_which_sum_is_0[a]
            coppy_board = np.array(first_board)
            new = np.zeros(np.shape(board),int)
            new[all_row_which_sum_is_0] = coppy_board[all_row_which_sum_is_0 -1]
            coppy_board[ all_row_which_sum_is_0-1,:] = 0 
            new_board = coppy_board + new
            if np.sum(first_board == new_board) == np.shape(board)[0] * np.shape(board)[1] :
                break
            else :
                ans.append(new_board)
                first_board = new_board
    return ans

xxx028xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 812, 'const': 324, 'code+const': 1136}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('While', 9)]]
import numpy as np
def get_score(board):
    col_count = board.shape[1]
    has_block = board > 0
    res = np.sum(has_block, axis=1) == col_count
    return np.sum(res) * 40
def get_time_cap(board, time_caps):
    score_by_time = board.reshape(len(time_caps), -1).sum(axis=1)
    time_caps_array = np.array(time_caps)
    res = time_caps_array[score_by_time > 0]
    return res[0] if res.size > 0 else time_caps[-1]
def rotate_right(shape):
    return shape.T[:, ::-1]
def rotate_left(shape):
    return shape.T[::-1, :]
def animate_drop(board, shape, c):
    time_line = []
    width = shape.shape[1]
    height = shape.shape[0]
    for i in range(1 - height, board.shape[0]):
        if i >= 0:
            slot = board[i : i + height, c : c + width]
        else:
            slot = board[: i + height, c : c + width]
        if slot.shape != shape.shape and i >= 0:
            break
        if i >= 0:
            is_empty = np.sum(slot[shape > 0]) == 0
            if is_empty:
                new_board = board * 1
                new_board[i : i + height, c : c + width] += shape
                time_line.append(new_board)
            else:
                break
        else:
            is_empty = np.sum(slot[shape[-i:] > 0]) == 0
            if not is_empty:
                break
    return time_line
def animate_clear(board):
    cleared_board = board * 1
    is_full = np.sum(board > 0, axis=1) == board.shape[1]
    if np.sum(is_full) == 0:
        return []
    cleared_board[is_full] = np.zeros(board.shape[1])
    floor = cleared_board.shape[0] - 1
    time_line = [cleared_board]
    while floor >= 0:
        is_empty = np.sum(cleared_board[floor] > 0) == 0
        if not is_empty:
            floor -= 1
            continue
        is_empty_above = np.sum(cleared_board[: floor + 1] > 0) == 0
        if is_empty_above:
            break
        new_board = np.zeros(board.shape, int)
        new_board[floor + 1 :] = cleared_board[floor + 1 :]
        new_board[1 : floor + 1] = cleared_board[:floor]
        cleared_board = new_board * 1
        time_line.append(new_board * 1)
        floor = cleared_board.shape[0] - 1
    return time_line

xxx209xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score0.0
[40, 4120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 718, 'const': 362, 'code+const': 1080}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [], [('all', 5), ('all', 4)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 9)]]
import numpy as np
def get_score(board):
    pu = board>0
    p= np.sum(pu,axis=1)
    u= p==5
    score = np.sum(u)*40
    return score
def get_time_cap(board, time_caps):
    f=np.sum(board,axis=1)
    fstrow = np.argmax((f>0))
    if(fstrow==0 and f[0]==0):
      tc = time_caps[-1]
      return tc
    tc = time_caps[fstrow//(len(board)//len(time_caps))]
    return tc
def rotate_right(shape):
    rot = shape.T
    rot = rot[0::, ::-1]
    return rot
def rotate_left(shape):
    rotl = shape.T
    rotl = rotl[::-1, 0::]
    return rotl
def animate_drop(board, shape, c):
    op = []
    for i in range(board.shape[0]-shape.shape[0]+1):
        new_board = np.array(board)
        new_board[i:i+shape.shape[0],c:c+shape.shape[1]] += shape
        if ((new_board[i:i+shape.shape[0],c:c+shape.shape[1]][shape>0])             != (shape[shape>0])).sum()==0:
            op.append(np.array(new_board))
        else:
            break
    return op
def animate_clear(board):
    new_board = np.array(board)
    op = []
    if len(new_board[new_board.all(axis=1)])>0:
        new_board[new_board.all(axis=1)] = np.zeros(new_board.shape[1])
        op.append(np.array(new_board))
    start = board.shape[0]-1
    i = start
    while i>=0:
        if all(new_board[i] == 0):
            new_board[1:1+i] = new_board[:i]
            new_board[0] = np.zeros(new_board.shape[1])
            op.append(np.array(new_board))
            i = start
        i = i-1
        if (new_board[:i] != np.zeros(new_board[:i].shape)).sum()==0:
            return op
    return op

xxx120xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0ValueError('could not broadcast input array from shape (3,4) into shape (0,4)')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 822, 'const': 398, 'code+const': 1220}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 23)]]
import numpy as np
def get_score(board):
    row = np.min(board,axis = 1)
    sc = np.sum(row != 0)
    ans = sc*40
    return ans
def get_time_cap(board, time_caps):
    row = np.sum(board != 0,axis =1)
    b = row>0
    if sum(b) == 0:
        return time_caps[-1]
    else:
        b = list(b)
        index = b.index(True)
        return time_caps[index//2]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    ans =[]
    a = board.shape[0]
    b = shape.shape[0]
    for n in range(a):
        x = board[n:b+n,c:c+len(shape[0])]
        new_board = np.array(board)
        if sum(np.sum(x,axis=1))==0:
            new_board[n:n+len(shape),c:c+len(shape[0])] += new_shape
            ans.append(new_board)
        else:
            break
    return ans
def animate_clear(board):
    ans = []
    new_board = np.array(board)
    x = np.sum(board==0,axis=1)
    pos = np.arange(x.shape[0])
    i = pos[x==0]
    new_board[i] = 0
    ans.append(new_board)
    a = board.shape[1]
    min_b = np.sum(np.max(board ,axis =1)==0)
    max_b = np.max(new_board ,axis =1)
    sum_b = np.sum(max_b == 0)
    if sum_b == 0:
        return []
    if min_b == 1 and np.max(new_board[0])==0 :
        new_board1 = np.array(ans[-1])
        new_board1[1:] = ans[-1][:-1]
        new_board1[0] = np.array([0]*a)
        ans.append(new_board1)
    else:
        count = -1
        while np.sum(ans[-1][:sum_b,:]) != 0 :
            new_board1 = np.array(ans[-1])
            if max(new_board1[count])== 0 :
                new_board1[1:count+1:] = ans[-1][:count:]
                new_board1[0] = np.array([0]*a)
                ans.append(new_board1)
            else:
                count -=1
    return ans

xxx027xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_20.0
[[array([[0, 2, 0, 0],
       [2, 2, 2, 0],
       [1, 1, 0, 0]])],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [10, 20, 0, 0],
       [0, 0, 0, 0],
       [1, 02, 20, 40],
       [01, 0, 02, 04],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 864, 'const': 338, 'code+const': 1202}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('For', 9)]]
import numpy as np
def get_score(board):
    c = board.shape[1]
    x = np.sum(board>0,axis=1)
    y = len(x[x==c])
    return y*40
def get_time_cap(board, time_caps):
    if np.sum(board)==0:
        return time_caps[-1]
    else:
        r = board.shape[0]//len(time_caps)
        x = np.sum(board>0,axis=1)
        y = len(x[x==0])
        i = y//r
        return time_caps[i]
def rotate_right(shape):
    return shape[::-1,:].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    x = []
    for i in range(board.shape[0]):
        new_board = np.array(board)
        if i+shape.shape[0]<=board.shape[0]:
            ob = board[i:i+shape.shape[0],c:shape.shape[1]+c]
            b = ob + shape
            new_board[i:i+shape.shape[0],c:shape.shape[1]+c] = b
            if np.sum(b!=0)-np.sum(shape!=0)==np.sum(ob!=0):
                x.append(new_board)
            else:
                break
        else:
            break
    return x
def animate_clear(board):
    x = []
    new_board = np.array(board)
    a = np.sum(board>0,axis=1)
    full = (a==board.shape[1])
    new_board[full] = 0
    x.append(new_board)
    for i in range(board.shape[0]-1,-1,-1):
        nb = np.zeros_like (board, int)
        if np.sum(new_board[i,:])==0 and len(x)==1:
            nb[i+1:,:] = new_board[i+1:,:]
            nb[1:i+1,:] = new_board[:i,:]
            nb_copy = np.array(nb)
            x.append(nb)
        elif np.sum(new_board[i,:])==0:
            nb[i+1:,:] = nb_copy[i+1:,:]
            nb[1:i+1,:] = new_board[:i,:]
            x.append(nb)
    return x

xxx038xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 2036, 'const': 838, 'code+const': 2874}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 14)], [('While', 9)]]
import numpy as np
def get_score(board):
    array40 = np.array([40]*len(board))
    first_boo = (board == 0)
    sum_first_boo = np.sum(first_boo, axis=1)
    second_boo = (sum_first_boo == 0)
    score = array40[second_boo]
    return score.sum()
def get_time_cap(board, time_caps):
    first_boo = (board != 0)
    sum_first_boo = np.sum(first_boo, axis=1)
    second_boo = (sum_first_boo == 0)
    nrows = np.arange(len(board))
    index_arr = nrows[second_boo]
    if len(index_arr) == 0: index = 0
    elif index_arr[-1] == 0: index = 0
    elif index_arr[-1] == len(board)-1: index = len(board)-1
    else: index = index_arr[-1] + 1
    time_caps_len = len(time_caps)
    multiplier = int(len(board)//len(time_caps))
    new_time_caps = time_caps * multiplier
    new_time_caps.sort()
    return new_time_caps[index]
def rotate_right(shape):
    new_shape = shape[::-1]
    return new_shape.T
def rotate_left(shape):
    new_shape = shape[::-1]
    new_shape = new_shape.T
    new_shape = new_shape[::-1]
    new_shape = new_shape.T
    new_shape = new_shape[::-1]
    return new_shape.T
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    resized_board = resize_board1(new_board, c)
    lapse = len(new_board) - len(new_shape) + 1
    l_out = []
    top = 0
    bottom = len(new_board) - len(new_shape)
    resized_board = resize_board2(resized_board, top, bottom)
    checker_boo = (resized_board == 0)
    diff = len(checker_boo[0]) - len(new_shape[0])
    can_place_shape = check_place_shape(checker_boo, new_shape, diff)
    if not firsttime_check_place_shape(checker_boo, new_shape, diff): return []
    while can_place_shape:
        out_board = place_shape(new_board, new_shape, c, top)
        l_out.append(out_board)
        top += 1
        bottom -= 1
        if bottom <0 : return l_out
        new_board = np.array(board)
        resized_board = resize_board1(new_board, c)
        resized_board = resize_board2(resized_board, top, bottom)
        checker_boo = (resized_board == 0)
        if len(checker_boo) == 0: return l_out
        diff = len(checker_boo[0]) - len(new_shape[0])
        can_place_shape = check_place_shape(checker_boo, new_shape, diff)
    return l_out
def place_shape(board, new_shape, c, top): 
    board[top:top+len(new_shape), c:c+len(new_shape[0])] += new_shape
    return board
def check_place_shape(checker_boo, new_shape, diff):
    checker_boo = resize_board3(checker_boo, diff)
    reshaped_checker_boo = checker_boo.reshape(len(checker_boo)*len(checker_boo[0]))
    reshaped_new_shape = new_shape.reshape(len(new_shape)*len(new_shape[0]))
    placed_shape = reshaped_new_shape[reshaped_checker_boo]
    sum_of_placed = sum(placed_shape)
    checker_again = (reshaped_new_shape > 0)
    number_of_block = reshaped_new_shape[checker_again]
    sum_of_block = sum(number_of_block)
    if sum_of_placed == sum_of_block: return True
    else: return False
def firsttime_check_place_shape(checker_boo, new_shape, diff):
    checker_arr = np.arange(len(new_shape))
    checker = (new_shape != 0)
    checker2 = np.sum(checker, axis=1)
    highest = np.max(checker2)
    pos = checker_arr[checker2 == highest]
    position = pos[-1]
    if position == 0: return True
    if position == len(new_shape): return True
    filter_list = [True]*len(new_shape[0])
    filter_list *= position
    filter_arr = np.array(filter_list)
    sum_of_filter = np.sum(filter_arr)
    checker_boo = resize_board3(checker_boo, diff)
    checker_boo = resize_board2(checker_boo, 0, len(new_shape)-position)
    reshaped_checker_boo = checker_boo.reshape(len(checker_boo)*len(checker_boo[0]))
    sum_of_checker = np.sum(reshaped_checker_boo)
    if sum_of_filter != sum_of_checker: return False
    else: return True
def resize_board1(board, c):
    l = [False]*c
    dl = [True]*(len(board[0])-c)
    l += dl
    checker_boo = np.array([l]*len(board))
    new_board = board[checker_boo].reshape(len(board),len(board[0])-c)
    return new_board
def resize_board2(board, t, b):
    new_board = rotate_right(board)
    new_board = resize_board1(new_board, b)
    new_board = rotate_left(new_board)
    new_board = rotate_left(new_board)
    new_board = resize_board1(new_board, t)
    new_board = rotate_right(new_board)
    return new_board
def resize_board3(board, c):
    l = [True]*(len(board[0])-c)
    dl = [False]*c
    l += dl
    checker_boo = np.array([l]*len(board))
    new_board = board[checker_boo].reshape(len(board),len(board[0])-c)
    return new_board
def animate_clear(board):
    new_board = np.array(board)
    new_board = clear_row(new_board)      
    row_index_arr = check_row0(new_board) 
    if len(row_index_arr) == 0: return [] 
    else: can_place = True                
    l_out = []
    l_out.append(new_board)
    while can_place and check_top(row_index_arr):
        new_board = replace_row(new_board, row_index_arr) 
        l_out.append(new_board)
        row_index_arr = check_row0(new_board) 
        if len(row_index_arr) == 0: can_place == False
    return l_out
def copy_board(new_board):
    newer_board = np.array(new_board)
    return newer_board, new_board
def clear_row(new_board):
    checker_boo = (new_board != 0)
    sum_checker_boo = np.sum(checker_boo, axis=1)
    ncols = len(new_board[0])
    nrows = len(new_board)
    checker = (sum_checker_boo != ncols)
    checker = checker.reshape(nrows, 1)
    cleared_row_board = new_board * checker
    return cleared_row_board
def check_row0(new_board): 
    sum_checker = np.sum(new_board, axis=1)
    checker_boo = (sum_checker == 0)
    row_index = np.arange(len(new_board))
    row_index = row_index[checker_boo]
    return row_index
def replace_row(board, row_index):
    new_board = np.array(board)
    row_index_top = row_index - 1
    bottom = len(new_board) - row_index[-1]
    resized_new_board = resize_board2(new_board, 0, bottom)
    new_board[:row_index[-1],:] -= resized_new_board
    new_board[1:row_index[-1]+1,:] += resized_new_board
    return new_board
def check_top(index_arr):
    if (len(index_arr) == 1) and (index_arr[-1] == 0): return False 
    if index_arr[0] == 0:
        last_digit = index_arr[-1]
        checker = np.arange(last_digit+1)
        if len(checker) == len(index_arr): 
            diff = checker - index_arr
            sum_of_diff = np.sum(diff)
            if sum_of_diff == 0: return False 
            else: return True
        else: return True 
    else: return True

xxx043xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1278, 'const': 356, 'code+const': 1634}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 21)]]
import numpy as np
def get_score(board):
    board2 = board == 0
    a = board2.sum(axis=1)
    return len(board[a == 0])*40
def get_time_cap(board, time_caps):
    r = len(time_caps)
    board2 = board.reshape((r, int(board.shape[1]*board.shape[0]/r)))
    board3 = board2 != 0
    a = board3.sum(axis=1)
    t = np.array(time_caps)
    result = t[a != 0]
    if len(result) == 0:
        return time_caps[-1]
    else:
        return result[0]
def rotate_right(shape):
    shape2 = shape[::-1, :]
    return shape2.T
def rotate_left(shape):
    shape2 = shape.T
    return shape2[::-1, :]
def animate_drop(board, shape, c):
    result = []
    new_shape = np.array(shape)
    n = 1
    if shape.shape[0] <= board.shape[0]:
        for i in range(board.shape[0]):
            new_board = np.array(board)
            if new_shape.shape[0] == 1:
                v = new_shape[0][0]
                if np.sum(new_board[i, c:c+new_shape.shape[1]]) == 0:
                    new_board[i, c:c+new_shape.shape[1]] = v
                    result.append(new_board)
                else:
                    break
            else:
                if n < new_shape.shape[0]:
                    if np.sum(np.max((new_board[:n, c:c+new_shape.shape[1]], new_shape[new_shape.shape[0]-n:]), axis=0)) == np.sum(new_board[:n, c:c+new_shape.shape[1]]+new_shape[new_shape.shape[0]-n:]):
                        n += 1
                    else:
                        break
                else:
                    if np.sum(np.max((new_board[i-n+1:i-n+1+new_shape.shape[0], c:c+new_shape.shape[1]], new_shape), axis=0)) == np.sum(new_board[i-n+1:i-n+1+new_shape.shape[0], c:c+new_shape.shape[1]] + new_shape):
                        new_board[i-n+1:i-n+1+new_shape.shape[0], c:c+new_shape.shape[1]] = new_board[i-n+1:i-n+1+new_shape.shape[0], c:c+new_shape.shape[1]] + new_shape
                        result.append(new_board)
                    else:
                        break
    return result
def animate_clear(board):
    new_board = np.array(board)
    board2 = new_board == 0
    board3 = board2.sum(axis=1)
    if 0 not in board3:
        return []
    if sum(board3) == 0:
        return [np.zeros((new_board.shape[0], new_board.shape[1]), int)]
    i = np.arange(board.shape[0])
    i = i[board3 == 0]
    new_board[i, :] = 0
    board4 = new_board == 0
    board5 = board4.sum(axis=1)
    nz = np.sum(board5 == board.shape[1])
    n = np.array(new_board)
    result = []
    result.append(n)
    i = n.shape[0]
    j = 1
    while True:
        if np.sum(new_board[i-j, :]) == 0:
            new_board[1:i-j+1, :], new_board[0, :] = new_board[0:i-j, :], 0
            n = np.array(new_board)
            result.append(n)
        else:
            j += 1
        if np.sum(new_board[:nz, :]) == 0:
            break
    return result

xxx120xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[array([[2, 2, 2, 0],
       [3, 0, 1, 1]])], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[ 0,  0,  0,  0,  0,  0],
       [ 0,  2,  2,  2,  0,  0],
       [ 0,  0,  0,  2,  8,  0],
       [ 1,  1,  0, 10,  8,  0],
       [ 1,  1,  0,  0,  8,  0]]),
  array([[ 0,  0,  0,  0,  0,  0],
       [ 0,  0,  0,  0,  0,  0],
       [ 0,  2,  2,  2,  8,  0],
       [ 1,  1,  0, 10,  8,  0],
       [ 1,  1,  0,  2,  8,  0]])],
 [array([[ 0,  0,  2,  2,  2,  0],
       [ 0,  0,  0,  0,  2,  0],
       [ 0,  0,  0,  0, 10,  0],
    ... (more)
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0ValueError('could not broadcast input array from shape (3,4) into shape (0,4)')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 1030, 'const': 398, 'code+const': 1428}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 29)]]
import numpy as np
def get_score(board):
    x = board != 0
    a = np.sum(x, axis = 1)
    ans = sum(a == len(board[0]))
    return ans*40
def get_time_cap(board, time_caps):
    x = board != 0
    a = np.sum(x, axis = 1)
    if sum(a) == 0 :
        return time_caps[-1]
    else :
        pos = np.arange(a.shape[0])
        index = pos[a != 0]
        return time_caps[index[0]//2]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    ans = []
    for i in range(len(board)) :
        a = board[i, c:c+len(shape[0])] 
        b = board[i:len(shape)+i, c:c+len(shape[0])]
        new_board = np.array(board)
        if sum(a) == 0 :
            if sum(np.sum(b,axis =1)) != 0 and sum(new_board[i:len(shape)+i, c:c+len(shape[0])][-1]) == 0 :
                break
            else :
                new_board[i:i+len(shape),c:c+len(shape[0])] += new_shape
                ans.append(new_board)
        else :
            break
    return ans
def animate_clear(board):
    ans = []
    new_board = np.array(board)
    x = board[:,:] == 0
    a = np.sum(x, axis = 1)
    pos = np.arange(a.shape[0])
    index = pos[a == 0]
    new_board[index] = 0
    ans.append(new_board)
    y = new_board[:,:] != 0
    j = np.sum(y, axis = 1)
    if sum(j) == 0:
        return ans
    else :
        f = np.arange(j.shape[0])
        g = f[j!= 0]
        h = j[g[0]:]
        num = sum(h == 0)
    i = 1
    if num == 0 :
        ans = []
    elif num == 1 and sum(ans[-1][-1]) == 0 :
        new = np.array(ans[-1])
        new[1:] = ans[-1][:-i]
        new[0] = 0
        ans.append(new)
    else :
        while i <= num :
            new = np.array(ans[-1])
            if sum(new[-i]) == 0 :
                new[1:-i+1] = ans[-1][:-i]
                new[0] = 0
                ans.append(new)
            else :
                i += 1
            test = new[:-i] != 0
            still = np.sum(test, axis = 1)
            if i > num and sum(still) > 0 :
                num += 1
    return ans

xxx024xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 958, 'const': 352, 'code+const': 1310}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('For', 15)]]
import numpy as np
def get_score(board):
    t=board==0
    s=np.sum(t,axis=1)
    a=s[s==0]
    return len(a)*40
def get_time_cap(board, time_caps):
    t=board!=0
    s=np.sum(t,axis=1)
    a=s!=0
    if True in a:
        index=np.arange(board.shape[0])
        not_all0=index[a]
        first=not_all0[0]
        return time_caps[first//(board.shape[0]//len(time_caps))]
    else:
        return time_caps[-1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    ans=[]
    if 0 <= c <= board.shape[1]-shape.shape[1]:
        for k in range(board.shape[0]-shape.shape[0]+1):
            a=np.zeros_like(board)
            A = board[k:k+shape.shape[0],c:c+shape.shape[1]:]
            if np.sum((A+shape==shape)&(shape!=0))==np.sum(shape!=0):
                a[k:k+shape.shape[0],c:c+shape.shape[1]:]=shape
                b=board+a
                ans.append(b)
            else:
                return ans
    return ans
def animate_clear(board):
    a=board!=0
    b=np.arange(board.shape[0])
    c=np.sum(a,axis=1)
    s=b[c == board.shape[1]]
    d=np.array(board)
    ans=[]
    if np.sum(np.sum(d!=0,axis=1)==d.shape[1])!=0:
        d[s]= 0
        total_0=b[np.sum(d,axis=1)==0][::-1]
        new_board = np.array(board)
        new_board = np.array(d)
        ans.append(d)
        for i in range(len(total_0)):
            new_board[i:i+1:,:]=[0]*board.shape[1]
            total_0=b[np.sum(d,axis=1)==0][::-1]
            new_board[i+1:total_0[0]+1:,:]=d[i:total_0[0]:]
            if np.sum(np.array(new_board).reshape(d.shape[0]*d.shape[1])==                  np.array(ans[-1]).reshape(d.shape[0]*d.shape[1]))== d.shape[0]*d.shape[1]:
                break
            k=np.array(new_board)
            ans.append(k)
            d = np.array(new_board)
    return ans

xxx212xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[[2, 2, 2, 0, 0, 0],
        [0, 0, 2, 0, 0, 0],
        [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 82, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
        [1, 1, 0, 0, 8, 0]]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0IndexError('index 2 is out of bounds for axis 0 with size 2')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]]),
  array([[1, 0, 2, 4],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1198, 'const': 306, 'code+const': 1504}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep:
   [[], [('tolist', 7)], [('transpose', 6)], [], [('tolist', 16)], [('array_equal', 31), ('tolist', 10), ('any', 21), ('tolist', 22), ('tolist', 28)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep:
   [[('ListComp', 2)], [('For', 4), ('For', 10), ('For', 6)], [('For', 4)], [('For', 5), ('For', 11), ('For', 7)], [('For', 5), ('For', 8), ('For', 9), ('For', 13), ('For', 14)], [('For', 5), ('For', 16), ('For', 20), ('For', 29), ('ListComp', 8)]]
import numpy as np
def get_score(board):
    return sum([40 if 0 not in i else 0 for i in board])
def get_time_cap(board, time_caps):
    ind = 0
    res = []
    for i in range(len(time_caps)):
        temp = []
        for j in range(board.shape[0] // len(time_caps)):
            temp += board[ind].tolist()
            ind+=1
        res.append(temp)
    for i, j in zip(res, range(len(time_caps))):
        if sum(i)>0:
            return time_caps[j]
    return time_caps[-1]
def rotate_right(shape):
    row = shape.shape[0]
    m = []
    for i in range(row-1, -1, -1):
        m.append(shape[i])
    return np.transpose(np.array(m))
def rotate_left(shape):
    col = shape.shape[1]
    row = shape.shape[0]
    m = []
    for i in range(col):
        temp = []
        for j in range(row):
            temp.append(shape[j][i])
        m.append(temp)
    r = []
    for i in range(len(m)-1, -1, -1):
        r.append(m[i])
    return np.array(r)
def animate_drop(board, shape, c):
    new_board = np.array(board)
    ans = []
    rn = 0
    for k in range(4):
        f = 0
        temp = []
        for i in range(shape.shape[0]):
            for j in range(shape.shape[1]):
                if new_board[rn+i][j+c] != 0:
                    f=1
        if f==0:
            for i in range(shape.shape[0]):
                for j in range(shape.shape[1]):
                    new_board[rn+i][j+c] = shape[i][j]
            temp.append(new_board.tolist())
            ans.append(np.array(temp))
            new_board[rn] = [0]
            rn+=1
            new_board[rn] = [0]
    return ans
def animate_clear(board):
    r = []
    m = []
    c=0
    for i in board:
        if 0 not in i:
            c+=1
            m.append([0 for i in range(len(i))])
            continue
        m.append(i.tolist())
    if c==0:return []
    m = np.array(m)
    r.append(m)
    ind = 0
    new_m = np.array(m)
    for i in range(c+1):
        f = 0
        temp = []
        temp2 = []
        for i in range(new_m.shape[0]-1, -1, -1):
            if new_m[i].any()==[0]  and f==0:
                temp.append(new_m[i-1].tolist())
                new_m[-1] = [0]
                f = 1
            else:
                if f==1:
                    i-=1
                temp.append(new_m[i].tolist())
        for i in range(len(temp)-1, -1, -1):
            temp2.append(temp[i])
        if np.array_equal(np.array(temp2), r[-1]):
            break
        r.append(np.array(temp2))
        new_m = np.array(np.array(temp2))
    return r

xxx220xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 296, 'const': 240, 'code+const': 536}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
import numpy as np
def get_score(board):
  a = board > 0 ; b = np.sum(a,axis=1) ; c = b==board.shape[1] ; point = np.sum(c)*40
  return point
def get_time_cap(board, time_caps):
  a = board > 0  ; b = np.sum(a,axis=1) ; c = b<=0
  if np.sum(board) != 0:
    d = np.sum(c)  ; f = board.shape[0]//len(time_caps) 
    v = time_caps[d//f]
    return v
  if np.sum(board) == 0:
    v = time_caps[-1]
    return v
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
    pass

xxx039xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 810, 'const': 338, 'code+const': 1148}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 8)], [('While', 12)]]
import numpy as np
def get_score(board):
    return np.sum(np.sum(board !=0,axis=1)==board.shape[1])*40
def get_time_cap(board, time_caps):
    n = board.shape[0]//len(time_caps)
    x= np.sum(board,axis=1)!=0
    rge = np.arange(board.shape[0])
    out = rge[x]
    if len(out)==0:
        return(time_caps[-1])
    else:
        return(time_caps[out[0]//n])
def rotate_right(shape):
    return (shape.T[:,::-1])
def rotate_left(shape):
    return (shape.T[::-1])
def animate_drop(board, shape, c):
    sum_tf_shape = np.sum(shape!=0)    
    nrs,ncs = shape.shape    
    rge =board.shape[0]-nrs+1
    out = list()
    count =0
    while count != rge:
            cpb = np.array(board)                    
            zero_board = np.zeros((cpb.shape[0],cpb.shape[1]),int)
            zero_board[count:count+nrs,c:c+ncs] = shape           
            fill = (board==0)&(zero_board != 0)
            if sum_tf_shape == np.sum(fill) :
               cpb[count:count+nrs,c:ncs+c] += shape
               out.append(cpb)
               count+=1 
            else: break
    return out
def animate_clear(board):
    out=list()
    rol,col=board.shape
    new_board=np.array(board)
    a=np.sum(board!=0,axis=1)
    b=np.arange(a.shape[0])
    if np.sum(a==col)==0 : 
      return []
    new_board[b[a==col]]=np.zeros((1,col),int)
    out.append(new_board)
    while True:
        tf= new_board==0
        sum_value_tf=tf.sum(axis=1)
        sum_value_tf=b[sum_value_tf==col]
        if np.sum(new_board[:len(sum_value_tf)])==0:
          return out
        zero_board=np.zeros_like(board,int)
        n=sum_value_tf[-1]+1
        s2=np.arange(board.shape[1]*board.shape[0])
        zero_board[1:]=new_board.reshape(1,rol*col)[((s2<(col*(n-1)))|(s2>=(col*n))).reshape(1,rol*col)].reshape(rol-1,col)
        out.append(zero_board)
        new_board=zero_board

xxx208xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0IndexError('index 2 is out of bounds for axis 0 with size 2')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0IndexError('index 5 is out of bounds for axis 0 with size 5')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 02, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (2,) into shape (1,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1166, 'const': 366, 'code+const': 1532}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('For', 13)]]
import numpy as np
def get_score(board):
  mini = np.min(board,axis=1)
  score = mini[mini>0]
  return len(score)*40
def get_time_cap(board, time_caps):
  maxi = np.max(board,axis=1) 
  index = np.arange(board.shape[0]) 
  search = maxi > 0 
  tc = sorted(time_caps*int((board.shape[0]/len(time_caps))))
  i = index[search]
  if len(i) != 0 :
    e = i[0]
    return tc[e]
  else :
    return tc[-1]
def rotate_right(shape):
  a = shape[::-1]
  return a.T
def rotate_left(shape):
  a = shape[:,::-1]
  return a.T
def animate_drop(board, shape, c):
  newb = np.array(board)
  news = np.array(shape)
  out = []
  if newb[0,c] == 0 :
    for i in range(newb.shape[0]) :
      if news.shape[0] == 1 :
        if newb[i,c] == 0 :
          newb[i,c:news.shape[1]+1] = news
          out.append(newb)
          newb = np.array(board)
      elif news.shape[0] == 2 :
        if newb[i,c] == 0 :
          newb[i,c:c+news.shape[1]] = news[0]
          if newb[i+1,c] == 0 :
            newb[i+1,c:c+news.shape[1]] = news[1]
            out.append(newb)
            newb = np.array(board)
          else :
            return out
        else : return out
      elif news.shape[0] == 3 :
        if newb[i,c] == 0 :
          newb[i,c:c+news.shape[1]] = news[0]
          if newb[i+1,c] == 0 :
            newb[i+1,c:c+news.shape[1]] = news[1]
            if newb[i+2,c] == 0 :
              newb[i+1,c:c+news.shape[1]] = news[2]
              out.append(newb)
              newb = np.array(board)
            else :
              return out
          else :
            return out
        else :
          return out
    return out
  else :
    return out
def animate_clear(board) :
  out = []
  newb = np.array(board)
  index = np.arange(newb.shape[0])
  mini = np.min(newb,axis=1)
  dis = mini > 0
  if len(mini[mini>0]) == 0 :
    return out
  i = index[dis]
  newb[i] = 0
  out.append(np.array(newb))
  c = 0
  for i in range(board.shape[0]-1,-1,-1) :
    data = newb == 0
    aa = np.sum(data,axis=1) == newb.shape[1]
    pos = np.arange(newb.shape[0])
    if len(pos[aa]) != 0 :
      info = pos[aa][-1] 
      newb[1:info+1] = newb[:info]
      newb[0] = np.zeros((1,board.shape[1]),int)
      c += 1
      if c > len(pos[aa]) :
          break
      elif np.sum(newb[:pos[aa][-1]+1]) == 0 :
          break
      copy = np.array(newb)
      out.append(copy)
  return out

xxx220xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 812, 'const': 350, 'code+const': 1162}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 14)]]
import numpy as np
def get_score(board):
    a = np.min(board,axis=1)
    return len(a[a!=0])*40
def get_time_cap(board, time_caps):
  if np.max(board) == 0:
    return time_caps[-1]
  x,y = board.shape
  l = len(time_caps)
  return time_caps[np.min(np.arange(l)[np.sum(np.sum(board, axis = 1).reshape((l,x//l)), axis = 1) != 0])]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
  json = []
  new_board = np.array(board)
  new_shape = np.array(shape)
  r,l = board.shape
  x,y =  shape.shape
  for e in range(r-x+1):
    if np.dot(new_board[np.arange(x) + e, c:c+y].reshape((1,x*y))[0], new_shape.reshape(1,x*y)[0]) == 0 and np.sum(board[:x-1,c:c+y]*shape[1-x:]) == 0:
      new_board[np.arange(x) + e, c:c+y] += shape
      json.append(new_board)
      new_board = np.array(board)
      new_shape = np.array(shape)
    else:break
  return json
def animate_clear(board):
  result = []
  clear = np.min(board, axis = 1) != 0
  clear = np.arange(np.shape(board)[0])[clear]
  new_board = np.array(board)
  if len(clear) > 0:
    new_board[clear] = 0
    result = [new_board]
  m = np.max(new_board, axis = 1) == 0
  if len(np.arange(np.shape(board)[0])[m]) == 0:
    return result
  m = max(np.arange(np.shape(board)[0])[m])
  new_board = np.array(new_board)
  while m > 0:
    if False not in (new_board[:m] == 0):
      break
    new_board[1:m+1] = new_board[:m]
    new_board[0] = 0
    result.append(np.array(new_board))
    if True in (new_board[m] != 0):
      m -= 1
  return result

xxx142xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 1812, 'const': 366, 'code+const': 2178}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 10)], [('While', 20)]]
import numpy as np
def get_score(board):
  find_zero = np.min(board,axis=1)
  tf = (find_zero!=0)
  not_zero = find_zero[tf]
  multi = len(not_zero)
  score = multi*40
  return score
def get_time_cap(board, time_caps):
  find_max = np.max(board,axis=1)
  TF = (find_max==0)
  zero = find_max[TF]
  interval = len(board) // len(time_caps)
  if len(zero) == len(board):
      time = time_caps[-1]
  else:
      row = len(zero)+1
      time = time_caps[((row+(interval-1)) // interval)-1]
  return time
def rotate_right(shape):
    rc = shape.shape
    cr = rc[::-1]
    new_shape = shape[::-1]
    new_shape = new_shape.T
    return new_shape
def rotate_left(shape):
    rc = shape.shape
    cr = rc[::-1]
    new_shape = shape.T
    new_shape = new_shape[::-1]
    return new_shape
def animate_drop(board, shape, c):
    out=[]
    rb,cb = board.shape
    rs,cs = shape.shape
    default_board = np.array(board)
    default_shape = np.array(shape)             
    default_0 = len(default_board[(default_board==0)]) - len(default_shape[(default_shape!=0)])
    for i in range(rb-(rs-1)):
        if np.min(shape) == 0:
            new_board = np.array(board)
            result = new_board[i:i+rs,c:c+cs] + default_shape
            new_board[i:i+rs,c:c+cs] = result
            new_tf = (new_board==0)
            new_0 = len(new_board[new_tf])
            if new_0 == default_0:
                out.append(new_board)
                check = (new_board[i:i+rs,c:c+cs] == shape)
                if rs<=2:
                    check2 = (new_board[i,c:c+cs] == shape[0])
                    top = np.array(shape[0])
                    if len(default_shape[check]) != (rs*cs):
                        if len(top[check2]) != cs:
                            x=out.pop(-1)
                            break
                        break
                    if i != 0:
                        if np.max(new_board[0:i,c:c+cs]) != 0 :
                            x=out.pop(-1)
                            break
                if rs>2:
                    check3 = (new_board[i:i+rs-1,c:c+cs] == shape[0:rs-1,0:cs])
                    body = np.array(shape[0:rs-1,0:cs])
                    if len(default_shape[check]) != (rs*cs):
                        if len(body[check3]) != (rs-1)*cs:
                            x=out.pop(-1)
                            break
                        break
                    if i != 0:
                        if np.max(new_board[0:i,c:c+cs]) != 0 :
                            break
        elif np.min(shape) != 0:
            new_board2 = np.array(board)
            if np.sum(new_board2[i:i+rs,c:c+cs]) == 0:
                new_board2[i:i+rs,c:c+cs] = shape
                out.append(new_board2)
            elif np.sum(new_board2[i:i+rs+1,c:c+cs]) != 0:
                break
    return out
def animate_clear(board):
    r,c = board.shape
    new_board = np.array(board)
    find_zero = np.max(new_board, axis=1)
    all_zero = (find_zero==0)
    find_num = np.min(new_board, axis=1)
    all_num = (find_num!=0)
    limit = r - (len(find_zero[all_zero]) + len(find_num[all_num]))
    s = 0
    i = 0
    k = r-2
    out=[]
    if limit == r:
        return out
    while True:
        if s == 0 :
            if i <= r-1:
                if min(list(new_board[i])) == 0:
                    i+=1
                elif min(list(new_board[i])) != 0:
                    new_board[i] = 0
                    i+=1
            if i == r :
                s = 1
                newer_board = np.array(new_board)
                out.append(newer_board)
        if s == 1  :
            check_board = np.array(new_board)
            find_max = np.max(check_board,axis=1)
            tf = (find_max!=0)
            find_max = find_max[tf]
            fm = (list(find_max))
            if k <= r-2:
                if max(new_board[k]) == 0:
                    k-=1
                    if k < 0:
                        newer_board = np.array(new_board)
                        out.append(newer_board)
                        k= r-2
                        if fm == list(np.max(new_board[r-limit:,::],axis=1)):
                            break
                elif max(new_board[k]) != 0:
                    if max(new_board[k+1]) == 0:
                        new_board[k+1] = new_board[k]
                        new_board[k] = 0
                        k-=1
                        if k < 0:
                            newer_board = np.array(new_board)
                            out.append(newer_board)
                            k=r-2
                            if fm == list(np.max(new_board[r-limit:,::],axis=1)):
                                break
                    elif max(new_board[k+1]) != 0:
                        k-=1
                        if k < 0:
                            newer_board = np.array(new_board)
                            out.append(newer_board)
                            k=r-2
                            if fm == list(np.max(new_board[r-limit:,::],axis=1)):
                                break
    return out

xxx018xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1020, 'const': 338, 'code+const': 1358}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 40)], [('For', 19)]]
import numpy as np
def get_score(board):
    minnie = np.min(board, axis=1)
    use = minnie[minnie > 0]
    return 40*len(use)
def get_time_cap(board, time_caps):
    this_row = np.max(board, axis=1)
    index1 = np.arange(0, this_row.shape[0])
    want = index1[this_row > 0]
    if len(want) == 0:
        return time_caps[-1]
    pos = want[0]  
    rangee = this_row.shape[0]//len(time_caps)  
    ind = pos//rangee
    return time_caps[ind]
def rotate_right(shape):
    a = shape[-1::-1, :]
    return a.T
def rotate_left(shape):
    a = shape[:, -1::-1]
    return a.T
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    keep_list = []
    if board[0, c] != 0:
        return keep_list
    if new_shape.shape[1] > board.shape[1] - c:  
        return keep_list
    if new_shape.shape[0] > board.shape[0]:  
        return keep_list
    shape_row = new_shape.shape[0]
    shape_col = new_shape.shape[1]
    row = 0
    i = shape_row-1
    tf_shape = new_shape > 0
    row_board = new_board.shape[0]
    while row < row_board:
        if i != 0:
            spec_b = board[0:abs(shape_row-i), c:c+shape_col]
            spec_s = shape[i:, :]
            tf_spec_s = spec_s > 0
            tf_spec_b = spec_b > 0
            interr = tf_spec_b & tf_spec_s
            summ = np.sum(interr)
            if summ > 0:
                return keep_list
            i -= 1
        else:
            specific = board[row:row+shape_row, c:c+shape_col]  
            if specific.shape[0] != shape_row:
                break
            tf_specific = specific > 0
            inter = tf_shape & tf_specific
            summy = np.sum(inter)
            if summy > 0:
                break
            else:
                new_board = np.array(board)
                new_board[row:row+shape_row, c:c+shape_col] += new_shape
                keep_list.append(new_board)
                row += 1
    return keep_list
def animate_clear(board):
    keep = []
    new_board = np.array(board)
    pos = np.arange(0, new_board.shape[0])
    minnie = np.min(new_board, axis=1)
    want = pos[minnie > 0]
    if len(want) == 0:
        return keep
    new_board[want] = [0]*new_board.shape[1]
    keep.append(new_board)
    stick = np.max(new_board, axis=1)
    stick_use = stick == 0
    what_ind = pos[stick_use]  
    prev_board = np.array(new_board)
    what_ind = what_ind[::-1]
    for e in what_ind:
        new_board = np.array(new_board)
        new_board[1:e+1, :] = new_board[0:e, :]
        new_board[0, :] = [0]*new_board.shape[1]
        if np.sum(new_board != prev_board) == 0:
            return keep
        keep.append(new_board)
        prev_board = np.array(new_board)
        what_ind += 1
    return keep

xxx042xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[ 0,  0,  0,  0,  0,  0],
       [ 0,  2,  2,  2,  0,  0],
       [ 0,  0,  0,  2,  8,  0],
       [ 1,  1,  0, 10,  8,  0],
       [ 1,  1,  0,  0,  8,  0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, ... (more)
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 774, 'const': 242, 'code+const': 1016}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 10)]]
import numpy as np
def get_score(board):
  return np.sum(np.sum((board == 0),1) == 0)*40
def get_time_cap(board, time_caps):
  check = board.reshape(len(time_caps),board.shape[1]*board.shape[0]//len(time_caps))
  a = np.sum(check != 0,1)>0
  if np.sum(a) == 0:
    return time_caps[-1]
  else:
    return np.array(time_caps)[a][0]
def rotate_right(shape):
  return shape[-1::-1].T
def rotate_left(shape):
  return shape[:,-1::-1].T
def animate_drop(board, shape, c):
    bt_shape= np.zeros((board.shape [0]+shape.shape [0], board.shape [1]), int) 
    bt_shape [:shape. shape [0], c: shape.shape [1]+c] = shape
    bt_shape [shape.shape [0]:] = board
    t = np.min(np.sum (bt_shape [:,c:]==0,0))
    anim_seq= []
    for i in range(t):
      frame = np.array(bt_shape)
      frame [i+1: shape.shape [0]+i+1, c:c+shape.shape[1]]+= shape
      anim_seq.append(frame [shape.shape[0]:])
    return anim_seq[shape.shape[0]-1:]
def animate_clear(board):
    cframe = []
    a = np.sum(board == 0,1) != 0 ; lst = np.arange(board.shape[0])
    if np.sum(a) == board.shape[0]:
      return cframe
    new_board = a.reshape((board.shape[0],1))*board
    cframe.append(new_board)
    cs = lst[np.sum(new_board,1) == 0]
    while np.sum(new_board[1:cs[-1]+1]) != 0:
      oboard = np.array(new_board)
      oboard[1:cs[-1]+1] = new_board[:cs[-1]]
      oboard[0] = np.zeros(board.shape[1])
      cframe.append(oboard)
      new_board = np.array(oboard)
      cs = lst[np.sum(new_board,1) == 0]
    return cframe

xxx205xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[None56, None56, None56, None56, None45, None45, None45]
test_rotate_right0.0
[Nonearray([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, None0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left0.0
[Nonearray([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, None4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 168, 'const': 198, 'code+const': 366}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
import numpy as np
def get_score(board):
  m = np.min(board,axis=1)
  s = np.sum(m != 0)
  return s*40
def get_time_cap(board, time_caps):
  max = np.max(board, axis=1)
  p = np.arange(len(board))
  if len(board) == 0:
    return 
    pass
def rotate_right(shape):
    pass
def rotate_left(shape):
    pass
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
    pass

xxx206xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 800, 'const': 390, 'code+const': 1190}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 3)], [('For', 10)]]
import numpy as np
def get_score(board):
    check = np.array(board == board*2)
    result = np.sum(np.array(np.sum(check,axis = 1)==0)) * 40      
    return result
def get_time_cap(board, time_caps):
    if np.sum(board != 0) == 0:
        return time_caps[-1]
    cap = board.shape[0]/len(time_caps)
    index = np.arange(0,board.shape[0],1)
    check = np.array(board != 0)
    result = index[np.array(np.sum(check,axis = 1)!=0)][0]
    return time_caps[int(result//cap)]
def rotate_right(shape):
    return shape.T[0::1,-1::-1]
def rotate_left(shape):
    return shape.T[-1::-1,0::1]
def animate_drop(board, shape, c):
    result = []
    for row in range(board.shape[0]):
        new_board = np.array(board)
        if (new_board[row:row+shape.shape[0]:1,c:c+shape.shape[1]:1].shape != shape.shape):
            break
        if np.sum(np.array(new_board[row:row+shape.shape[0]:1,c:c+shape.shape[1]:1]==0) | (shape==0))==shape.size :
            new_board[row:row+shape.shape[0]:1,c:c+shape.shape[1]:1] += shape 
            result.append(np.array(new_board))
        else:break                  
    return result
def animate_clear(board):
    check = np.sum(board == 0,axis=1)
    index = np.arange(0,board.shape[0],1)[check == 0]
    if len(index) == 0:
        return []
    new_board = np.array(board)
    new_board[index,0::1] = 0
    result = [np.array(new_board)]
    row = board.shape[0]-1
    for times in range(board.shape[0]):
        if np.sum(new_board[row]) == 0 and np.sum(new_board[0:row:1]) != 0:
            new_board[1:row+1:1]=new_board[0:row:1]
            new_board[0]=0
            result.append(np.array(new_board))
        else:
            row-=1     
    return result

xxx201xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 752, 'const': 338, 'code+const': 1090}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('For', 11)]]
import numpy as np
def get_score(board):
    m = np.min(board,axis=1)
    n = 40*sum(m != 0)
    return n
def get_time_cap(board, time_caps):
    n = board.reshape(len(time_caps),(board.shape[0]//len(time_caps))*board.shape[1])
    m = np.max(n,axis=1)
    a = m!=0  
    y = np.array(time_caps)
    n = list(y[a])
    if n != []:
        b = n[0]
    else:
        b = y[-1]
    return b
def rotate_right(shape):
    a = shape[::-1,:]
    return a.T
def rotate_left(shape):
    a = shape[:,::-1]
    return a.T
def animate_drop(board, shape, c):
    x = []
    n = np.sum(board != 0) +  np.sum(shape != 0)
    for i in range(board.shape[0]-shape.shape[0]+1):
        new_board = np.array(board)
        new_board[i:i+shape.shape[0],c:c+shape.shape[1]] += shape
        if np.sum(new_board != 0) == n: 
            x.append(new_board)
        else: 
            break
    return x
def animate_clear(board):
    x = []
    new_board = np.array(board)
    m = np.min(board,axis=1) != 0
    new_board[m,:] = 0
    num = np.arange(new_board.shape[0])
    n0 = np.zeros_like((new_board),int)
    if len(num[np.max(new_board,axis=1) == 0]) != 0:
        x.append(np.array(new_board))
    for i in range(new_board.shape[0]):
        c = num[np.max(new_board,axis=1) == 0]
        if len(c) > 0:
            b = c[-1]
            new_board[i+1:b+1,:] = new_board[i:b,:]
            new_board[i] = n0 = np.zeros_like((new_board),int)[i]
            if list(np.arange(b+1)) == list(c):
                break
            else:
                x.append(np.array(new_board))
    return x

xxx040xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (2,3) (3,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 818, 'const': 338, 'code+const': 1156}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 11)]]
import numpy as np
def get_score(board):
    return sum(np.min(board,axis = 1) != 0)*40
def get_time_cap(board, time_caps):
    row = np.arange(board.shape[0])
    bound = board.shape[0]//len(time_caps)
    want = row[np.max(board,axis = 1) != 0]//bound
    if want.shape[0] != 0 : return time_caps[want[0]]
    else : return time_caps[-1]
def rotate_right(shape):
    return np.array(shape).T[::,::-1]
def rotate_left(shape):
    return np.array(shape).T[::-1,:]
def animate_drop(board, shape, c):
    copy_board = np.array(board)
    copy_shape = np.array(shape)
    out = []
    for i in range(copy_board.shape[0]) :
     if i < copy_shape.shape[0]-1 :
        ok_to_place = copy_board[:1+i,c:c+copy_shape.shape[1]]*copy_shape[copy_shape.shape[0]-1-i:]
        if np.sum( ok_to_place != 0 ) != 0 :
          out = []
          break
     ok_to_place = copy_board[i:i+copy_shape.shape[0],c:c+copy_shape.shape[1]]*copy_shape
     if np.sum( ok_to_place != 0 ) != 0 :
       break
     new_board = np.array(copy_board)
     new_board[i:i+copy_shape.shape[0],c:c+copy_shape.shape[1]] += copy_shape
     out.append(new_board)
    return out
def animate_clear(board):
    copy_board = np.array(board)
    copy_board[np.min(board,axis = 1) != 0] = 0
    if np.sum(copy_board) == np.sum(np.array(board)) : return [] 
    else :
        row = np.arange(board.shape[0])
        new_board = np.array(board)
        new_board[np.min(board,axis = 1) != 0] = 0
        out = [new_board]
        while True :
            position_0 = row[np.sum(copy_board,axis = 1) == 0][-1]
            if np.sum(copy_board[:position_0+1,:] != 0) == 0 : break 
            else :    
                copy_board[1:position_0+1,:] = copy_board[0:position_0,:]
                copy_board[0] = 0
                copy2_board = np.array(copy_board)
                out.append(copy2_board)
    return out

xxx120xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [0, 0, 0, 0],
       [1, 0, 2, 4]]),
  array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1770, 'const': 392, 'code+const': 2162}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 22)], [('While', 15)]]
import numpy as np
def get_score(board):
    a = board != 0
    b = np.sum(a,axis=1)
    return sum((b == int(board.shape[1]))) * 40
def get_time_cap(board, time_caps):
    n = int(board.shape[0] / len(time_caps))
    ntc = sorted(time_caps + (time_caps * (n-1)))
    a = board != 0
    b = np.sum(a,axis=1)
    c = b != 0
    ntc = np.array(ntc)
    if np.sum(c) == 0 :
        return time_caps[-1]
    return min(ntc[c])
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    ans = []
    done = False 
    new_board = np.array(board)
    new_shape = np.array(shape)
    i = 0
    K = new_shape.shape[1]
    if new_shape.shape[0] == 1 :
        a = new_board[0,c:new_shape.shape[1]+c:]
    else :
        a = new_board[0:new_shape.shape[0],c:new_shape.shape[1]+c:]
    b = new_shape == 0 
    C = a == 0 
    d = b | C
    e = np.ones_like(d,int)
    if np.sum(d) != np.sum(e) :
        return []
    add = True
    k = 0
    I = new_shape.shape[0]-1
    while True :
        if i < new_shape.shape[0] and not done :
            a = new_shape[I,:]
            a = a == 0
            b = new_board[0:new_shape.shape[0]-i,c:new_shape.shape[1]+c:]
            C = b == 0
            d = a|C
            e = np.ones_like(d,int)
            if np.sum(d) != np.sum(e) :
                return ans
            else :
                if I != 0 :
                    a = new_board[I-1,c:new_shape.shape[1]+c:]
                    b = np.sum(a)
                    C = new_shape[I,:]
                    d = b == 0
                    e = C == 0
                    f = d|e
                    g = np.ones_like(f,int)
                    if np.sum(g) != np.sum(f) :
                        return ans
                    else :
                        new_board[I,c:new_shape.shape[1]+c:] += new_shape[I,:]
                else :
                    new_board[I,c:new_shape.shape[1]+c:] += new_shape[I,:]
            i += 1
            I -= 1
        else :
            if add :
                ans.append(new_board)
                add = False
                j = i
                i -= 1 
                j -= 1
                done = True
                new_board = np.array(ans[-1])
            if k == 0 :
                if j+1 == new_board.shape[0] :
                    return ans
                j = i 
                a = new_board[j,c:new_shape.shape[1]+c:]
                b = new_board[j+1,c:new_shape.shape[1]+c:]
                d = a == 0
                e = b == 0
                f = d | e
                g = np.ones_like(d,int)
                new_board = np.array(ans[-1])
            if k != new_shape.shape[0] and np.sum(f) == np.sum(g) :
                new_board[j+1,c:new_shape.shape[1]+c:] += new_board[j,c:new_shape.shape[1]+c:]
                new_board[j,c:new_shape.shape[1]+c:] = 0 
                k += 1
                j -= 1
            elif k == new_shape.shape[0] and np.sum(f) == np.sum(g):
                new_board[j+1,c:new_shape.shape[1]+c:] = 0 
                ans.append(new_board)
                k = 0
                j = i
                i += 1
                j += 1
            elif np.sum(f) != np.sum(g) :
                return ans
def animate_clear(board):
    ans = []
    new_board = np.array(board)
    b = np.sum(new_board != 0, axis=1)
    c = b == new_board.shape[1]
    if np.sum(c) == 0 :
        return []
    new_board[c] = 0
    ans.append(new_board)
    i = 0
    I = 0
    k = 0
    new_board1 = np.array(ans[-1])
    while True :
        i = i%new_board.shape[0]
        if i == 0 and k == 0 and I != 0 :
            return ans
        if i == 0 and I > 0 :
            ans.append(new_board1)
            new_board1 = np.array(ans[-1])
            k = 0
        A = np.sum(new_board1[i,:])
        B = np.sum(new_board1[(i+1)%new_board.shape[0],:])
        if i == 0 and I > 0 :
            i += 1
            I += 1
        elif A != 0 and B == 0 and i != new_board.shape[0]-1:
            new_board1[i+1,:] = new_board1[i,:]
            new_board1[i,:] = 0
            i += 2
            I += 2
            k +=1
        else :
            i += 1
            I += 1

xxx019xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 888, 'const': 324, 'code+const': 1212}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('For', 20)]]
import numpy as np
def get_score(board):
  row = np.ndarray((board.shape[0]))
  n = board > 0
  sum_row = n.sum(axis = 1)
  a = sum_row == board.shape[1]
  c = len(row[a]) * 40
  return c
def get_time_cap(board, time_caps):
  n = board == 0
  n = n.sum(axis = 1)
  n = n == board.shape[1]
  m = n.sum()
  x = board.shape[0] // len(time_caps)
  n = n.sum()
  if n == board.shape[0]:
    return time_caps[-1]
  else:
    return time_caps[m//x]
def rotate_right(shape):
  a = shape.T
  return a[:,-1::-1]
def rotate_left(shape):
  a = shape.T
  return a[-1::-1,:]
def animate_drop(board, shape, c):
  z = []
  n_row = board.shape[0]
  n_col = board.shape[1]
  n_row_s = shape.shape[0]
  n_col_s = shape.shape[1]
  for i in range(n_row-n_row_s+1):
      new_board = np.array(board)
      new_shape = np.array(shape) 
      a1 = board[i:i+n_row_s,c:n_col_s+c]
      a2 = a1 == 0
      b2 = new_shape == 0
      x = b2 | a2
      if x.sum() == n_row_s * n_col_s:
          new_board[i:i+n_row_s,c:n_col_s+c] += shape
          z.append(new_board)
      else:
        break
  return z
def animate_clear(board):
  n_row = board.shape[0]
  r = np.arange(n_row)
  n_b = np.array(board)
  n_b_2 = np.array(board)
  min = board.min(axis = 1)
  full = min != 0
  full = full.reshape((full.shape[0],1))
  n_b_2 = board * full
  n_b = n_b - n_b_2
  z = []
  a = n_b != 0
  a = a.sum(axis = 1)
  a = a == 0
  a = a.sum()
  if a > 0:
      z.append(n_b)
      j = 0
      for i in range(n_row):
          k = n_row-i-1
          c = np.array(n_b)
          a = n_b[k+j].sum()
          if a == 0:
              c[1:k+j+1,:] = n_b[:k+j,:]
              c[0,:] -= n_b[0,:]
              x = abs(c - n_b)
              if x.sum() != 0:
                n_b = np.array(c)
                z.append(n_b)
                j += 1
      return z
  else:
      return z

xxx034xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 852, 'const': 352, 'code+const': 1204}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 4)], [('For', 11)]]
import numpy as np
def get_score(board):
    return board[np.min(board, axis=1)!=0,:].shape[0]*40
def get_time_cap(board, time_caps):
    max_r = np.max(board, axis=1); k = 0
    m = max_r[max_r==0].shape[0]+1
    n = board.shape[0]/len(time_caps)
    if m/n-int(m/n) == 0:
      k = int(m/n)-1
    else:
      k = int(m/n)
    if np.mean(max_r) == 0:
      k = -1
    return time_caps[k]
def rotate_right(shape):
    s = np.zeros_like(shape.T)
    s[:] = shape.T
    return s[:,::-1]
def rotate_left(shape):
    s = np.zeros_like(shape.T)
    s[:] = shape.T
    return s[::-1,:]
def animate_drop(board, shape, c):
    i=0
    drop = []
    while True:
      block = board[i:i+shape.shape[0],c:c+shape.shape[1]]
      if block.shape[0]<shape.shape[0]:
        break
      if np.mean(block[shape>0]) != 0:
        break
      else: 
        nb = np.array(board)
        nb[i:i+shape.shape[0],c:c+shape.shape[1]]+=shape
        drop.append(nb)
        i+=1
    return drop
def animate_clear(board):
    anic = []
    board[np.min(board,axis=1)!=0] = 0
    n = np.array(board)
    anic.append(board)
    find = np.sum(board,axis=1)
    find[find>0] = 3
    find = find[np.argmax(find):]
    if find[find==0].shape[0] == 0:
      return []
    for i in range(find[find==0].shape[0]):
      board[-1-np.argmin(np.sum(board,axis=1)[::-1])] = -1
      board = board[board!=-1].reshape((board.shape[0]-1, board.shape[1]))
      start = np.zeros((board.shape[0]+i+1, board.shape[1]))
      start[i+1:,:] = board
      anic.append(np.array(start,int))
    anic[0] = n
    return anic

xxx208xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1036, 'const': 338, 'code+const': 1374}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('For', 17)]]
import numpy as np
def get_score(board):
    A = np.arange(0,board.shape[0])
    B = np.sum(board>0, axis=1)
    C = B==board.shape[1]
    return len(B[C])*40
def get_time_cap(board, time_caps):
    A = np.sum(board,axis=1)
    if np.sum(A) == 0 :
        return time_caps[-1]
    B = np.arange(0,len(A))
    C = B[A>0]
    D = C[0]
    E = board.shape[0]//len(time_caps)
    return time_caps[D//E]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    A = board[:shape.shape[0]:,c:c+shape.shape[1]:]
    if np.sum(A[shape>0]==0) != len(A[shape>0]) :
        return []
    else:
        result = []
        for k in range(board.shape[0] - shape.shape[0] + 1):
            B = board[k:k+shape.shape[0]:, c:c + shape.shape[1]:]
            if np.sum(B[shape>0]==0) != len(B[shape>0]):
                return result
            else:
                new_board = np.array(board)
                new_board[k:k+shape.shape[0]:, c:c + shape.shape[1]:] = B + shape
                result.append(new_board)
        return result
def animate_clear(board):
    new_board = np.array(board)
    A = np.sum(board>0,axis=1)
    B = np.arange(len(A))
    C = B[A==board.shape[1]]
    new_board[C] = np.zeros([new_board[C].shape[0],new_board[C].shape[1]],int)
    if np.sum(new_board==board) == board.shape[0]*board.shape[1] :
        return []
    else:
        result = []
        result.append(np.array(new_board))
        nn_board = new_board[::-1,:]
        D = np.sum(nn_board,axis=1)
        E = np.arange(len(D))
        F = np.arange(len(E[D==0]))
        for i in E[D==0]-F :
            G = np.zeros([nn_board.shape[0]-i,nn_board.shape[1]],int)
            H = nn_board[i+1::,:]
            G[:H.shape[0]:,:] = H
            nn_board[i::,:] = G
            if np.sum(np.array(nn_board[::-1,:])==result[len(result)-1]) != nn_board.shape[0]*nn_board.shape[1] :
                result.append(np.array(nn_board[::-1,:]))
        return result

xxx020xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[456, 456, 456, 456, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 270, 'const': 240, 'code+const': 510}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
import numpy as np
def get_score(board):
    MIN = np.min(board, axis=1)
    c=np.sum(MIN != 0)*40
    return c
def get_time_cap(board, time_caps):
    MAX=np.max(board, axis=1)
    a=list((MAX != 0))
    x=len(board)//len(time_caps)
    if len(a) == 0 :
      return time_caps[-1]
    else:
      a=int(a[0])
      c=((a//x)+1) -1
      return time_caps[c]
def rotate_right(shape):
    d=shape.T
    return d[:,::-1]
def rotate_left(shape):
    d=shape.T
    return d[::-1,:]
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
    pass

xxx201xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 860, 'const': 338, 'code+const': 1198}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 10)], [('While', 19)]]
import numpy as np
def get_score(board):
    a = np.min(board,axis=1)
    b = a!=0 
    c = np.sum(b) 
    return c*40
def get_time_cap(board, time_caps):
    s = np.max(board,axis=1)
    s = s > 0
    c = np.arange(0,board.shape[0])
    d = c[s]
    if len(d) == 0 :
        return time_caps[-1]
    a = len(board)//len(time_caps)
    b = d[0]//a
    return time_caps[b]
def rotate_right(shape):
    a = shape.T
    b = a[:,::-1] 
    return b
def rotate_left(shape):
    a = shape.T
    b = a[::-1,:] 
    return b
def animate_drop(board, shape, c):
    sea = []
    row = 0
    pos = shape.shape[0]
    pos1 = shape.shape[1]
    b = board[row:row+pos,c:pos1+c]
    s = shape  != 0
    bs = b[s] == 0
    while np.sum(bs) == np.sum(s) :
        new_board = np.array(board)
        new_board[row:row+pos,c:pos1+c] += shape
        sea.append(new_board)
        row += 1
        if row == (board.shape[0]-pos+1) :
            break
        b = board[row:row+pos,c:pos1+c]
        bs = b[s] == 0
    return sea
def animate_clear(board):
    ice = []
    a = np.min(board,axis=1)
    d = a != 0 
    b = np.arange(0,board.shape[0])
    c = b[d]
    if len(c) == 0 :
        return []
    new_board = np.array(board)
    new_board[c,:] = 0    
    ice.append(new_board)
    aa = (np.max(new_board,axis=1))==0
    bb = b[aa]
    fb = (np.max(new_board,axis=1))!=0
    if np.sum(fb)==0:
         return ice
    fb = b[fb]
    while bb[-1] >= fb[0] :
        new_board1 = np.array(new_board)
        new_board1[1:bb[-1]+1,:] = new_board[0:bb[-1],:]
        new_board1[0,:] = 0
        ice.append(new_board1)
        new_board = new_board1
        aa = (np.max(new_board,axis=1))==0
        bb = b[aa]
        fb = (np.max(new_board,axis=1))!=0
        fb = b[fb]
    return ice

xxx026xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 876, 'const': 384, 'code+const': 1260}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 11)], [('For', 18)]]
import numpy as np
def get_score(board):
    minboard = board.min(axis=1)
    boo = minboard > 0
    return np.sum(boo)*40
def get_time_cap(board, time_caps):
    boo = board > 0
    maxboard = boo.reshape(len(time_caps), boo.shape[0]*boo.shape[1]//len(time_caps)).max(axis=1)
    arTC = np.array(time_caps)
    re = arTC[maxboard]
    if len(re) > 0:
        return re[0]
    return time_caps[-1]
def rotate_right(shape):
    return shape.T[:, ::-1]
def rotate_left(shape):
    return shape.T[::-1, :]
def animate_drop(board, shape, c):
    maxboard = board[:, c:c+shape.shape[1]]
    boo = maxboard > 0
    boo2 = boo.max(axis=1)
    boo3 = boo[boo2]
    end = shape[-1,boo3[0]].max(axis=0) if len(boo3) > 0 else 0
    j = 0
    k = 0
    new_board = list()
    for i in boo2:
        if i and k < shape.shape[0]-1:
            break
        i = not i
        if end == -1:
            break
        if not i and end == 0:
            i = not i
            end = -1
        if not i:
            break
        if k >= shape.shape[0]-1:
            copy_board = np.array(board)
            copy_board[j:j+shape.shape[0], c:c+shape.shape[1]] += shape
            new_board.append(copy_board)
            j += 1
        k += 1
    return new_board
def animate_clear(board):
    minboard = board.min(axis=1)
    boo = minboard > 0
    new_board = np.array(board)
    new_board[boo, :] = 0
    if str(new_board) == str(board):
        return []
    maxboard = new_board.max(axis=1)
    boo = maxboard > 0  
    s = np.arange(0, board.shape[0])
    first = s[boo][0]
    ns = s[first:][~boo[first:]]
    clear_board = list()
    clear_board.append(np.array(new_board))
    row_zero = np.zeros_like(board.shape[1], int)
    i = 0
    for n in ns[::-1]:
        n += i
        new_board[1:n+1, :] = np.array(new_board[:n, :])
        new_board[0, :] = np.array(row_zero)
        clear_board.append(np.array(new_board))
        i += 1
    return clear_board

xxx016xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score0.0
[5800, 79120]
test_get_time_cap0.0
[None56, None56, None56, None56, None45, None45, None45]
test_rotate_right0.0
[array([[40, 01],
       [30, 52],
       [25, 03],
       [10, 04]]),
 array([[01, 40],
       [52, 30],
       [03, 25],
       [04, 10]])]
test_rotate_left0.0
[array([[04, 10],
       [03, 25],
       [52, 30],
       [01, 40]]),
 array([[10, 04],
       [25, 03],
       [30, 52],
       [40, 01]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 196, 'const': 108, 'code+const': 304}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [('rot90', 2)], [('rot90', 2)], [], []]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[('For', 3), ('For', 4)], [], [], [], [], []]
import numpy as np
def get_score(board):
    point = 0
    for i in range(len(board)):
        for j in range(len(board[i])):
            if board[i][j]==0:
                pass
            else:
              point += board[i][j]
    return 40*point
def get_time_cap(board, time_caps):
    pass
def rotate_right(shape):
    return np.rot90(shape)
def rotate_left(shape):
    return np.rot90(shape,3)
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
    pass

xxx204xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (4,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (6,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (3,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[]]
bytecount: {'code': 710, 'const': 338, 'code+const': 1048}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 3)], [('While', 16)]]
import numpy as np
def get_score(board):
  a = np.sum(board==0,axis=1)
  c = len(a[a==0])
  return c*40
def get_time_cap(board, time_caps):
  summ = np.sum(board,axis=1)
  notzero = len(summ[summ==0])
  if notzero == len(board):
    return time_caps[-1]
  else:
    n = len(board)//len(time_caps)
    d = notzero//n
    return time_caps[d]
def rotate_right(shape):
  return shape[::-1].T
def rotate_left(shape):
  return shape[::,::-1].T
def animate_drop(board, shape, c):
  list_board = []
  for i in range(len(board)):
    if np.sum(board[i,c:])==0:
      new_board = np.array(board)
      new_board[i,c:] = shape
      list_board.append(new_board)
  return list_board
def animate_clear(board):
  ans = [] ; board1 = np.array(board)
  col = board1.shape[1] ; summ = np.sum(board1!=0,axis=1)
  test = list(summ[::]==col) ; board1[test] = np.zeros_like(board[0],int)
  if 0 not in list(np.sum(board1,axis=1)):
    return []
  else:
    ans.append(board1)
    bboard = np.array(board1) 
    no = np.sum(bboard,axis=1) 
    listz = list(no) 
    firstnotz = no[no!=0][0]
    notz = listz.index(firstnotz) 
    index = listz.copy() 
    i = 1 
    while True:
        if 0 in index:
          n = index.index(0)
          notz = index.index(firstnotz) 
          if n > notz:
            bboard[n] = bboard[n-1] 
            bboard[n-1] = np.zeros_like(board[0],int) 
            index[n] = 1
            if i%2==0:
              index = list(np.sum(bboard,axis=1))
              anss = np.array(bboard)
              ans.append(anss)
            i+=1
          else:
            index[n]=22
        else:
            ans.append(bboard)
            break
    return ans

xxx021xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 862, 'const': 324, 'code+const': 1186}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 11)], [('While', 10)]]
import numpy as np
def get_score(board):
    board = np.array(board)
    min_array = np.min(board,axis=1)
    num = sum(min_array != 0)
    ans = num * 40
    return ans
def get_time_cap(board, time_caps):
    board = np.array(board)
    max_arrray = np.max(board,axis = 1)
    postion = np.arange(max_arrray.shape[0])
    non_zero = postion[max_arrray != 0]
    if non_zero.shape[0] != 0:
        ans = time_caps[non_zero[0]//(board.shape[0]//len(time_caps))]
    else:
        ans = time_caps[-1]
    return ans
def rotate_right(shape):
    shape = np.array(shape)
    shape2 = shape[::-1]
    return shape2.T
def rotate_left(shape):
    shape1 = rotate_right(shape)
    shape2 = rotate_right(shape1)
    left_shape = rotate_right(shape2)
    return left_shape
def animate_drop(board, shape, c):
    new_board = np.array(board)
    shape = np.array(shape)
    new_shape = np.zeros_like(new_board[0:shape.shape[0],:])
    new_shape[:,c:c+shape.shape[1]] += shape
    c_max = new_board.shape[1] - shape.shape[1]
    if c > c_max :
        return []
    ans = []
    for row in range(new_board.shape[0] - new_shape.shape[0]+1):
        check_board = np.array(board)
        check_array =check_board[ row : row+new_shape.shape[0] ]
        check_array += new_shape
        check_same = check_array[check_array == new_shape]
        if np.sum(new_shape) != np.sum(check_same):
            if row == 0:
                return []
            else:
                break
        else:
            ans.append(check_board)
    return ans
def animate_clear(board):
    ans = []
    new_board = np.array(board)
    zero_board = np.zeros_like(new_board)
    check = np.sum(new_board == zero_board,axis = 1)
    check = (check == 0)
    new_board[check] = 0
    ans.append(new_board)
    while True:
        check_sum = np.sum(new_board,axis = 1)
        check_sum = (check_sum == 0)
        pos = np.arange(check_sum.shape[0])
        ans_board = np.zeros_like(new_board)
        if pos[check_sum].shape[0] != 0:
            B_row = pos[check_sum][-1]
            B = new_board[B_row]
            A = new_board[:B_row]
            C = new_board[B_row+1:]
            ans_board[0] = B
            ans_board[1:B_row+1] = A
            ans_board[B_row+1:] = C
            ans.append(ans_board)
            if np.sum(ans_board == new_board) != np.sum(np.ones_like(new_board)):
                new_board = ans_board
            else:
                break
        else:
            break
    return ans[:-1]

xxx002xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [0, 0, 0, 0],
       [1, 0, 2, 4]]),
  array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [1, 0, 5, 4],
       [1, 0, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 738, 'const': 338, 'code+const': 1076}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 7)], [('While', 10)]]
import numpy as np
def get_score(board):
    board2 = np.array(board)
    return len(board2[np.min(board2, axis=1) != 0])*40
def get_time_cap(board, time_caps):
    board2 = np.array(board)
    mask = np.sum(board2, axis=1)==0
    board2 = board2[mask, :]
    u = (len(board2)//(len(board)//len(time_caps)))//1
    if u<len(time_caps):
        return time_caps[u]
    return time_caps[-1]
def rotate_right(shape):
    sT = np.array(shape)
    sT = sT.T
    return sT[:,::-1]
def rotate_left(shape):
    sT = np.array(shape)
    sT = sT.T
    return sT[::-1,:]
def animate_drop(board, shape, c):
    ani = list()
    i = 0
    lr, lc = board.shape
    row, col = shape.shape
    while True:
        copy = np.array(board)
        newcopy = copy[i:i+row, c:c+col]
        if np.sum(newcopy)!=0 and i==0:
          return ani
        newcopy += shape
        bsh = newcopy[shape!=0]
        ssh = shape[shape!=0]
        if np.min(bsh==ssh) == 1:
            ani.append(copy)
        else:
            break
        if i+row>lr-1:
            break
        i += 1
    return ani
def animate_clear(board):
    ani = list()
    lr, lc = board.shape
    if np.max(np.sum(board==0,axis=1)==0) == 0:
        return []
    copy = np.array(board)
    copy[np.min(board,axis=1)!=0] = 0
    ani.append(np.array(copy))
    while True:
        index = np.arange(lr)
        index = index[(np.max(copy,axis=1)==0) & (index>=1)]
        a = [np.array(copy[index]), np.array(copy[index-1])]
        copy[index-1], copy[index] = a
        if np.max(copy != ani[-1]) == 1:
            ani.append(np.array(copy))
            continue
        break
    return ani

xxx035xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (2,3) (3,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[0 0 0 0]
 [0 0 0 0]
 [0 0 0 0]
 [0 0 0 0]]
[]
[0 1 2 3]
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[1 2 0 0]
 [0 0 0 0]
 [1 0 2 4]
 [0 0 0 0]
 [0 0 0 0]
 [0 0 1 1]]
[0 2 5]
[1 3 4]
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  Nonearray([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 928, 'const': 354, 'code+const': 1282}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 11)], [('While', 22)]]
import numpy as np
def get_score(board):
    row,col=board.shape[:]
    x=np.min(board, axis=1)
    b= x!=0
    return sum(b)*40
def get_time_cap(board, time_caps):
    row=board.shape[0]
    tc=len(time_caps)
    a=int(row/tc)
    x=np.sum(board,axis=1)
    x= x!= 0
    id=np.arange(1,row+1)
    if len(id[x]) == 0:
        return time_caps[-1]
    else: 
     idx= (id[x][0]-0.1)//a
    return time_caps[int(idx)]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    ans =[]
    new_board = np.array(board)
    i=0
    board_space=new_board[i:i+shape.shape[0],c:c+shape.shape[1]]
    bool_shape= (shape == 0) 
    bool_board_space= (board_space == 0) 
    okcheck = bool_board_space | bool_shape
    while (np.sum(okcheck)==shape.shape[0]*shape.shape[1]) & (i<= shape.shape[0]):
        new_board = np.array(board)
        x=new_board[i:i+shape.shape[0],c:c+shape.shape[1]]|shape
        new_board[i:i+shape.shape[0],c:c+shape.shape[1]]=x
        ans+=[new_board]
        i+=1
        new_board = np.array(board)
        board_space=new_board[i:i+shape.shape[0],c:c+shape.shape[1]]
        bool_board_space= (board_space == 0)
        okcheck = bool_board_space | bool_shape
    return ans
def animate_clear(board):
    ans=[]
    new_board=np.array(board)
    bool_new=np.sum((board>0),axis=1)
    id=np.arange(board.shape[0])
    id2=id[(np.sum((board!=0),axis=1)==board.shape[1])]
    if board.shape[1] not in bool_new:return []
    else:
        new_board[id2,:]=np.zeros((1,board.shape[1]))
        print(new_board)
    notzerorol=id[(np.sum(new_board,axis=1)!=0)]
    zerorol=id[(np.sum(new_board,axis=1)==0)]
    print(notzerorol)
    print(zerorol)
    while np.sum(notzerorol) != np.sum(np.arange(notzerorol[0],notzerorol[-1]+1)):
        if notzerorol[-1]>zerorol[-1]:
            id=np.arange(notzerorol[-1]-len(notzerorol)+1,notzerorol[-1]+1)
            return
        else:
         return

xxx031xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 690, 'const': 310, 'code+const': 1000}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 9)], [('While', 12)]]
import numpy as np
def get_score(board):
    row_have_zero = (np.min(board, axis=1) == 0)
    sum_row = np.sum(board, axis=1)
    row_without_zero = sum_row[~row_have_zero]
    return row_without_zero.shape[0]*40
def get_time_cap(board, time_caps):
    sum_row = np.sum(board,axis=1)
    period = board.shape[0]/len(time_caps)
    count_zero_row = board[sum_row==0,:].shape[0]
    index = int(count_zero_row//period) 
    if index == len(time_caps) :
      return time_caps[index-1]
    else :
      return time_caps[index]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    new_shape = np.array(shape)
    start_sum = np.sum(board)
    start_shape = np.sum(shape)
    ch=1
    po = 0
    ans = []
    while(ch) :
      new_board = np.array(board)
      if po+shape.shape[0] >= board.shape[0] : break 
      new_board[po:po+shape.shape[0], c:c+shape.shape[1]] = shape
      if np.sum(new_board) != start_sum+start_shape : break
      ans.append(new_board)
      po+=1
    return ans
def animate_clear(board):
    new_board = np.array(board)
    ans = []
    zero_row = np.min(new_board, axis=1)!=0
    if(np.sum(zero_row)==0): return []
    new_board[zero_row] = np.array([0])
    ans.append(np.array(new_board))
    top = 0
    now = board.shape[0]-1
    while(now>top):
      if np.sum(new_board[now,:]) == 0 :
        new_board[1:now+1,:] = new_board[0:now]
        new_board[0,:] = np.array([0])
        top+=1
        ans.append(np.array(new_board))
      else :
        now-=1
    return ans

xxx040xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1102, 'const': 370, 'code+const': 1472}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('For', 22)]]
import numpy as np
def get_score(board):
    check_board=np.min(board,axis=1)
    final_board=check_board[check_board!=0]
    return int(final_board.shape[0]*40)
def get_time_cap(board, time_caps):
    length_time_caps=len(time_caps)
    row=board.shape[0]
    in_row=int(row/length_time_caps)
    check_board=np.max(board,axis=1)
    pos=np.arange(0,len(check_board))
    check_pos_Nonzero=pos[check_board>0]
    if check_pos_Nonzero.shape[0]==0:
        return time_caps[len(time_caps)-1]
    else:
        return time_caps[(check_pos_Nonzero[0]//in_row)]
def rotate_right(shape):
    return np.array(shape).T[:,::-1]
def rotate_left(shape):
    return np.array(shape).T[::-1,:]
def animate_drop(board, shape, c):
    nb = np.array(board)
    ns = np.array(shape)
    copy_ns=np.array(ns)
    row,col=ns.shape
    ans=list()
    for i in range(nb.shape[0]*row):
        if i+row>nb.shape[0]: 
            break
        loop_board=np.array(nb)
        check_board=loop_board[i:i+row,c:c+col]
        sum_check_board=np.sum(check_board)
        if sum_check_board==0:
            loop_board[i:i+row,c:c+col] = ns
            ans.append(loop_board)
        else:
            testshape=np.array(ns)
            testshape=testshape[::-1,:]
            max_shape_col = np.argmax(testshape, axis=0)
            testrow = ns.shape[0] - 1
            max_shape_col=testrow-max_shape_col
            pos_shape=np.arange(ns.shape[0]).reshape(1,ns.shape[0]).T
            solution=pos_shape-max_shape_col
            condition=(solution<=0)&(ns==0)
            ns[condition]=1
            if np.sum(ns*check_board)==0:
                loop_board[i:i + row, c:c + col] += copy_ns
                ans.append(loop_board)
            else:
                break
    return ans
def animate_clear(board):
    nb=np.array(board)
    check=np.min(nb,axis=1)!=0
    ans=[]
    if np.max(check)==0:
        return []
    else:
        testnb=np.array(nb)
        testnb[check]=0
        check_bc=np.arange(nb.shape[0])
        check_bc_0=check_bc[np.max(testnb,axis=1)==0]
        check_bc_non0=check_bc[np.max(testnb,axis=1)!=0]
        if len(check_bc_non0)==0:
            ans.append(testnb)
            return ans
        zeroB=len(check_bc_0[check_bc_0<check_bc_non0[0]])
        copy_test=np.array(testnb)
        ans.append(np.array(testnb))
        check_loop=np.arange(copy_test.shape[0])
        check_loop=len(check_loop[np.max(copy_test,axis=1)==0])
        check_loop-=zeroB
        for i in range(check_loop):
            pos = np.arange(testnb.shape[0])
            pos = pos[np.max(testnb, axis=1) == 0][-1]
            testnb[1:pos + 1, :] = testnb[:pos, :]
            testnb[0, :] = 0
            ans.append(np.array(testnb))
        return ans

xxx022xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 256, 'const': 190, 'code+const': 446}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
import numpy as np
def get_score(board):
    a=board==0
    x=list(np.sum(a,1))
    y=x.count(0)
    return y*40
def get_time_cap(board, time_caps):
    x=len(board)/len(time_caps)
    i=np.sum(board,1)
    a=i!=0
    if True not in list(a):
        return time_caps[-1]
    else:
        dex=list(a).index(True)
        return time_caps[int(dex//x)]
def rotate_right(shape):
    x = shape[::-1]
    y=x.T
    return y
def rotate_left(shape):
    x=shape.T
    y=x[::-1]
    return y
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
    pass

xxx027xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 816, 'const': 338, 'code+const': 1154}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('While', 5)]]
import numpy as np
def get_score(board):
    row = board.min(axis=1)
    row = row != 0
    row = row.sum()
    score = row * 40
    return score
def get_time_cap(board, time_caps):
    if board.sum() == 0:
        return time_caps[-1]
    pos = board.max(axis=1)
    pos = pos != 0
    pos = pos.argmax()
    len_b = len(board)
    len_t = len(time_caps)
    c = len_b//len_t
    index = pos//c
    time = time_caps[index]
    return time
def rotate_right(shape):
    tran = shape.T
    rev = tran[:, ::-1]
    return rev
def rotate_left(shape):
    tran = shape.T
    rev = tran[::-1,:]
    return rev
def animate_drop(board, shape, c):
    animates = []
    shape_sum = shape.sum()
    for i in range(1-shape.shape[0],len(board)-len(shape)+1):
        new_board = np.array(board)
        new_shape = np.array(shape)
        if i >= 0:
            slc = new_board[i:i+shape.shape[0],c:c+shape.shape[1]]
            slc_sum = slc.sum()
            slc[shape != 0] = shape[shape != 0]
            if slc_sum + shape_sum == slc.sum():
                animates.append(new_board)
            else:
                return animates
        else:
            slc = new_board[0:shape.shape[0]+i,c:c+shape.shape[1]]
            slc_sum = slc.sum()
            slc_shape = new_shape[-i:,:]
            slc_shape_sum = slc_shape.sum()
            slc[slc_shape != 0] = slc_shape[slc_shape != 0]
            if slc.sum() != slc_sum + slc_shape_sum:
                break
    return animates
def animate_clear(board):
    animates = []
    new_board = np.array(board)
    while True:
        new_board = np.array(new_board)
        before = np.array(new_board)
        row = new_board.min(axis=1)
        row = row != 0
        if row.sum() != 0:
            new_board[row] = 0
        else:
            m = new_board.max(axis=1)
            m = m[::-1]
            mi = len(board) - m.argmin() - 1
            if (m == 0).sum() == 0:
                return animates
            slc = new_board[:mi,:]
            new_board[1:mi+1,:] = slc
            new_board[0,:] = 0
        if (before == new_board).min() != 0:
            return animates
        animates.append(new_board)

xxx030xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (1,3)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (1,3)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0IndexError('index 2 is out of bounds for axis 0 with size 2')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 860, 'const': 498, 'code+const': 1358}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 6)], [('While', 7)]]
import numpy as np
def get_score(board):
    nrow, ncol = board.shape
    non_zero = board > 0
    sum_non_zero = np.sum(non_zero, axis=1)
    fsum = sum_non_zero[sum_non_zero == ncol]
    score = len(fsum)*40
    return score
def get_time_cap(board, time_caps):
    if np.sum(board) == 0:
        return time_caps[-1]
    idxs = np.arange(board.shape[0])
    b = np.sum(board, axis=1)
    pidxs = idxs[b > 0]
    rlen = len(board)//len(time_caps)
    fidxs = pidxs[0]
    tidx = fidxs//rlen
    return time_caps[tidx]
def rotate_right(shape):
    s = shape.T
    rs = s[:, ::-1]
    return rs
def rotate_left(shape):
    s = shape.T
    rs = s[::-1, :]
    return rs
def animate_drop(board, shape, c):
    shw = len(shape[0])
    i = 0
    rs = []
    while True:
        if np.sum(board[i, c:shw+c]) != 0:
            break
        new_board = np.array(board)
        new_board[i:i+1, c:shw+c] = shape
        i += 1
        rs.append(new_board)
    return rs
def clear_full_rows(new_board):
    non_zero = new_board > 0
    non = np.sum(non_zero, axis=1)
    nrow, ncol = new_board.shape
    idxs = np.arange(nrow)
    frowidxs = idxs[non == ncol]
    new_board[frowidxs, :] = 0
    return new_board
def find_emptyrow_idxs(new_board):
    rsums = np.sum(new_board, axis=1)
    nrow, ncol = new_board.shape
    idxs = np.arange(nrow)
    idx0 = idxs[rsums == 0]
    return idx0
def can_move_empty_rows(new_board):
    idx0 = find_emptyrow_idxs(new_board)
    n = len(idx0)
    if n == 0:
        return False
    oidxs = np.arange(n)
    bools = oidxs == idx0
    return np.sum(bools) != n
def move_row_to_top(new_board, ridx):
    nrows, ncols = new_board.shape
    idxlist = list(range(nrows))
    idxlist.remove(ridx)
    idxlist.insert(0, ridx)
    return new_board[idxlist, :]
def move_last_empty_row_to_top(new_board):
    eidxs = find_emptyrow_idxs(new_board)
    ridx = eidxs[-1]
    new_board = move_row_to_top(new_board, ridx)
    return new_board
def animate_clear(board):
    new_board = np.array(board)
    new_board = clear_full_rows(new_board)
    rs = [new_board]
    change = False
    while can_move_empty_rows(new_board) == True:
        change = True
        new_board = move_last_empty_row_to_top(new_board)
        rs.append(new_board)
        new_board = np.array(new_board)
    if change == False:
        return []
    else:
        return rs

xxx030xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[56, 56, 56, 56, 45, 45, 56, 456]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (3,3) (2,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1000, 'const': 340, 'code+const': 1340}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 13)], [('While', 14)]]
import numpy as np
def get_score(board):
    r = board.shape[0]
    c = board.shape[1]
    zero = np.zeros((r,c), int)
    x = np.sum((board == zero), axis=1)
    result = np.sum(x==0) * 40
    return result
def get_time_cap(board, time_caps):
    r = board.shape[0]
    c = board.shape[1]
    ratio = r//len(time_caps)
    zero = np.zeros((r,c), int)
    x = np.sum((board == zero), axis=1)
    x[x != c] = 0
    x = list(x)
    if 0 in x:
        p = x.index(0)
    else:
        return time_caps[-1]
    if p%2 == 0:
        p += 2
    else:
        p += 1
    p //= ratio
    return time_caps[p-1]
def rotate_right(shape):
    result = shape.T[:, ::-1]
    return result
def rotate_left(shape):
    result = shape.T
    result = result[::-1]
    return result
def animate_drop(board, shape, c):
    new_board = np.array(board)
    x,y = shape.shape
    place = board[:x, c:c+y]
    result = []
    tester = shape + place == shape
    if np.sum(shape*tester == shape) == x*y:
        new_board[:x, c:c+y] += shape
        a = np.array(new_board)
        result.append(a)
        k=1
        while True:
            new_board[k-1:x+k-1, c:c+y] -= shape
            place = new_board[k:x+k, c:c+y]
            tester = shape + place == shape
            if np.sum(shape*tester == shape) == x*y:
                pass
            else:
                break
            new_board[k:x+k, c:c+y] += shape
            a = np.array(new_board)
            result.append(a)
            k += 1
    else:
        return []
    return result
def animate_clear(board):
    new_board = np.array(board)
    r,c = board.shape
    zero = np.zeros((r,c), int)
    x = np.sum((board == zero), axis=1)
    new_board[x == 0] = 0
    a = np.array(new_board)
    result = [a]
    reverse_board = new_board[::-1]
    row = 0
    if 0 not in x:
        return []
    while row < r:
        new_reverse_board = np.array(reverse_board)
        if np.sum(reverse_board[row]) == 0:
            new_reverse_board[0:row] = reverse_board[0:row]
            new_reverse_board[row:-1] = reverse_board[row+1:]
            new_reverse_board[-1] = reverse_board[row]
            a = np.array(new_reverse_board)[::-1]
            result.append(a)
        else:
            row += 1
        if np.sum(reverse_board[row:]) == 0:
            break
        reverse_board = np.array(new_reverse_board)
    return  result

xxx219xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 740, 'const': 356, 'code+const': 1096}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('any', 7)], [('any', 11)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 10)]]
import numpy as np
def get_score(board):   
    x = board.min(axis=1)
    ans = x[x>0].shape[0]*40
    return ans
def get_time_cap(board, time_caps):
    x = board.max(axis=1)
    n = x[x==0].shape[0]
    z = board.shape[0]//len(time_caps)
    if n!= board.shape[0]:
        n += 1
    n /= z
    if int(n) != n:
        n += 1
    return time_caps[int(n-1)]
def rotate_right(shape):
    ns=np.array(shape)
    nk=ns[::-1].T
    return nk
def rotate_left(shape):
    ns = np.array(shape)
    nk = ns.T[::-1]
    return nk
def animate_drop(board, shape, c):
    l = []
    for i in range(shape.shape[0],board.shape[0]+1):
        nb = np.array(board)
        ns = np.array(shape)
        if not any(((board[i-shape.shape[0]:i , c:c+shape.shape[1]] != 0) & (shape != 0)).any(axis=1)):
            nb[i-shape.shape[0]:i,c:c+shape.shape[1]] += ns
            l.append(np.array(nb))
        else:
            break
    return l
def animate_clear(board):
    l = []
    nb = np.array(board)
    x = board.min(axis=1)
    if x[x>0].shape[0] != 0:
        nb[(nb.min(axis=1))!=0] = np.zeros(nb.shape[1],int)
        l.append(nb)
    i = nb.shape[0]-1
    while i>-1:
        if all(nb[i] == 0) and any((nb[:i]!=0).any(axis=1)):
            nbb = np.zeros(nb.shape,int)
            nbb[i:] = nb[i:]
            nbb[1:i+1] = nb[:i]
            l.append(np.array(nbb))
            nb = nbb
        else:
            i -= 1
    return l

xxx209xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
operands could not be broadcast together with shapes (2,3) (3,3)
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 798, 'const': 366, 'code+const': 1164}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 6)], [('While', 9)]]
import numpy as np
def get_score(board):
    new_board = np.array(board)
    value_isnot_0 = new_board != 0
    row_all_not_0 = np.min(value_isnot_0, axis=1)
    return np.sum(row_all_not_0)*40
def get_time_cap(board, time_caps):
    new_board = np.array(board)
    new_board = new_board.reshape(len(time_caps),-1,new_board.shape[1])
    new_board = np.sum(new_board, axis=1)
    new_board = np.sum(new_board, axis=1)
    have_non0 = new_board != 0
    have_non0 = list(have_non0)
    try:
        return time_caps[have_non0.index(True)]
    except:
        return time_caps[-1]
def rotate_right(shape):
    new_shape = np.array(shape)
    return new_shape.T[:, ::-1]
def rotate_left(shape):
    new_shape = np.array(shape)
    return new_shape[:, ::-1].T
def animate_drop(board, shape, c):
    if any(board[0:shape.shape[0], c:c+shape.shape[1]].reshape(-1)):
      return []
    r = 0
    frames = []
    while True:
        new_board = np.array(board)
        try:
            new_board_shape = new_board[r:r+shape.shape[0], c:c+shape.shape[1]] + shape
            shape_mask = shape!=0
            if np.min(new_board_shape[shape_mask]==shape[shape_mask]) == 1:
                new_board[r:r+shape.shape[0], c:c+shape.shape[1]] = new_board_shape
                frames.append(new_board)
            else:
                return frames
        except IndexError:
            return frames
        except Exception as e:
            print(e)
            return frames
        r += 1
def animate_clear(board):
    new_board = np.array(board)
    frames = []
    non_zeros = np.min(new_board, axis=1) != 0
    if not np.max(non_zeros):
        return frames
    new_board[non_zeros] = 0
    frames += [new_board]
    while True:
        new_board = np.array(new_board)
        new_board_rev = new_board[::-1]
        row_sum = np.sum(new_board_rev, axis=1)
        move_index = new_board.shape[0]-np.argmin(row_sum)
        upper_index = move_index-1
        new_board[1:move_index] = new_board[:upper_index]
        new_board[0] = 0
        if np.min(frames[-1] == new_board):
            return frames
        frames.append(new_board)

xxx036xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1166, 'const': 380, 'code+const': 1546}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 15)]]
import numpy as np
def get_score(board):
    return list(np.sum(board == 0,axis =1)).count(0)*40
def get_time_cap(board, time_caps):
    check_zero = np.sum(board, axis = 1)
    if np.sum(check_zero) == 0:
        return time_caps[-1]
    check_zero_TF = check_zero == 0
    sec_pos = list(check_zero_TF).index(False)//int(len(board)/len(time_caps))
    return time_caps[sec_pos]
def rotate_right(shape):
    temp = shape[::-1]
    rotated = temp.T
    return rotated
def rotate_left(shape):
    rotated = rotate_right(rotate_right(rotate_right(shape)))
    return rotated
def animate_drop(board, shape, c):
    drop = []
    h,w = shape.shape
    board1 = np.array(board)
    animate = np.array(board)
    temp = np.array(np.zeros_like(board))
    for i in range(len(board1)-h+1):
        temp[i:i+h,c:w+c] = shape[:,:]
        tf_shape = shape[:,:] == 0
        tf_board = board1[i:i+h,c:w+c] == 0
        tf_merge = tf_shape+tf_board == False
        can_place = np.sum(np.sum(tf_merge,axis =1))
        if np.sum(board1[i:i+h,c:w+c] + shape[:,:]) == np.sum(temp[i:i+h,c:]):
            board1[i:i+h,c:w+c] = shape[:,:]
            drop.append(board1)
            board1 = np.array(animate)
            temp = np.array(np.zeros_like(board))
        elif can_place == 0:
            merge = board1[i:i+h,c:w+c] + shape[:,:]
            temp_b = np.array(board1)
            temp_b[i:i+h,c:w+c] = merge
            drop.append(temp_b)    
        else:
            break
    return drop
def animate_clear(board):
    animate = []
    h,w = board.shape
    board1 = np.array(board)
    board2 = board1 == 0
    check = np.sum(board2,axis = 1)
    if 0 not in list(check):
        return animate
    check = check == 0
    board1[check] = np.array(np.zeros((1,w),))        
    animate.append(board1)
    reverse = np.array(board1[::-1])
    temp_reverse = np.array(board1[::-1])
    i = 0
    while i < len(board1):
        if np.sum(reverse[i]) == 0 and np.sum(reverse[i+1:]) != 0:
            zero = np.array(np.zeros_like(board1))
            temp_reverse1 = temp_reverse != np.zeros((1,w),)
            zero_arr = np.sum(temp_reverse1,axis = 1)
            position = list(zero_arr).index(0)
            slice1 = temp_reverse[0:position]
            slice2 = temp_reverse[position+1:]
            h1,w1 = slice1.shape
            h2,w2 = slice2.shape
            zero[0:h1,0:w1] = slice1
            zero[h1:h-1,0:w2] = slice2
            animate.append(zero[::-1])
            temp_reverse = np.array(zero)
            reverse = np.array(zero)
        else:
            i+=1
    return animate

xxx219xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[array([[2, 2, 2, 0],
       [1, 0, 1, 1]])], [array([[0, 2, 2, 2],
       [1, 02, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 05, 05, 0, 0, 0],
       [0, 2, 2, 2, 05, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 02, 0, 0, 0],
       [0, 0, 02, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 02, 0, 8, 0],
       [1, 1, 02, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 02, 8, 8, 0],
       [1, 1, 02, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 2, 2, 2, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 2, 2, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [array([[0, 0, 2, 2, 2, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0,  ... (more)
test_animate_drop_30.0IndexError('index 2 is out of bounds for axis 0 with size 2')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 558, 'const': 278, 'code+const': 836}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[('tolist', 4)], [('where', 5)], [], [], [], []]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 12)], []]
import numpy as np
def get_score(board):
    tmp_board = board
    ans = np.min(tmp_board, axis = 1)
    lis = ans.tolist()
    ans1 = len(ans) - lis.count(0)
    return ans1*40
def get_time_cap(board, time_caps):
    tmp_board = board
    tmp_time_caps = time_caps
    count = np.max(tmp_board, axis = 1)
    ans = np.where(count > 0)
    if len(ans[0]) == 0:
        row = 0
    else :
        row = int(ans[0][0])+1
    tmp = len(tmp_board) / len(tmp_time_caps)
    tmp1 = row/tmp
    if round(tmp1) < tmp1:
        haha = round(tmp1)+1
    else :
        haha = round(tmp1)
    ans2 = tmp_time_caps[haha-1]
    return ans2
def rotate_right(shape):
    tmp_shape = shape
    n = rotate_left(tmp_shape)
    oe = rotate_left(n)
    ts = rotate_left(oe)
    return ts
def rotate_left(shape):
    tmp_shape = shape
    return tmp_shape.T[::-1]
def animate_drop(board, shape, c):
    tmp_board = board
    tmp_shape = np.copy(shape)
    tmp_c = c
    okeyletgo = []
    box = tmp_board[...,c:len(tmp_shape[0])+c]
    ans = np.max(box, axis = 1)
    i = 0
    A = np.copy(tmp_board)
    gg = np.copy(tmp_board)
    while ans[i] == 0:
        A[i, c:len(tmp_shape[0])+c] = tmp_shape[0]
        k = np.copy(A)
        okeyletgo.append(k)
        A[i, c:len(tmp_shape[0])+c] = gg[i, c:len(tmp_shape[0])+c]
        i+=1
    return okeyletgo
def animate_clear(board):
    pass

xxx033xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 784, 'const': 326, 'code+const': 1110}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 10)], [('While', 11)]]
import numpy as np
def get_score(board):
    b = board
    u = np.min(board, axis=1)
    u = u[u > 0]
    return len(u)*40
def get_time_cap(board, time_caps):
    b = board
    t = time_caps
    time = len(b)//len(t)
    u = np.sum(b, axis=1)
    u = u[u == 0]
    idx = len(u)//time
    if idx < len(t):
        return t[idx]
    else:
        return t[len(t)-1]
def rotate_right(shape):
    s = shape
    s = s.T
    s = s[:, ::-1]
    return s
def rotate_left(shape):
    s = shape
    s = s.T
    s = s[::-1, :]
    return s
def animate_drop(board, shape, c):
    b = np.array(board)
    s = np.array(shape)
    sumshape = np.sum(s)
    row, col = s.shape
    animation = list()
    if np.sum(b[:row,c:c+col]) != 0:
        return animation
    for i in range(1000000):
        newb = np.array(b)
        check = newb[i:i+row, c:c+col]
        sumcheck = np.sum(check)
        if i+row > len(b):
            break
        check[s != 0] = s[s != 0]
        sumcheck2 = np.sum(check)
        if sumshape + sumcheck == sumcheck2:
            animation += [newb]
        else:
            break
    return animation
def animate_clear(board):
    b = np.array(board)
    animation = list()
    boardno0 = np.min(b, axis=1) != 0
    if np.max(boardno0) == 1:
        b[boardno0, :] = 0
        animation += [b]
    else:
        return animation
    while True:
        mask = np.sum(b[::-1], axis=1)
        b = np.array(b)
        idx = len(b)-np.argmin(mask)
        b[1:idx, :] = b[0:idx-1, :]
        b[0, :] = 0
        try:
            animation[0] = animation[0]
            if np.min(animation[-1] == b) == 1:
                return animation
            else:
                animation.append(b)
        except:
            pass

xxx023xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 432, 'const': 278, 'code+const': 710}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
import numpy as np
def get_score(board):
    a = np.min(board, axis=1)
    b = a>0
    count = 40*(np.sum(b))
    return count
def get_time_cap(board, time_caps):
    f = int(int(board.shape[0])//len(time_caps))
    if np.sum(board[0:f:1]) != 0:
        return time_caps[0]
    elif np.sum(board[f:2*f:1]) != 0:
        return time_caps[1] 
    elif np.sum(board[2*f:3*f:1]) != 0:
        return time_caps[2] 
    elif np.sum(board[3*f:4*f:1]) != 0:
        return time_caps[3] 
    elif np.sum(board[4*f:5*f:1]) != 0:
        return time_caps[4] 
    elif np.sum(board[5*f:6*f:1]) != 0:
        return time_caps[5]
    else:
        return time_caps[-1]
def rotate_right(shape):
    return shape.T[::,::-1]
def rotate_left(shape):
    return shape.T[::-1,::]
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
    pass

xxx025xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0IndexError('boolean index did not match indexed array along dimension 1; dimension is 5 but corresponding boolean dimension is 4')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (3,4)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0IndexError('boolean index did not match indexed array along dimension 1; dimension is 3 but corresponding boolean dimension is 2')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 974, 'const': 338, 'code+const': 1312}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('For', 10)]]
import numpy as np
def get_score(board):
    x = np.min(board, axis=1)
    return x[x > 0].shape[0] * 40
def get_time_cap(board, time_caps):
    n = board.shape[0]
    m = len(time_caps)
    x = np.sum(np.sum(board, axis=1).reshape((m, n//m)), axis=1)
    if np.sum(x) == 0 :
        i = -1
    else :
        i = np.arange(m)[x > 0][0]
    return time_caps[i]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    copy_board = np.copy(board)
    copy_shape = np.copy(shape)
    x = copy_board[:, c:c+copy_shape.shape[1]]
    ans = []
    for i in range(x.shape[0]-copy_shape.shape[0]+1) :
        check = x[i:i+copy_shape.shape[0], :]
        if np.sum(copy_shape[check>0]) == 0 :
            copy_board = np.copy(board)
            if np.sum(copy_board[i:i+copy_shape.shape[0], c:c+copy_shape.shape[1]+1]) == 0 :
                copy_board[i:i+copy_shape.shape[0], c:c+copy_shape.shape[1]+1] = copy_shape
            else :
                copy_board[i:i+copy_shape.shape[0], c:c+copy_shape.shape[1]+1][check == 0] = copy_shape[copy_shape != 0]
            ans.append(copy_board)
        else :
          break
    return ans
def animate_clear(board):
    copy_board = np.copy(board)
    x = np.min(copy_board, axis=1)
    copy_board[x != 0] = 0
    ans = []
    if np.sum(copy_board == board) != board.shape[0]*board.shape[1] :
        ans.append(copy_board)
        copy_board2 = np.copy(copy_board)
        for i in range(board.shape[0]+1) :
            copy_board3 = np.copy(copy_board2)
            x = np.sum(copy_board2, axis=1) == 0
            j = np.argmax(x[::-1])
            if j == 0 :
                copy_board2[1:,:] = copy_board2[:-j-1,:]
                copy_board2[0,:] = 0
            else :
                copy_board2[1:-j,:] = copy_board2[:-j-1,:]
                copy_board2[0,:] = 0
            if i != 0 and np.sum(copy_board2 == copy_board3) != board.shape[0]*board.shape[1] :
                ans.append(copy_board3)
            if i == board.shape[0] :
                ans.append(copy_board3)
    return ans

xxx205xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 670, 'const': 350, 'code+const': 1020}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 11)]]
import numpy as np
def get_score(board):
    copyboard=np.array(board)
    x=np.min(copyboard,axis=1)
    y=x[x!=0]
    return len(y)*40
def get_time_cap(board, time_caps):
    copyboard=np.array(board)
    bool_arr=copyboard!=0
    max_arr=np.max(bool_arr,axis=1)
    if max(max_arr)==False:
        return time_caps[-1]
    m=np.argmax(max_arr)
    length=m//int((len(copyboard)/len(time_caps)))
    return time_caps[length]
def rotate_right(shape):
    copyshape=np.array(shape)
    return copyshape[::-1].T
def rotate_left(shape):
    copyshape=np.array(shape)
    return copyshape.T[::-1]
def animate_drop(board, shape, c):
    board_list=[]
    width=len(shape[0])
    for i in range(len(board)-len(shape)+1):
        copyboard=np.array(board)
        selected=copyboard[i:i+len(shape),c:c+width]
        if max(selected[shape>0]):
            break
        selected[shape>0]=shape[shape>0]
        board_list.append(copyboard)
    return board_list
def animate_clear(board):
    board_list=[]
    copy_board=np.array(board)
    cond=np.min(copy_board>0,axis=1) 
    if not max(cond):
        return board_list
    copy_board[cond]=0 
    new_board=np.array(copy_board[::-1])
    i=0
    board_list.append(copy_board)
    while True:
        if np.min((new_board==0)[i:]):
            break
        if min(new_board[i]==0):
            new_board[i:len(copy_board[::-1][i+1:])+i]=new_board[i+1:]
            new_board[-1]=[0]*len(board[0])
            board_list.append(np.array(new_board[::-1]))
        else:
            i+=1
    return board_list

xxx025xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[456, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [], []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 1300, 'const': 370, 'code+const': 1670}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 20)], [('While', 19)]]
import numpy as np
def get_score(board):
    s = board.shape[1]
    a = board>0
    c = np.sum(a,axis = 1)
    b = (c == s)
    return np.sum(b)*40
def get_time_cap(board, time_caps):
    a = board>0
    c = np.sum(a,axis = 1)
    b = (c==0)
    return time_caps[np.argmin(b)//int(len(board)/len(time_caps))]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[::1,::-1].T
def animate_drop(board, shape, c):
    ans = list()
    top = 0
    n_board = np.array(board)
    n_board = n_board[top:top+shape.shape[0],c:c+shape.shape[1]] + shape
    check1 = n_board.reshape(n_board.shape[0]*n_board.shape[1])
    pos = np.arange(n_board.shape[1])
    tempsize = np.argmax(shape,axis=0)
    tempboard = (np.array(board))[top:top+shape.shape[0],c:c+shape.shape[1]]
    tempboard[tempboard!=0] = 1
    tempmax = np.argmax(tempboard,axis=0)
    tempboard = np.max(tempboard,axis=0)
    isPos = np.sum( (tempmax < tempsize) & (tempboard!=0) )
    if(isPos):
      return list()
    pos = np.arange(n_board.shape[0]*n_board.shape[1])
    nshape = shape.reshape(n_board.shape[0]*n_board.shape[1])
    concern = pos[nshape!=0]
    check1 = check1[concern]
    while(top<board.shape[0]-shape.shape[0]+1 and np.sum(check1,axis=0) == np.sum(np.sum(shape,axis=0),axis=0)):
      n_board = np.array(board)
      n_board[top:top+shape.shape[0],c:c+shape.shape[1]] = n_board[top:top+shape.shape[0],c:c+shape.shape[1]] + shape
      ans.append(n_board)
      top = top+1
      if(top<board.shape[0]-shape.shape[0]+1):
        n_board = np.array(board)
        n_board = n_board[top:top+shape.shape[0],c:c+shape.shape[1]] + shape
        check1 = n_board.reshape(n_board.shape[0]*n_board.shape[1])
        nshape = shape.reshape(n_board.shape[0]*n_board.shape[1])
        concern = pos[nshape!=0]
        check1 = check1[concern]
    return ans
def animate_clear(board):
    ans = list()
    b = np.arange(board.shape[0])
    c = np.min(board,axis=1)
    d = np.max(board,axis=1)
    toclear = b[c!=0]
    n_board = np.array(board)
    n_board[toclear] = np.zeros(board.shape[1])
    prefer_top = np.sum( (c!=0) | (d==0) )
    lower = board.shape[0]-1
    x=0
    if(prefer_top!=0):
      ans.append(n_board)
    if(b[np.sum(n_board,axis=1)!=0].shape[0]!=0):
      solidrow = b[np.sum(n_board,axis=1)!=0][0]
    else:
      solidrow = prefer_top
    while(solidrow!=prefer_top):
      if(np.sum(n_board[lower])!=0):
        lower-=1
      else:
        index = np.arange(-1,lower)
        index[0]=lower
        new_board = np.array(n_board)
        new_board[:lower+1] = (n_board[index])
        n_board = np.array(new_board)
        ans.append(n_board)
      if(b[np.sum(n_board,axis=1)!=0].shape[0]!=0):
        solidrow = b[np.sum(n_board,axis=1)!=0][0]
      else:
        solidrow = prefer_top
      x+=1
    return ans

xxx025xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 2140, 'const': 368, 'code+const': 2508}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 5)], [('For', 15)]]
import numpy as np
def get_score(board):
    return len(board[np.sum(board[:] == 0,axis = 1)== 0])*40
def get_time_cap(board, time_caps):
    if np.sum(board[:]==0) == board.shape[0]*board.shape[1]:return time_caps[-1]
    else:return time_caps[int(((np.arange(1,board.shape[0]+1)[np.sum(board[:] != 0,axis = 1)>0])[0]+0.9*(board.shape[0]//len(time_caps)))//(board.shape[0]//len(time_caps)))-1]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    new_board = np.array(board);out = []
    i = 0;j=0
    while True:
        if j<shape.shape[0] and i<=board.shape[0]-shape.shape[0]:
            if ((np.sum(board[i:i+shape.shape[0],c:c+shape.shape[1]][:j+1][shape[:j+1]!=0] == 0) == np.sum(shape[:j+1] != 0)) and                 (np.sum(board[i:i+shape.shape[0],c:c+shape.shape[1]][:j+1][shape[:j+1][::-1]!=0] == 0) == np.sum(shape[:j+1] != 0)))and                 ((np.sum(board[i:i+shape.shape[0],c:c+shape.shape[1]][:j+1][shape[:j+1] == 0] >= 0) == np.sum(shape[:j+1]==0)) and                 (np.sum(board[i:i+shape.shape[0],c:c+shape.shape[1]][:j+1][shape[:j+1][::-1] == 0] >= 0) == np.sum(shape[:j+1]==0))):
                j += 1
            elif np.sum(shape[j] == 0)>0:
                 if ((np.sum(board[i:i+shape.shape[0],c:c+shape.shape[1]][:j+1][shape[:j+1]!=0] == 0) == np.sum(shape[:j+1] != 0)) or                 (np.sum(board[i:i+shape.shape[0],c:c+shape.shape[1]][:j+1][shape[:j+1][::-1]!=0] == 0) == np.sum(shape[:j+1] != 0)))and                 ((np.sum(board[i:i+shape.shape[0],c:c+shape.shape[1]][:j+1][shape[:j+1] == 0] >= 0) == np.sum(shape[:j+1]==0)) or                 (np.sum(board[i:i+shape.shape[0],c:c+shape.shape[1]][:j+1][shape[:j+1][::-1] == 0] >= 0) == np.sum(shape[:j+1]==0))):
                     j += 1
                 else:break
            else:break
        else:
            if i<=board.shape[0]-shape.shape[0]:
                if i>=1:
                    new_board1 = np.array(new_board)
                    new_board = np.array(board)
                    new_board[i:shape.shape[0]+i,c:shape.shape[1]+c] += shape
                else:
                    new_board[i:shape.shape[0]+i,c:shape.shape[1]+c] += shape
                if np.sum(new_board[i:shape.shape[0]+i,c:shape.shape[1]+c][shape!=0])>np.sum(shape[shape!=0]):
                    return out
            else:
                return out 
            out.append(new_board)
            i += 1
            j = 0
    return out
def animate_clear(board):
    new_board = np.array(board)
    out = []
    if list(new_board[np.arange(board.shape[0])[np.sum(board[:] != 0,axis = 1)== board.shape[1]],:]) == []:
        return []
    else:
        new_board[np.arange(board.shape[0])[np.sum(board[:] != 0,axis = 1)== board.shape[1]],:] = np.zeros((1,board.shape[1]))
        out.append(new_board)
        new_board = np.array(new_board)
        if np.sum(new_board== 0) == board.shape[0]*board.shape[1]:return out
        else:
            x = np.arange(board.shape[0])[np.sum(new_board[:] == 0,axis = 1)<board.shape[1]][0]
            a = np.arange(x,board.shape[0])[np.sum(new_board[x:] == 0,axis = 1) == board.shape[1]][::-1]
            for e in range(a.shape[0]) :
                if e>=1:
                    a += 1
                b = list(a)
                new_board[1:b[e]+1,:] = new_board[:b[e],:]
                new_board[0,:] = np.zeros((1,board.shape[1]))
                out.append(new_board)
                new_board = np.array(new_board)
            return out

xxx039xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score0.0
[0, 120]
test_get_time_cap0.0
[12056, 12056, 12056, 12056, 12045, 12045, 12045]
test_rotate_right0.0
[array([[0, 1],
       [0, 12],
       [15, 13],
       [0, 4]]),
 array([[1, 0],
    1   [2, 0],
       [03, 15],
       [14, 10]])]
test_rotate_left0.0
[array([[14, 10],
       [13, 5],
       [2, 0],
       [1, 0]]),
 array([[10, 14],
       [15, 3],
       [0, 2],
       [10, 01]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 140, 'const': 146, 'code+const': 286}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
import numpy as np
def get_score(board):
  return 0
def get_time_cap(board, time_caps):
  return 120
def rotate_right(shape):
  return np.array([[0,1], [0,1],[1,1]])
def rotate_left(shape):
  return np.array([[1,1], [1,0],[1,0]])
def animate_drop(board, shape, c):
  return []
def animate_clear(board):
  return []

xxx205xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 788, 'const': 338, 'code+const': 1126}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 10)]]
import numpy as np
def get_score(board):
    findmin = np.min(board,axis=1)
    return len(findmin[(findmin>0)])*40
def get_time_cap(board, time_caps):
  if np.sum(board) == 0: return time_caps[-1]
  return np.array(time_caps)[np.sum(board.reshape(len(time_caps),(board.shape[0]//len(time_caps))*board.shape[1]),axis = 1) != 0][0]
def rotate_right(shape):
    return shape.T[::,::-1]
def rotate_left(shape):
    return shape.T[::-1,::]
def animate_drop(board, shape, c):
    ans = []
    check_not_zero = np.sum(board != 0) + np.sum(shape != 0)
    zero = np.zeros((shape.shape[0]+board.shape[0],board.shape[1]),int)
    zero[shape.shape[0]:,:] = np.array(board)
    for i in range(board.shape[0]+1):
        new_board = np.array(zero)
        new_board[i:i+shape.shape[0],c:c+shape.shape[1]] += shape
        if np.sum( new_board[shape.shape[0]:,:]) != 0:
            if np.sum(new_board != 0) != check_not_zero:
                return ans
            if i >= shape.shape[0]:
                ans.append(new_board[shape.shape[0]:])
    return ans
def animate_clear(board):
    new_board = np.array(board)
    indzero = np.min(board, axis = 1)!=0
    new_board[indzero,:] = 0
    ans = [np.array(new_board)]
    if np.sum(indzero) == 0:
        return []
    ind0 = np.arange(board.shape[0])[np.sum(new_board,axis=1)==0]
    while np.sum(new_board[0:len(ind0)]) != 0:
        if ind0[-1] != board.shape[0]:
            new_board[1:ind0[-1]+1] = new_board[0:ind0[-1]]
            new_board[0] = 0
        ans.append(np.array(new_board))
        ind0 = np.arange(board.shape[0])[np.sum(new_board,axis=1)==0]
    return ans

xxx020xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 898, 'const': 398, 'code+const': 1296}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 8)], [('While', 7)]]
import numpy as np
def get_score(board):
    return np.sum(np.abs(board).min(axis=1)>0)*40
def get_time_cap(board, time_caps):
    r = board.shape[0]; rt = len(time_caps)
    A = np.abs(board).max(axis=1)
    if np.sum(A!=0) > 0:
        first_line = np.arange(board.shape[0])[A!=0][0]
        B = np.array([time_caps]).T
        B2 = np.ones((1,r//rt),int)
        Bx = B*B2
        K = Bx.reshape(r)
        return K[first_line]
    else: return time_caps[-1]
def rotate_right(shape):
    if len(shape.shape) == 2:
        return shape[::-1,:].T
    else:
        return np.array([shape]).T
def rotate_left(shape):
    if len(shape.shape) == 2:
        return shape[:,::-1].T
    else:
        return np.array([shape[::-1]]).T
def animate_drop(board, shape, c):
    rs,cs = shape.shape
    rb,cb = board.shape 
    temp_board = board[:,c:c+cs]
    A = np.abs(temp_board).max(axis=1)
    r = []
    i = rs-1
    while True:
        new_board = np.abs(np.array(board))
        if i == rb:
            break
        s = new_board[i-(rs-1):i+1:,c:c+cs:]*shape
        if s.max() == 0:
            new_board[i-(rs-1):i+1:,c:c+cs:] += shape
            r.append(new_board)
            i += 1
        else:
            break
    return r
def animate_clear(board):
    clear_board = np.array(board)
    clear_board[np.abs(board).min(axis=1) != 0] = np.array(0)
    temp_board = np.array(clear_board)
    r = [clear_board]
    if np.sum(clear_board != board) != 0:
        while True:
            A = np.abs(temp_board).max(axis=1)
            first_blank = np.arange(board.shape[0])[A==0][-1]
            first_full = np.arange(board.shape[0])[A!=0]
            if np.sum(first_full<first_blank)==0:
                break
            first_full = first_full[first_full<first_blank][-1]
            new_board = np.array(temp_board)
            new_board[1:first_blank+1] = new_board[0:first_blank]
            new_board[0] = np.array(0)
            temp_board = np.array(new_board)
            r.append(new_board)
            first_full += 1
        return r
    else:
        return []

xxx039xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0ValueError('cannot reshape array of size 24 into shape (2,8)')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (4,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (6,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (3,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [0, 0, 0, 0],
       [1, 0, 2, 4]]),
  array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [1, 0, 5, 4],
       [1, 0, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1342, 'const': 352, 'code+const': 1694}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('For', 14)]]
import numpy as np
def get_score(board):
    check_equal_zero = np.array([[0]*board.shape[1]]*board.shape[0])  == board
    check_no_zero = [ 0  == np.sum(check_equal_zero,axis=1)]
    no_zero = board[check_no_zero]
    get_the_score = no_zero.shape[0]*40
    return get_the_score
def get_time_cap(board, time_caps):
    board_reshape = board.reshape( (len(time_caps) , board.shape[1]*2))
    find_number = np.array([[0]*board_reshape.shape[1]]*board_reshape.shape[0]) != board_reshape
    zero_line = 0 == np.sum(find_number,axis=1)
    cut_zero_line = ~(zero_line)
    fine_position = np.arange(0,board_reshape.shape[0])[cut_zero_line]
    if sum(~zero_line) != 0:
        position = fine_position[0]
        total_time_caps = time_caps[position]
    else:
        total_time_caps = time_caps[-1]
    return total_time_caps
def rotate_right(shape):
    new_shape = shape[-1::-1]
    return new_shape.T
def rotate_left(shape):
    re_shape = shape[::,::-1]
    return re_shape.T
def animate_drop(board, shape, c):
    new_board = np.array(board)
    list_board = []
    count = 0
    for line in range(board.shape[0]):
        if sum(new_board[line][c::] == [0]*len(new_board[line][c::])) == len(new_board[line][c::])and count == 0:
            new_board[line][c::] = shape
            list_board.append(new_board)
            count += 1
        elif sum(new_board[line][c::] == [0]*len(new_board[line][c::])) == len(new_board[line][c::]) and count != 0:
            new_board = np.array(board)
            new_board[line][c::] = shape
            list_board.append(new_board)
    return list_board
def animate_clear(board):
    position = np.arange(0,board.shape[0],1)
    find_boolean_of_all_each_num_in_line = np.zeros((board.shape[0],board.shape[1]),int) == board
    find_boolean_of_num_line = [np.sum(find_boolean_of_all_each_num_in_line,axis=1) == 0]
    position_all_num = position[find_boolean_of_num_line]
    board[position_all_num] = np.array([0]*board.shape[1])
    list_board_clear = []
    new_board = np.array(board)
    list_board_clear.append(new_board)
    find_boolean_of_all_each_zero_in_line = np.zeros((board.shape[0],board.shape[1])) == board
    find_boolean_of_zero_line = [np.sum( find_boolean_of_all_each_zero_in_line,axis=1) == board.shape[1]]
    number_of_aero_line = len(position[find_boolean_of_zero_line])
    for i in range(board.shape[0]):
        if np.sum(np.sum(board[:number_of_aero_line:1] == np.zeros((board[:number_of_aero_line:1].shape[0],board[:number_of_aero_line:1].shape[1]),int),axis=1),axis=0) != 1*board[:number_of_aero_line:1].shape[1]*board[:number_of_aero_line:1].shape[0]:
            find_boolean_of_all_each_zero_in_line = np.zeros((board.shape[0],board.shape[1])) == board
            find_boolean_of_zero_line = [np.sum( find_boolean_of_all_each_zero_in_line,axis=1) == board.shape[1]]
            position_changing = position[find_boolean_of_zero_line]
            if -1 not in position_changing-1:
                board[position_changing] = board[position_changing-1]
                check_boolean_of_the_line_position_each_changing_1 = board[position_changing-1] == board[position_changing]
                check_boolean_of_the_line_position = np.sum(check_boolean_of_the_line_position_each_changing_1,axis=1)== board.shape[1]
                get_line_that_gonna_change_together = (position_changing-1)[check_boolean_of_the_line_position]
            else:
                board[position_changing[1::]] = board[(position_changing-1)[1::]]
                check_boolean_of_the_line_position_each_changing_1 = board[(position_changing-1)[1::]] == board[position_changing[1::]]
                check_boolean_of_the_line_position = np.sum(check_boolean_of_the_line_position_each_changing_1,axis=1) == board.shape[1]
                get_line_that_gonna_change_together = (position_changing-1)[1::][check_boolean_of_the_line_position]
            board[get_line_that_gonna_change_together] = np.array([0]*board.shape[1])
            new_board = np.array(board)
            list_board_clear.append(new_board)
    if np.sum(np.sum((list_board_clear[0] != board),axis=1),axis=0) != 0:
        return list_board_clear
    else:
        return []

xxx043xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 856, 'const': 350, 'code+const': 1206}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 10)], [('While', 12)]]
import numpy as np
def get_score(board):
    ch = np.sum(board == 0,axis=1)
    return sum(ch==0)*40
def get_time_cap(board, time_caps):
    prows = np.arange(0,board.shape[0])
    ch = np.sum(board != 0,axis=1)
    if sum(ch) == 0:
        return time_caps[-1]
    f = prows[ch != 0][0]
    return time_caps[f//(board.shape[0]//len(time_caps))]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    result = []
    c_board = np.array(board); c_shape = np.array(shape)
    mx = np.max(c_shape)
    pos = np.arange(c_shape.shape[1])
    posch = np.ndarray((c_shape.shape[0],c_shape.shape[1]),int)
    posch[:,:] = pos
    b = c_shape!=mx
    ch = posch[c_shape==mx]
    for i in range(board.shape[0]-shape.shape[0]+1):
        newboard = np.array(c_board)
        nb = newboard[i:i+shape.shape[0],c:c+shape.shape[1]]!=0
        if list(posch[(nb+b) == False]) == list(ch):
            newboard[i:i+shape.shape[0],c:c+shape.shape[1]] += c_shape
            result.append(newboard)
        else : break
    return result
def animate_clear(board):
    final = []
    c_board = np.array(board)
    rpos = list(np.arange(c_board.shape[0])[(np.sum(c_board==0,axis=1))==0])
    if rpos == []:
        return final
    c_board[rpos] = 0
    final.append(np.array(c_board))
    z = len(np.arange(c_board.shape[0])[(np.sum(c_board!=0,axis=1))==0])
    newboard = np.array(c_board)
    oldboard = np.array(c_board)
    while np.sum(newboard[:z]) != 0:
        zpos = list(np.arange(oldboard.shape[0])[(np.sum(oldboard!=0,axis=1))==0])[-1]
        newboard[0] = 0
        newboard[1:zpos+1] = oldboard[:zpos]
        final.append(np.array(newboard))
        newboard = np.array(newboard)
        oldboard = np.array(newboard)
    return final

xxx218xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 806, 'const': 324, 'code+const': 1130}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('For', 10)]]
import numpy as np
def get_score(board):
  return np.sum(np.sum(board != 0, axis = 1) == board.shape[1])*40
def get_time_cap(board, time_caps):
  if np.sum(board) == 0:
    return time_caps[-1]
  new_board = np.array(board)
  new_board = new_board.reshape((len(time_caps),(board.shape[0]*board.shape[1])//len(time_caps)))
  inx = np.arange(len(time_caps))[np.sum(new_board, axis = 1)*np.array(time_caps) > 0][0]
  return time_caps[inx]
def rotate_right(shape):
  return shape.T[:,::-1]
def rotate_left(shape):
   return shape.T[::-1,:]
def animate_drop(board, shape, c):
  sun = []
  new_board = np.array(board)
  ck = np.sum(board*board)
  ro, co = shape.shape
  for j in range(1+board.shape[0]-ro):
    new_board[np.arange(ro) + j, c:co+c] += shape
    if np.sum(new_board*board) == ck and np.sum(board[:ro-1,c:c+co]*shape[1-ro:]) == 0:
      sun.append(new_board)
      new_board = np.array(board)
    else:
      break
  return sun
def animate_clear(board):
  ro, co = board.shape
  if np.sum(np.sum(board != 0, axis = 1) == co) == 0:
    return []
  day = []
  new_board = np.array(board)
  new_board[np.arange(ro)[np.min(board, axis = 1) != 0]] *= 0
  day.append(new_board)
  exp = np.array(new_board)
  for j in range(ro+1):
    iz = np.max(np.arange(ro)[np.max(exp, axis = 1) == 0])
    if np.sum(exp[np.arange(iz)]) != 0:
      g = np.zeros((iz+1,co),int)
      g[1:,:] += exp[np.arange(iz)]
      exp[np.arange(iz+1)] = g
      out = np.array(exp)
      day.append(out)
    else:
      return day

xxx204xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 10, 1]])0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[0, 0, 2, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [02, 02, 02, 0, 0, 0],
       [0, 0, 02, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [02, 02, 02, 0, 8, 0],
       [1, 1, 02, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 0, 0, 2, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [12, 12, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 2,  ... (more)
test_animate_drop_30.0
[[],
 [array([[0, 2, 2, 0],
       [1, 1, 02, 0],
       [1, 0, 0, 02],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 2, 2, 0],
       [1, 1, 0, 0],
       [1, 01, 02, 02]])],
       [1, 0, 0, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_10.0
[[array([[2, 2, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [2, 2, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [2, 2, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [20, 20, 20, 40]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[5, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
   ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 1218, 'const': 512, 'code+const': 1730}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 10)], [('While', 8)]]
import numpy as np
def get_score(board):
    x = np.min(board, axis=1) != 0
    return np.sum(x*40)
def get_time_cap(board, time_caps):
    x = np.max(board, axis=1) == 0
    y = np.sum(x*1)
    if y % 2 == 0 : y -= 2
    else: y -= 1
    if y >= len(time_caps)-1 : y = -1
    return time_caps[y]
def rotate_right(shape):
    new_shape = np.array(shape)
    return new_shape[::-1,:].T
def rotate_left(shape):
    new_shape = np.array(shape)
    return new_shape[:,::-1].T
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    shape_size = new_shape.shape 
    ans = []
    if board.shape[0] < shape_size[0]+c: return ans
    i,j = 0,0 
    check1,check2 = True,True 
    while True :
        if check1 == True: 
            if i == new_board.shape[0]: break
            base = np.zeros(board.shape, int)
            if i < shape_size[0] : x = new_shape[shape_size[0]-i-1 :, :] 
            else : x = new_shape[shape_size[0]-1 :, :] 
            base[i-x.shape[0]+1:i+1,c : c+x.shape[1]] = x 
            check1 = False 
            j = 0 
        y_zero = base[i-x.shape[0]+1:i+1,c : c+x.shape[1]]
        y_new = new_board[i-x.shape[0]+1:i+1,c : c+x.shape[1]] 
        y = (y_zero + y_new)
        if check1 == False: 
            if j < y.shape[0] * y.shape[1] :  
                X = j // y.shape[1]
                Y = j % y.shape[1]
                if y[X][Y] == y_zero[X][Y] or y[X][Y] == y_new[X][Y] : check2 = True 
                else : check2 = False
            else: 
                check1 = True 
                j = 0 
                i += 1 
                ans.append(base + new_board)
                continue 
            j+=1 
            if check2 == False: break
    return ans
def animate_clear(board):
    new_board = np.array(board)
    ans = []
    i = new_board.shape[0]-1 
    check1,check2 = True,True 
    line = 0 
    while(True):
        if check1:
            if np.min(new_board[i]) != 0 : 
                new_board[i] = np.zeros(new_board[i].shape, int) 
                line+=1
            elif np.sum(new_board[i]) == 0 : line+=1
            i -= 1 
            if i == 0 and line != 0 : 
                i = new_board.shape[0]-1
                ans.append(np.array(new_board)) 
                check1 = False
            elif i == 0 and line == 0 : break 
        if check1 == False : 
            if i == -1 : break 
            if check2 :
                if np.sum(new_board[i]) == 0 : check2 = False
                else :
                    i -= 1
                    continue
            if i != 0 : 
                new_board[i] = new_board[i-1]
                i -= 1
            elif i == 0 : 
                new_board[i] = np.zeros(new_board[i].shape, int)
                ans.append(np.array(new_board))
                if np.sum(np.sum(ans[-1], axis=1)[:line] == 0) == line : break 
                check2 = True
                i = new_board.shape[0]-1 
    return ans

xxx029xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0ValueError('zero-size array to reduction operation maximum which has no identity')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0ValueError('min() arg is an empty sequence')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0ValueError('min() arg is an empty sequence')
[[]]
bytecount: {'code': 888, 'const': 324, 'code+const': 1212}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 14)]]
import numpy as np
def get_score(board):
    a = board[~(np.min(board, axis=1)==0)]
    return len(a)*40
def get_time_cap(board, time_caps):
    b = np.sum(board,axis=1)==0
    c = np.arange(1,board.shape[0]+1)
    d = c[b]
    if np.max(d)==len(board):
        g = time_caps[-1]
    else:
        e = int(np.max(d))+1
        f = int(len(board)//len(time_caps))
        cal = int(int(-(-e//f)))-1
        g = time_caps[cal]
    return g
def rotate_right(shape):
    return np.array(shape.T[:,::-1])
def rotate_left(shape):
    return np.array(shape.T[::-1,:])
def animate_drop(board, shape, c):
    a = np.array(board)
    s = np.array(shape)
    fin = []
    for i in range(a.shape[0]-s.shape[0]+1):
        b = np.array(a)
        b[i:i+s.shape[0],c:c+s.shape[1]:][s!=0]=s[s!=0]
        if (np.sum(a!=0)+np.sum(s!=0))==np.sum(b!=0):
            fin.append(b)
        else:break
    return fin
def animate_clear(board):
    a = np.array(board)
    fin = []
    r,c = a.shape
    b = np.zeros(c)
    a[np.min(a,axis=1)!=0]=b
    if sum(np.sum(a, axis=1)==0)==0:
       return [] 
    fin.append(np.array(a))
    d = np.arange(r)[np.sum(a,axis=1)!=0]
    e = np.arange(r)[np.sum(a,axis=1)==0]
    f = max(np.arange(r)[np.sum(a,axis=1)==0])
    while min(np.arange(r)[np.sum(a,axis=1)!=0])!=r-len(d):
        f = max(np.arange(r)[np.sum(a,axis=1)==0])
        if f>=len(e):
            a[1:f+1:,:]=a[0:f:,:]
            a[0,:]=np.zeros(c)
        fin.append(np.array(a))
    return fin

xxx019xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 980, 'const': 338, 'code+const': 1318}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 11)], [('While', 12)]]
import numpy as np
def get_score(board):
    a = board
    c = a[:,:][np.min(a,axis=1) != 0 ]
    row = len(c)
    return row * 40
def get_time_cap(board, time_caps):
    a = board
    b = np.array(time_caps)
    listidx= np.arange(0,len(b))
    ares = a.reshape(len(b),((a.shape[0]*a.shape[1])//len(b)))
    check = np.sum(ares,axis=1)
    check2 = check!=0
    if np.sum(check2) != 0:
        ans = b[check2][0]
        return ans
    else:
        return b[-1]
def rotate_right(shape):
    a = shape.T
    b = a[:,::-1]
    return b
def rotate_left(shape):
    a = shape.T
    b = a[::-1,:]
    return b
def animate_drop(board, shape, c):
    a = np.array(board)
    b = np.array(shape)
    listans = []
    idxforloop = 0
    idxforboard = 0
    k = 1
    i = 1
    tfforshape = b == np.max(b)
    idxdoneloop = a.shape[0]
    while idxforloop < idxdoneloop:
        if k ==board.shape[0] +1:
            break
        chooseboard = board[idxforloop:k,c:c+b.shape[1]]
        chooseshape = b[b.shape[0]-i:,:]
        if chooseboard.shape[0] != chooseshape.shape[0]:
            return listans
        tfinboard = chooseboard > 0
        tfinshape = chooseshape == np.max(b)
        checktf = tfinboard & tfinshape
        sumcheck = np.sum(checktf)
        if sumcheck > 0:
            break
        elif i == b.shape[0]:
            newa = np.array(a)
            newa[idxforloop:k,c:c+b.shape[1]] += chooseshape
            listans.append(newa)
        if i == b.shape[0]:
            i += 0
            idxforloop += 1
            k += 1
        else:
            i += 1
            k +=1
    return listans
def animate_clear(board):
    listans = []
    a = np.array(board)
    aridx = np.arange(a.shape[0])
    b = np.min(board,axis = 1)!=0
    if np.sum(b) != 0:
        a[b,:] = 0
        listans.append(np.array(a))
    else:
        return listans
    block = np.sum(np.sum(a,axis = 1)!= 0) 
    while np.sum(np.sum(a[-block:],axis = 1) != 0) != block:
        gap = np.sum(a,axis = 1) == 0
        idxgap = aridx[gap][-1]
        if idxgap != a.shape[0]:
            a[1:idxgap+1] = a[0:idxgap]
            a[0,:] = 0
            listans.append(np.array(a))
    return listans

xxx219xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 770, 'const': 346, 'code+const': 1116}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 9)], [('While', 9)]]
import numpy as np
def shanronggreadloi(hoha, ahha):
  za = -(-hoha//ahha)
  return za
def get_score(board):
    jadinoor = np.min(board, axis = 1)
    return 40 * np.sum(jadinoor != 0)
def get_time_cap(board, time_caps):
    yagtaartummaidy = np.max(board, axis = 1)
    kunkruboubboubnoy = np.arange(len(board))
    mandang = kunkruboubboubnoy[yagtaartummaidy != 0]
    if len(mandang) == 0 :
      return time_caps[-1]
    mandang = int(mandang[0])
    saroung = shanronggreadloi(mandang + 1, len(board) // len(time_caps))
    ounnimairu = saroung -1
    return time_caps[ounnimairu]
def rotate_right(shape):
    return np.array(shape.T[::,::-1])
def rotate_left(shape):
    return np.array(shape.T[::-1,::])
def animate_drop(board, shape, c):
    awer = np.sum(board != 0)
    fanedition = np.sum(shape != 0)
    tarour = awer + fanedition
    hahe, ahha = shape.shape
    yeayband = []
    sd = len(board) - hahe
    loveyou = sd + 1
    for i in range(loveyou) :
      yajanub = np.array(board)
      sa = i+hahe
      da = c+ahha
      yajanub[i:sa, c:da] += shape 
      if np.sum(yajanub != 0) != tarour :
        break
      zx = np.array(yajanub)
      yeayband.append(zx)
    return yeayband
def animate_clear(board):
    yeayband = np.array(board)
    yeayband[np.min(board, axis = 1)!= 0,:] = 0
    yajanub = np.sum(np.sum(yeayband, axis = 1) != 0)
    x = np.arange(len(board))
    tarour = []
    axtince = np.array(yeayband)
    tarour.append(axtince)
    while True :
      alfra = np.sum(yeayband, axis = 1) == 0
      if np.sum(alfra) == 0 :
        return []
      helpme = x[alfra][-1]
      if helpme != len(board) :
        yeayband[1:helpme+1] = yeayband[0:helpme]
        yeayband[0] = 0
        mairuna = np.array(yeayband)
        tarour.append(mairuna)
        tummaiban = np.sum(yeayband[-yajanub:], axis = 1)!= 0
      if np.sum(tummaiban) == yajanub :
        break
    return tarour

xxx018xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 666, 'const': 324, 'code+const': 990}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 6)], [('While', 10)]]
import numpy as np
def get_score(board):
    return np.sum(np.sum(board!=0, axis = 1)==board.shape[1]) * 40
def get_time_cap(board, time_caps):
    return np.array(time_caps)[np.sum(np.sum(board, axis=1).reshape(len(time_caps), board.shape[0]//len(time_caps)), axis=1)!=0][0] if np.sum(board)!=0 else time_caps[-1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    list_out = []
    row, col = shape.shape
    r = 0
    while (np.sum(np.ones((row,col))[(shape==0) | (board[r:r+row,c:c+col]==0)]) == (row*col)):
        new_board = np.array(board)
        new_board[r:r+row,c:c+col] += shape
        list_out.append(new_board)
        r += 1
        if r+row > board.shape[0]: break
    return list_out
def animate_clear(board):
    list_out = []
    new_board = np.array(board)
    new_board[np.sum(board!=0, axis = 1)==board.shape[1]] = 0
    c = board.shape[0]-1
    if get_score(board) > 0:
        board_output = np.array(new_board)
        list_out.append(board_output)
    while np.sum(new_board[:c]) != 0:
        if np.sum(new_board[c]) == 0:
            new_board[1:c+1,:] = new_board[:c,:]
            new_board[0] = np.zeros(board.shape[1])
            board_output = np.array(new_board)
            list_out.append(board_output)
        else:
            c -= 1
    return list_out

xxx207xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[array([0, 0, 0, 0])]
bytecount: {'code': 426, 'const': 200, 'code+const': 626}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[('For', 4)], [('For', 6), ('For', 8)], [], [], [('For', 6), ('For', 10)], [('For', 5)]]
import numpy as np
def get_score(board):
    pass
    a=0
    for e in board:
        if 0 not in e:
            a+=1
    ans=a*40
    return ans
def get_time_cap(board, time_caps):
    pass
    a=len(board)/len(time_caps)
    position=0
    check=0
    for i in range(len(board)):
        count=0
        for e in board[i]:
            if e==0:
                count+=1
        if count==len(board[i]):
            continue
        else:
            position=i
            check+=1
            break
    if check==0:
        return time_caps[-1]
    else:
        ans=time_caps[position//int(a)]
        return ans
def rotate_right(shape):
    pass
    ans=shape[::-1].T
    return ans
def rotate_left(shape):
    pass
    ans=shape.T[::-1]
    return ans
def animate_drop(board, shape, c):
    pass
    a=len(board)
    b=0
    for e in board:
        b=len(e)
    c=len(shape)
    d=0
    for e in shape:
        d=len(e)
def animate_clear(board):
    pass
    new_board = np.array(board)
    for e in new_board:
        if 0 not in e:
            e=0*e
        return e

xxx202xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [], []]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1326, 'const': 370, 'code+const': 1696}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 11)], [('For', 11)]]
import numpy as np
def get_score(board):
  min=np.min(board,axis=1)
  return min[min[:]!=0].shape[0]*40
def get_time_cap(board, time_caps):
  all=np.arange(1,board.shape[0]+1)
  sum=np.sum(board,axis=1)
  if all[sum[:]!=0].shape[0]==0: return time_caps[-1]
  else:
    n=board.shape[0]/len(time_caps)
    return time_caps[int((all[sum[:]!=0][0]/n)+(all[sum[:]!=0][0]%n!=0)-1)]
def rotate_right(shape):
  return shape[::-1,:].T
def rotate_left(shape):
  return shape[:,::-1].T
def animate_drop(board, shape, c):
  animate_drop=[]
  new_shape=np.array(shape)
  new_board=np.array(board)
  allshape=np.arange(shape.shape[0])
  if np.sum((np.sum(((shape!=0)+0),axis=1)==shape.shape[1])+0)!=0:
    new_shape[:allshape[np.sum(((shape!=0)+0),axis=1)==shape.shape[1]][0],:]=shape[shape!=0][0]
    new_board[:new_shape.shape[0],c:new_shape.shape[1]+c]+=new_shape
    if np.sum(new_board[:new_shape.shape[0],c:new_shape.shape[1]+c][new_shape[:,:]!=0])!=np.sum(new_shape): return animate_drop
  for i in range(board.shape[0]-shape.shape[0]+1):
    new_board=np.array(board)
    new_board[i:i+shape.shape[0],c:shape.shape[1]+c]+=shape
    if np.sum(new_board[i:i+shape.shape[0],c:shape.shape[1]+c][shape[:,:]!=0])==np.sum(shape):
      animate_drop.append(new_board)
    else: break
  return animate_drop
def animate_clear(board):
  animate_clear=[]
  all=np.arange(board.shape[0])
  min=np.min(board,axis=1)
  if all[min[:]!=0].shape[0]!=0:
    clear0_board=np.array(board)
    clear0_board[np.array(all[min[:]!=0]),:]=0
    animate_clear.append(clear0_board)
    sum=np.sum(clear0_board,axis=1)
    for i in range(all[sum[:]==0].shape[0]-all[sum[:]!=0][0]):
      newclear0_board=np.zeros(board.shape,int)
      present_board=np.array(animate_clear[-1])
      psum=np.sum(present_board,axis=1)
      new_board=np.zeros((board.shape[0]-1,board.shape[1]),int)
      new_board[:all[psum[:]==0][::-1][0],:]=present_board[:all[psum[:]==0][::-1][0],:]
      new_board[all[psum[:]==0][::-1][0]:,:]=present_board[all[psum[:]==0][::-1][0]+1:,:]
      newclear0_board[1:,:]=new_board
      animate_clear.append(newclear0_board)
  return animate_clear

xxx027xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0TypeError('only integer scalar arrays can be converted to a scalar index')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 202, 'const': 346, 'code+const': 548}
check_import({'allowable': ['numpy']}): [[('re', 1)]]
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep:
   [[('all', 2)], [('any', 2)], [('flip', 2), ('flip', 2), ('transpose', 2)], [('flip', 2), ('transpose', 2)], [], []]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
from re import S
import numpy as np
def get_score(board):
    return sum((board != 0).all(axis = 1)) * 40
def get_time_cap(board, time_caps):
    Any = (board != 0).any(axis = 1)
    if True not in Any:
      return time_caps[-1]
    return time_caps[Any][0]
def rotate_right(shape):
    return np.flip(np.flip(np.transpose(shape)), axis = 0)
def rotate_left(shape):
    return np.flip(np.transpose(shape), axis = 0)
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
    pass

xxx037xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0], ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0], ... (more)
bytecount: {'code': 834, 'const': 350, 'code+const': 1184}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [], [('array_equal', 21)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 3)], [('While', 14)]]
import numpy as np
def get_score(board):
    return len(np.arange((board != 0).shape[0])[np.sum(board != 0, axis=1) == board.shape[1]])*40
def get_time_cap(board, time_caps):
    size = board.shape[0]
    k = int(size/len(time_caps))
    a = np.sum(board != 0, axis=1) != 0
    n = np.arange((board != 0).shape[0])
    if list(n[a]) :
        t = n[a][0]
        return time_caps[int(np.floor(t/k))]
    return time_caps[-1]
def rotate_right(shape):
    return shape.T[::-1].T[::-1].T[::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    animate = []
    for i in range(board.shape[0]) :
        try :
            board2 = np.array(board)
            if sum(board2[i:i+shape.shape[0], c:c+shape.shape[1]][shape != 0]) != 0 :
                break
            board2[i:i+shape.shape[0], c:c+shape.shape[1]] += shape
            animate.append(board2)
        except : break
    return animate
def animate_clear(board):
    bo = np.array(board)
    bo[np.arange(len(board))[np.sum(board == 0, axis = 1) == 0]] = np.array([0])
    b = list(bo)
    u = len(b)
    i = 1 ; k = 0
    valid = False
    b2 = []
    b3 = []
    o = np.array(b)
    b3.append(o)
    r = [[0]*len(b[0])]
    z = np.ndarray(9)
    while True :
        if i > u : break
        valid = sum(b[-i]) == 0
        if valid :
            k += 1
            b2 = r + b[:-i] + b[-i+1:]
            q = np.array(b2)
            if not np.array_equal(b2,z) :
                b3.append(q)
            b = b2
            z = b2
            b2 = []
        valid = sum(b[-i]) == 0
        if i+k == u : break
        if valid :
            continue
        i+=1
    if len(b3) == 1 : return []
    return b3

xxx200xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 760, 'const': 364, 'code+const': 1124}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 5)], [('For', 11)]]
import numpy as np
def get_score(board):
    mini = np.min(board, axis=1)
    return mini[mini>0].shape[0]*40
def get_time_cap(board, time_caps):
    maxi = np.max(board, axis=1)
    if np.sum(maxi) == 0: return time_caps[-1]
    k = (maxi[maxi==0].shape[0]+1)/(board.shape[0]/len(time_caps))
    if k-int(k) != 0: return time_caps[int(k)]
    else: return time_caps[int(k)-1]
def rotate_right(shape): 
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    check = True; new = np.array(board); i=0; animate = []
    shapes = shape>0
    while check:
      space = board[i:i+shape.shape[0],c:c+shape.shape[1]]
      if space.shape[0]<shape.shape[0]: check = False; break
      if np.sum(space[shapes]) == 0:
        new = np.array(board)
        new[i:i+shape.shape[0],c:c+shape.shape[1]]+=shape
        animate.append(new); i+=1
      else: check = False; break
    return animate
def animate_clear(board):
    clear = []
    board[np.min(board,axis=1)!=0] = 0
    clear.append(board)
    idx = np.sum(board,axis=1)
    idx[idx>0] = 1
    idx = idx[np.argmax(idx):]
    idx = idx[idx==0].shape[0]
    if idx == 0: return []
    for i in range(idx):
      s = np.sum(board,axis=1)[::-1]
      s[-np.argmin(s)-1] = -1
      board = board[s>=0]
      e = np.zeros((board.shape[0]+i+1, board.shape[1]))
      e[i+1:,:] = board
      clear.append(np.array(e,int))
    return clear

xxx032xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (3,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (3,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (2,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 2122, 'const': 334, 'code+const': 2456}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('For', 16)]]
import numpy as np
def get_score(board):
    a=board!=0
    return 40*(sum(sum(a.T)==board.shape[1]))
def get_time_cap(board, time_caps):
    a=board!=0
    b=sum(a.T)==0
    if False in  list(b):
     c=list(b).index(False)
     d=board.shape[0]//len(time_caps)
     c=c//d
     return time_caps[c]
    else:
        return time_caps[-1]
def rotate_right(shape):
    a=shape.shape[0]
    b=shape.shape[1]
    c=shape[::-1]
    c=c.T
    return c
def rotate_left(shape):
    a=shape.shape[0]
    b=shape.shape[1]
    c=shape.T
    c=c[::-1]
    return c
def animate_drop(board, shape, c):
    a1=board.shape[1]
    b1=board.shape[0]
    a2=shape.shape[1]
    ans=[]
    for i in range(board.shape[0]+1):
     new_board = np.array(board)
     new_shape = np.array(shape)
     a=new_board!=0
     b=sum(a.T)
     if i==board.shape[0]:
         return ans
     if (a1-b[i])<a2 :
         return ans
     if (a1-b[i])>=a2 :
         new_board[i][int(a1-a2):]=shape
         ans.append(new_board)
     if i==0 and b[i]>c:
         return []
def animate_clear(board):
    a=board==0
    b=sum(a.T)
    ans=[]
    new_board = np.array(board)
    c=list(b)
    if not 0 in c:
        return []
    else:
     p=0
     n=0
     k=0
     h=0
     l=0
     for i in range(99999999999999999999999999999999999):
         if board.shape[0]==2:
          if (i <len(c)) and (c[i]==0 or c[i]==board.shape[1]):
              new_board[i]=0
              if p>=1:
                  k+=1
              else:
                  pass
          if(i <len(c)) and c[i]!=0 :
                 p+=1
          if i==len(c):
             ans.append(new_board)
             new1=np.array(new_board)
             new2=np.array(new_board)
             n+=1
             a=new1!=0
             b=list(sum(a.T))
          if (i>len(c) and k==0) :   
           return  ans 
          if i>len(c) and n==1 :
             new2[0]=0
             new2[1]=new1[0]
          if i>len(c) and k==1:
            ans.append(new2)   
            return  ans
         elif board.shape[0]==3:
          if (i <len(c)) and (c[i]==0 or c[i]==board.shape[1]):
              new_board[i]=0
              if p>=1:
                  k+=1
              else:
                  pass
          if(i <len(c)) and c[i]!=0 :
                 p+=1
          if i==len(c):
             ans.append(new_board)
             new1=np.array(new_board)
             new2=np.array(new_board)
             n+=1
             a=new1!=0
             b=list(sum(a.T))
          if (i>len(c) and k==0) :
           return  ans 
          if i>len(c) and k!=0:
            if k==1  :
             new2[0]=0
             new2[1]=new1[0]
             if b[n+1]==0:
              new2[2]=new1[1]
              ans.append(new2)
             else:
              ans.append(new2)
             return  ans
         elif board.shape[0]!=3 and board.shape[0]!=2:
          if (i <len(c)) and (c[i]==0 or c[i]==board.shape[1]):
              new_board[i]=0
              if p>=1:
                  k+=1
              else:
                  pass
          if(i <len(c)) and c[i]!=0 :
                 p+=1
          if i==len(c):
             ans.append(new_board)
             new1=np.array(new_board)
             new2=np.array(new_board)
             n+=1
             a=new1!=0
             b=list(sum(a.T))
          if (i>len(c) and k==0) :   
           return  ans 
          if i>len(c) and n==1 :
             new2[0]=0
             new2[1]=new1[0]
             n+=1
          if i>len(c) and 1<n<int(new2.shape[0])-2  :
             if i>len(c) and n==int(new2.shape[0])-3 and b[n+1]==0:
               new2[n+1]=new1[n]
               new2[n]=new1[n-1]
               n+=1
             elif i>len(c) and n==int(new2.shape[0])-3 and b[n+1]!=0:
               new2[n]=new1[n-1]               
               n+=1
             elif i>len(c) and n<int(new2.shape[0]):
              new2[n]=new1[n-1]
              new2[n+1]=new1[n]
              n+=1
          if i>len(c) and n==new2.shape[0]-2 and b[n+1]==0:
             new2[n+1]=new1[n]
             new2[n]=new1[n-1]
          if i>len(c) and n==new2.shape[0]-2 and b[n+1]==0:
             new2[n]=new1[n-1]
          if i>len(c) and n==new2.shape[0]-2:
            n=1
            ans.append(new2)
            new1=np.array(new2)
            new2=np.array(new2)
            a=new2!=0
            b=list(sum(a.T))
            h+=1
          if i>len(c) and h==k:   
           return  ans

xxx034xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 910, 'const': 364, 'code+const': 1274}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 11)], [('While', 8)]]
import numpy as np
def get_score(board):
  m = np.sum(board != 0,axis=1)
  return sum(m == board.shape[1])*40
def get_time_cap(board, time_caps):
  z = np.max(board,axis=1)
  k = list(np.max(board,axis=1) == 0)
  if sum(z == False) == len(z):
    return time_caps[-1] 
  m = k.index(False) ; a = board.shape[0] ;  b = len(time_caps)
  x = (int((m+1)/(a/b)) if (m+1)/(a/b)%1 == 0 else int((m+1)/(a/b)+1))-1
  return time_caps[x]
def rotate_right(shape):
  new_shape = np.array(shape)
  ro_r = np.array(new_shape[::-1]).T
  return ro_r
def rotate_left(shape):
  new_shape = np.array(shape)
  ro_l = np.array(shape[:]).T[::-1]
  return ro_l
def animate_drop(board, shape, c):
  b = np.array(board)
  bb = np.array(board)
  new_shape = np.array(shape)
  z = np.zeros_like(b)
  zz = np.array(z)
  k = 0
  p = []
  v = np.sum(b > 0) + np.sum(shape > 0)
  z[:shape.shape[0],c:shape.shape[1]+c] = new_shape
  while True:
    bb = bb+z
    if np.sum(bb > 0) != v:
      break
    p.append(np.array(bb))
    bb = np.array(board)
    z[1:] = z[:-1]
    z[0] = np.array([0])
  return p
def animate_clear(board):
  new_board = np.array(board)
  new_board[np.sum(new_board==0,axis=1) == 0] = np.array(0)
  if (sum(np.max(new_board, axis=1)==0)) == 0: return []
  p = [];c = 0
  p.append(np.array(new_board))
  while True:
    if np.max(new_board[-(c+1)]) == 0:
      if c == 0: new_board[1:] = new_board[:-(c+1)]
      else: new_board[1:-c] = new_board[:-(c+1)]
      new_board[0] = np.array(0)
      c = -1
      p.append(np.array(new_board))
      if sum(np.max(new_board[:(sum(np.max(new_board, axis=1)==0))], axis=1)==0) == (sum(np.max(new_board, axis=1)==0)): 
        break
    c += 1
  return p

xxx219xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (1,3)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (1,3)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (1,2)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  Nonearray([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 812, 'const': 242, 'code+const': 1054}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('For', 15)]]
import numpy as np
def get_score(board):
    a = board > 0
    c = np.sum(a,1)
    d = c == board.shape[1]
    scoreT = len(d[d%2==1])
    score = 40*scoreT
    return score
def get_time_cap(board, time_caps):
    nshung = len(board)/len(time_caps)
    nb = board.reshape(int(len(time_caps)),int(nshung*board.shape[1]))
    a = nb != 0
    rowTF = np.sum(a,1)
    findF = rowTF != 0
    x = np.sum(findF,0)
    if x == 0 :
        return time_caps[-1]
    else:
        firstF = np.argmax(findF)
        return time_caps[firstF]
def rotate_right(shape):
    n = shape[::-1, ::1]
    Tr = n.T
    return Tr
def rotate_left(shape):
    o = rotate_right(shape)
    t = rotate_right(o)
    tr = rotate_right(t)
    return tr
def animate_drop(board, shape, c):
    p = []
    zeroboard = np.zeros(board.shape, int)
    for i in range(board.shape[0]):
        new_board = np.array(board)
        new_shape = np.array(shape)
        spaceb = new_board == 0
        shapeinzero = np.zeros(board.shape)
        shapeinzero[i:i+1:,c:shape.shape[1]+c:] = shape
        haves = shapeinzero != 0
        mix = spaceb & haves
        mixT = np.sum(mix,1)
        if mixT[i] == shape.shape[1]:
            new_board[i:i+1:,c:shape.shape[1]+c:] = shape
            p.append(new_board)
        else:
           break
    return p
def animate_clear(board):
    d = []
    new_board = np.array(board)
    minrow = np.min(new_board, 1)
    index = minrow != 0
    new_board[index,:] = 0
    check0 = np.sum(new_board,1)
    nb = np.array(new_board)
    n_b = new_board - board
    n_b0 = np.sum(n_b)
    if n_b0 == 0 :
        return []
    else:
        d.append(new_board)
    for i in range(nb.shape[0]):
        nb2 = np.array(nb)
        if np.sum(nb[i]) == 0:
            nb2[1:i+1,:] = nb[0:i,:]
            nb2[0] = 0
            d.append(nb2)
        nb[:,:] = nb2[:,:]

xxx023xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score0.0
[40, 4120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[array([[2, 2, 2, 0],
       [1, 0, 1, 1]])], [array([[0, 2, 2, 2],
       [1, 02, 1, 1]])],
 [array([[0, 1, 5, 5, 50, 50, 0, 0],
       [0, 1, 1, 05, 05, 0, 0, 0],
       [0, 2, 2, 2, 05, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 02, 0, 0, 0],
       [0, 0, 02, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 02, 0, 8, 0],
       [1, 1, 02, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 02, 8, 8, 0],
       [1, 1, 02, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 2, 2, 2, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 2, 2, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [array([[0, 0, 2, 2, 2, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0,  ... (more)
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 0, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 0, 0, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [0, 0, 0, 0],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 25, 25, 4]])],
  [array([[0, 20, 20, 40],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 02, 02, 04]])]]
test_animate_clear_20.0
[[array([[0, 2, 0, 0],
       [2, 2, 2, 0],
       [1, 1, 0, 0]]),
  array([[0, 2, 0, 0],
       [2, 2, 2, 0],
       [1, 1, 0, 0]])],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 1008, 'const': 560, 'code+const': 1568}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], []]
import numpy as np
def get_score(board):
  x=np.sum(board>0,axis=1)
  return np.sum(x==5)*40
def get_time_cap(board, time_caps):
  y=np.arange(np.sum(board.reshape((len(time_caps),board.shape[0]*board.shape[1]//len(time_caps)))>0,axis=1).shape[0])[np.sum(board.reshape((len(time_caps),board.shape[0]*board.shape[1]//len(time_caps)))>0,axis=1)>0]
  return time_caps[y[0]] if len(y)>0 else time_caps[-1]
def rotate_right(shape):
  x=shape[-1::-1].T
  return x
def rotate_left(shape):
  if len(shape)==1:return np.array([shape[0][-1::-1]]).T
  else:return np.array([shape[0][-1::-1],shape[1][-1::-1]]).T
def animate_drop(board, shape, c):
  nb=np.array(board);ns=np.array(shape)
  x=np.sum(nb[0,c:c+ns.shape[1]]>0)
  ans=[]
  if x==0:
    nb[0,c:c+ns.shape[1]]=ns[0,0]
    ans.append(nb)
    for i in range(1,len(board)):
      nb=np.array(board)
      y=nb[i,c:c+ns.shape[1]]
      if np.sum(y>0)==0:    
          nb[i,c:c+ns.shape[1]]=ns[0,0]
          ans.append(nb)
      else:
          break
  return ans
def animate_clear(board):
  nb=np.array(board)
  slist=checknb(nb) 
  posf=posfull(slist) 
  anslist=[]
  nb[posf]=0 ; nb1=np.array(nb)
  anslist.append(nb)
  qqq=noton(nb1,posf)
  nb1[qqq]=9
  slist=checknb(nb1) ; posz=poszero(slist)
  nb1[posz]=nb[posz-1]
  nb1[posz-1]=0
  nb1[qqq]=nb[qqq]
  anslist.append(nb1)
  return anslist
def checknb(nb): 
  b=nb>0 ; slist=np.sum(b,axis=1)
  return slist
def posfull(slist): 
  pos=np.arange(len(slist))
  posf=pos[(slist==4)|(slist==0)]
  return posf
def poszero(slist): 
  pos=np.arange(len(slist))
  posz=pos[slist==0]
  return posz
def noton(nb,posf):
  z=np.ones_like(posf,int);z[...]=9
  z[:-1]=posf[1:]
  q=(z==posf+1) 
  pos1=np.arange(len(posf))
  qq=pos1[q==1]+1 ;qqq=posf[qq] 
  return qqq

xxx213xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None,
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 20, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 760, 'const': 338, 'code+const': 1098}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 9)]]
import numpy as np
def get_score(board):
    m = board==0
    n = np.sum(m,axis=1)
    return(np.sum((n==0)*40))
def get_time_cap(board, time_caps):
    cap = len(time_caps)
    m = board==0
    n = np.argmin(np.sum(m,axis=1)==board.shape[1])
    nn = np.min(np.sum(m,axis=1)==board.shape[1])
    if n==0 and nn == 1:
        return(time_caps[-1])
    else :
        return(time_caps[n//(len(board)//cap)])
def rotate_right(shape):
    return (shape[::-1,::].T)
def rotate_left(shape):
    return (shape[::,::-1].T)
def animate_drop(board, shape, c):
    ans = []
    for i in range(board.shape[0]):
        new_board = np.array(board)
        if (new_board[i:i+shape.shape[0],c:c+shape.shape[1]].shape)==(shape.shape):
            if not(np.max((new_board[i:i+shape.shape[0],c:c+shape.shape[1]] != 0) * (shape!=0))) :
                new_board[i:i+shape.shape[0],c:c+shape.shape[1]] +=shape
                ans.append(new_board)
            else :
                return ans
        else :
                return ans
def animate_clear(board):
    new_board = np.array(board)
    m = new_board==0
    pre_board = ((np.array([(np.sum(m, axis=1)!=0)]).T*new_board))
    a = 0
    qc = np.min(np.sum(pre_board,axis=1))
    ans = [pre_board]
    pre_board = np.array(pre_board[::-1])
    while True :
        if qc == 0 :
            if sum(pre_board[a]) == 0 :
                pre_board[a:-1]=pre_board[a+1:]
                pre_board[-1] = np.zeros_like (pre_board[-1], int)
                am = np.array(pre_board[::-1])
                ans.append(am)
            else :
                a+=1
            if np.max(pre_board[a+1:])==0:
                return ans
        else :
            return([])

xxx038xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[array([[2, 2, 2, 0],
       [1, 0, 1, 1]])], [array([[0, 2, 2, 2],
       [1, 02, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 05, 05, 0, 0, 0],
       [0, 2, 2, 2, 05, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 02, 0, 0, 0],
       [0, 0, 02, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 02, 0, 8, 0],
       [1, 1, 02, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 02, 8, 8, 0],
       [1, 1, 02, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 2, 2, 2, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 2, 2, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [array([[0, 0, 2, 2, 2, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0,  ... (more)
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 0, 0, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 772, 'const': 264, 'code+const': 1036}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 12)]]
import numpy as np
def get_score(board):
    a = np.min(board,1)
    a = a[a>0]
    return len(a)*40
def get_time_cap(board, time_caps):
    a = np.max(board,1)
    pos = np.arange(a.shape[0])
    pos = pos[a>0]
    if len(pos)!=0:
      k = pos[0]
      return time_caps[int(k/int(len(board)/len(time_caps)))]
    else:
      return time_caps[len(time_caps)-1]
def rotate_right(shape):
    a = shape[[shape.shape[0]-1]-np.arange(shape.shape[0])]
    return a.T
def rotate_left(shape):
    a = shape.T
    return a[[a.shape[0]-1]-np.arange(a.shape[0])]
def animate_drop(board, shape, c):
    nb = np.array(board)
    a = nb[:,c:c+len(shape[0])]
    a = np.max(a,1)
    t = []
    for i in range(len(board)):
      nb = np.array(board)
      if a[i] > 0:
          return t
      else:
        tmp = list(nb[i][0:c])+list(shape[0][:])+list(nb[i][c+len(shape[0]):])
        nb[i] = tmp
        t.append(np.array(nb))
    return t
def animate_clear(board):
    nb = np.array(board)
    a = np.min(board,1)
    pos = np.arange(a.shape[0])[a>0]
    if pos.shape[0] == 0:
      return []
    nb[pos] = [0]
    t = []
    t.append(nb)
    i = a.shape[0]-1
    while i>=0:
      a = nb.max(1)
      a = a==0
      if False not in a[:i]:
        return t
      if a[i] == True:
        pos = np.arange(a.shape[0])
        pos[0] = pos[i]
        pos[1:i+1]-=1
        nb = nb[pos]
        t.append(nb)
      else:
        i-=1

xxx206xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 272, 'const': 162, 'code+const': 434}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
import numpy as np
def get_score(board):
  l = len(board[0])
  b_t = board.T
  x = sum(b_t != 0)
  return (sum(x == l))*40
def get_time_cap(board, time_caps):
  b_t = board.T
  x = sum(b_t != 0)
  z = np.array(x != 0)
  y = np.arange(len(x))
  y = y[z == True]
  check = len(board)//len(time_caps)
  if len(y) == 0 :
    return time_caps[-1]
  i = min(y)//check
  return time_caps[i]
def rotate_right(shape):
  return shape[::-1].T
def rotate_left(shape):
  return shape[::,::-1].T
def animate_drop(board, shape, c):
  pass
def animate_clear(board):
  pass

xxx203xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (4,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (6,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (3,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 638, 'const': 270, 'code+const': 908}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 17)]]
import numpy as np
def get_score(board):
    r = np.min(board,1)
    t = r > 0
    result = t[t == True]
    return len(result)*40
def get_time_cap(board, time_caps):
    ma = np.max(board,1)
    t = ma > 0
    y = np.arange(len(ma))
    if len(y[t == True]) != 0:
        row = len(ma) - len(y[t == True])
        result = time_caps[int(row/2)]
        return result
    else:
        return time_caps[-1]
def rotate_right(shape):
    return (shape[::-1]).T
def rotate_left(shape):
    return ((shape).T)[::-1]
def animate_drop(board, shape, c):
    result = []
    for i in range(len(board)):
        new_board = np.array(board)
        if np.max(board[i][c:]) == 0:
             new_board[i][c:] = shape
             result.append(new_board)
    return result
def animate_clear(board):
    ma = np.min(board,1)
    y = np.arange(len(ma))
    r = y[ma != 0]
    board[r] = 0
    result = []
    if len(r) != 0:
        result.append(board)
        a = np.max(board,1)
        row_a = y[a != 0][0]
        b = np.max(board,1)
        row_b = y[b == 0][-1]
        new_board = np.array(board)
        n = 0
        while row_b > row_a:
            new_board = np.array(new_board)
            new_board[row_a+1:row_b+1] = new_board[row_a:row_b]
            new_board[n] = 0
            result.append(new_board)
            a = np.max(new_board,1)
            row_a = y[a != 0][0]
            b = np.max(new_board,1)
            row_b = y[b == 0][-1]
            n += 1
    return result

xxx206xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 884, 'const': 338, 'code+const': 1222}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('For', 15)]]
import numpy as np
def get_score(board):
    nr,nc = board.shape
    sc = np.array(np.sum(np.array(board!=0),axis=1)==nc)
    nr_not_zeros = np.sum(sc,axis=0)
    return nr_not_zeros*40
def get_time_cap(board, time_caps):
    nr,nc = board.shape
    check_first_row = np.array(np.sum(board,axis = 1) != 0)
    group_of_row = (nr//len(time_caps))
    idx = np.argmax(check_first_row,axis=0)
    if  np.sum(check_first_row) > 0 :
      return  time_caps[idx//group_of_row]
    else : 
      return time_caps[-1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    result = list()
    nr,nc = board.shape ; rs,cs = shape.shape
    new_board = np.array(board) ; copy_shape = np.zeros((nr,nc),int) 
    for r in range(nr-rs+1) :
        is_blank_on_board = np.array(new_board==0)[r:rs+r,c:cs+c]
        is_shape = np.array(shape!=0)
        compare = np.array((is_blank_on_board&is_shape)|((~ is_blank_on_board) & (~ is_shape))|(is_blank_on_board & (~ is_shape)))
        check_drop = np.min(compare)
        if check_drop :
            copy_shape[r:rs+r,c:cs+c] = shape
            result.append(copy_shape + new_board)
        if r == len(result) :
            break
        new_board = np.array(board)
        copy_shape = np.zeros((nr,nc),int)
    return result
def animate_clear(board):
    new_board = np.array(board)
    nr,nc = board.shape
    result = list()
    not_blank = np.sum(board!=0,axis=1)==nc
    countrow = np.arange(nr)[not_blank]
    new_board[countrow] = [0]*nc
    result.append(new_board)
    is_row_blank = np.sum(new_board!=0,axis=1)==0
    n_row_blank = np.arange(nr)[is_row_blank]
    copy_upper_blank_row = np.zeros((nr,nc),int)
    new_board_move = np.array(new_board)
    move = n_row_blank[::-1] + np.arange(n_row_blank.shape[0])
    for row in move:
        copy_upper_blank_row[1:row+1] = new_board_move[:row] 
        if np.min(new_board_move[:row]==0) : break
        else :
          new_board_move[:row] = np.zeros((row,nc),int)
        new_board_move += np.array( copy_upper_blank_row)
        result.append(np.array(new_board_move))
        copy_upper_blank_row = np.zeros((nr,nc),int)
    if len(result) == 1 :
      return []
    else :
      return result

xxx209xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0ValueError('zero-size array to reduction operation maximum which has no identity')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 920, 'const': 324, 'code+const': 1244}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 10)], [('While', 10)]]
import numpy as np
def get_score(board):
  col = board.shape[1]
  get = np.sum(board[::, ::] != 0, axis = 1)
  return 40*np.sum(get == col)
def get_time_cap(board, time_caps):
  if np.max(board) != 0:
    row = board.shape[0] 
    llen = len(time_caps)
    return time_caps[np.arange(row)[np.max(board, axis = 1) > 0][0]//(row//llen)]
  return time_caps[-1]
def rotate_right(shape):
  return shape[::-1,:].T
def rotate_left(shape):
  return shape[:,::-1].T
def animate_drop(board, shape, c):
  n = 0
  drop = []
  s = board.shape[0]
  p = shape.shape[0]
  d = shape.shape[1]
  new_board = np.array(board)
  new_shape = np.array(shape)
  check = np.sum(board*board)
  while n <= s-p and np.dot(new_board[np.arange(p) + n, c:c+d].reshape((1,p*d))[0], new_shape.reshape(1,p*d)[0]) == 0 and np.sum(board[:p-1,c:c+d]*shape[1-p:]) == 0:
    new_board[np.arange(p) + n, c:c+d] += shape
    drop.append(new_board)
    new_board = np.array(board)
    new_shape = np.array(shape)
    n += 1
  return drop
def animate_clear(board):
  if np.sum(np.min(board, axis = 1)) == 0:return []
  n = 0
  clear = []
  s = board.shape[0]
  new_board = np.array(board)
  new_board[np.arange(s)[np.sum(board == 0, axis = 1)] == 0] *= 0
  clear.append(new_board)
  t = np.array(new_board)
  while n < s+1 and np.max(t[np.arange(np.max(np.arange(s)[np.max(t, axis = 1) == 0]))]) != 0:
    sus = np.max(np.arange(s)[np.max(t, axis = 1) == 0])
    pup = np.zeros((sus+1,board.shape[1]),int)
    pup[1:,:] += t[np.arange(sus)]
    t[np.arange(sus+1)] = pup
    huh = np.array(t)
    clear.append(huh)
    n += 1
  return clear

xxx024xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0TypeError("argument of type 'bool' is not iterable")
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0TypeError("argument of type 'bool' is not iterable")
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (3,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 840, 'const': 350, 'code+const': 1190}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('While', 20)]]
import numpy as np
def get_score(board):
    x = board!=0
    y = np.sum(x,axis=1)
    ans = y==board.shape[1]
    return len(board[ans])*40
def get_time_cap(board, time_caps):
    y =np.sum(board,axis=1)
    number = np.arange(board.shape[0])
    x1 = y != 0
    if True not in x1 :
      return time_caps[-1]
    else:
      ans = number[x1]
      t = board.shape[0]//len(time_caps)
      return time_caps[ans[0]//t]
def rotate_right(shape):
    tr= shape.T
    ans = tr[:,-1::-1]
    return ans
def rotate_left(shape):
    tr= shape.T
    ans = tr[-1::-1,:]
    return ans
def animate_drop(board, shape, c):
    ans = []
    new_shape = np.array(shape)
    for i in range(board.shape[0]):
      k = board[i,c:] ==[0]*new_shape.shape[0]
      if False in k:
        break
      else:
        new_board = np.array(board)
        new_board[i,c:]= new_shape
        ans.append(new_board)
    return ans
def animate_clear(board):
    ans = []
    b = np.array(board)
    x =  b != 0
    y = np.sum(x,axis=1)
    change = y==b.shape[1] 
    if True not in change:
        return ans
    else:
        b[change] =np.array([0]*b.shape[1])
        same = np.array(b)
        ans.append(same)
        c = 1
        x =  0 != np.array(b[-c,:])
        n = 0
        C = np.zeros_like(b)
        while   c!= b.shape[0] :
            full = b.shape[0] 
            if True  in x:
                c += 1
            else:
                C = np.zeros_like(b)
                C[full - c : full, :] = b[full - c : full, :]
                f = b[:-c, :]
                if np.sum(f) == 0:
                    return ans
                if -c+1==0:
                    C[1:,:]= f
                else:
                    C[1 : -c + 1, :] = f
                copy = np.array(C)
                ans.append(copy)
                b = np.array(C)
            x = C[-c, :] != 0
        return ans

xxx042xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 898, 'const': 338, 'code+const': 1236}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('For', 16)]]
import numpy as np
def get_score(board):
    index = np.min(board,axis=1)
    return int(40*np.sum(index>0))
def get_time_cap(board, time_caps):
    r,c = board.shape; n=len(time_caps)
    zero = np.zeros((r,c),int)
    if np.sum(zero==board) == int(r*c):
        return time_caps[n-1]
    else:
        check = np.arange(0,int(r),r//n)
        pos_row = np.sum(board,axis=1)[::-1]
        min_pos = np.argmin(pos_row)
        if np.min(pos_row) == 0:
            pos_check = np.argmax(min_pos <= check)
        else:
            return time_caps[0]
    return time_caps[-pos_check]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    list = []
    r_b,c_b = board.shape
    r_s,c_s = shape.shape
    new_board = np.array(board)
    for e in range(r_b-(r_s-1)):
        if c_b - c < c_s:
            pass
        else:
            check_each_row = board[e:e+r_s,c:c+c_s:]
            check_tf = np.sum(check_each_row * shape)
            if check_tf == 0:
                new_board[e:e+r_s,c:c+c_s:] = shape+check_each_row
                list.append(new_board)
            else:
                break
            new_board = np.array(board)
    return list
def animate_clear(board):
    list = []
    r_b,c_b = board.shape
    new_board = np.array(board)
    zero = np.zeros((c_b),int)
    pos_1 = np.arange(0,r_b,1)
    index = np.min(board, axis=1)
    c2z = pos_1[index>0]
    if len(c2z) == 0:
        return list
    else:
        new_board[c2z] = zero
        nboard = np.array(new_board)
        list.append(new_board)
        cmin = np.max(new_board,axis=1)[::-1]
        for e in range(r_b-1):
            pos_zero = np.argmin(cmin)
            past_board = np.array(nboard)
            bboard = nboard[:-pos_zero-1:,:]
            if pos_zero != 0:
                nboard[1:-pos_zero:,:] = bboard
            else:
                nboard[1::, :] = bboard
            nboard[0,:] = np.zeros((c_b),int)
            future_board = np.array(nboard)
            if np.sum(future_board == past_board) != int(r_b*c_b):
                ab = np.array(nboard)
                list.append(ab)
            else:
                break
            cmin = np.max(nboard,axis=1)[::-1]
    return list

xxx021xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 734, 'const': 228, 'code+const': 962}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('For', 13)]]
import numpy as np
def get_score(board):
    r,c = board.shape
    a = board > 0
    b = np.sum(a,1)
    d = b == c
    e = np.sum(d)*40
    return e
def get_time_cap(board, time_caps):
    if np.sum(board) == 0:
        return time_caps[-1]
    a = board.reshape(len(time_caps),-1)
    b = np.sum(a,1)
    c = b > 0
    d = np.argmax(c)
    return time_caps[d]
def rotate_right(shape):
    a = shape.T
    b = a[:,::-1]
    return b
def rotate_left(shape):
    a = shape.T
    b = a[::-1,:]
    return b
def animate_drop(board, shape, c):
    ans = []
    r,c1 = board.shape
    l,w = shape.shape
    a = shape != 0
    for i in range(r):
        new_board = np.array(board)
        if new_board[i:i+l,c:c+w].shape == shape.shape:
            if np.sum(new_board[i:i+l,c:c+w][a]) == 0:  
                new_board[i:i+l,c:c+w] += shape
                ans.append(np.array(new_board))
    return ans
def animate_clear(board):
    a = board > 0
    r,c = board.shape
    b = np.sum(a, 1)
    new_board = np.array(board)
    new_board[b==c] = 0
    if np.sum(b==c) == 0:
        return []
    j = r-1
    ans = []
    ans.append(np.array(new_board))
    for i in range(r):
        if np.sum(new_board[j]) == 0:
            zero = np.zeros((r,c),int)
            zero[j+1:] = new_board[j+1:]
            zero[1:j+1] = new_board[:j]
            new_board = np.array(zero)
            if np.sum(ans[-1] != new_board) != 0:
                ans.append(np.array(new_board))
        else:
            j -= 1
    return ans

xxx029xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0Time-out: 5s
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 758, 'const': 356, 'code+const': 1114}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('all', 9)], []]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 12)]]
import numpy as np
def get_score(board):
    find_zero = np.min(board, axis = 1)
    zero_count = np.sum(find_zero == 0)
    score = (len(find_zero) - zero_count)*40
    return score
def get_time_cap(board, time_caps):
    max_num = np.max(board, axis = 1)
    pos = np.arange(max_num.shape[0])
    try:
      first_row = pos[max_num != 0][0]
    except:
      first_row = len(board)-1
    return time_caps[int(first_row/2)]
def rotate_right(shape):
    transpose_shape = shape.T
    rotate = transpose_shape[: , ::-1]
    return np.array(rotate)
def rotate_left(shape):
    transpose_shape = shape.T
    rotate = transpose_shape[::-1 , :]
    return np.array(rotate)
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    result_board = []
    for i in range(len(new_board) - len(new_shape)):
        new_board[i:len(new_shape)+i, c:len(new_shape[0])+c] += new_shape
        check_sum = np.sum(new_board[i:len(new_shape)+i, c:len(new_shape[0])+c], axis=1)
        if (check_sum == np.sum(new_shape, axis=1)).all():
            result_board.append(new_board)
            new_board = np.array(board)
        else:
            return result_board
    return result_board
def animate_clear(board):
    new_board = np.array(board)
    result_board = []
    if len(new_board[np.min(new_board, axis= 1) != 0]) == 0:
        return result_board
    else:
        new_board[np.min(new_board, axis= 1) != 0] *= 0
        result_board.append(new_board)
    count = 0
    new_board1 = np.array(new_board)
    while True:
        max_num = np.max(new_board1, axis = 1)
        pos = np.arange(max_num.shape[0])[max_num !=0]
        if count == len(pos):
            result_board.append(new_board1)
            count = 0
        elif pos[count] != len(new_board)-1:
            new_board1[pos[count] + 1] = new_board1[pos[count]]
            new_board1[pos[count]] *= 0 
            count += 1
        else: 
            break
    return result_board

xxx038xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 698, 'const': 338, 'code+const': 1036}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 14)]]
import numpy as np
def get_score(board):
    check = np.sum(board!=0,axis=1)
    cnt = np.sum(check==board.shape[1])
    return cnt*40
def get_time_cap(board, time_caps):
    if np.sum(board!=0) != 0 :
        arange = np.arange(board.shape[0])
        check = np.sum(board!=0 , axis=1)
        n = arange[check!=0][0]
        x = int(board.shape[0]/len(time_caps))
        return time_caps[n//x]
    return time_caps[-1]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    show = []
    number_in_board = np.sum(board!=0)
    number_in_shape = np.sum(shape!=0)
    al = number_in_board + number_in_shape
    new_shape =  np.array(shape)
    for i in range(board.shape[0]-shape.shape[0]+1) : 
        new_board = np.array(board)
        new_board[i:i+shape.shape[0] ,c:c+shape.shape[1]] += new_shape
        if np.sum(new_board!=0) == al :
            show.append(new_board)
        else :
            break
    return show
def animate_clear(board):
    show = []
    n = board.shape[1]
    check = np.sum(board!=0 ,axis=1)
    arange = np.arange(board.shape[0])
    fullrow = arange[check==board.shape[1]]
    old_board = np.array(board)
    old_board[fullrow , :] = 0
    new_board = old_board
    if str(new_board) == str(board) :
        return []   
    show.append(new_board)
    while True :
        check_row_zero = np.sum(new_board!=0 ,axis=1)
        row_zero = arange[check_row_zero==0]
        i = row_zero[-1]
        new_board = new_board[[i]+list(arange[:i])+list(arange[i+1:])]
        if str(new_board) == str(show[-1]) :
            break
        show.append(new_board)   
    return show

xxx201xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score0.0NameError("name 'get_score' is not defined")
[0, 120]
test_get_time_cap0.0NameError("name 'get_time_cap' is not defined")
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right0.0NameError("name 'np' is not defined")
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left0.0NameError("name 'np' is not defined")
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0NameError("name 'np' is not defined")
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0NameError("name 'np' is not defined")
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0NameError("name 'np' is not defined")
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0NameError("name 'np' is not defined")
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0NameError("name 'np' is not defined")
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0NameError("name 'np' is not defined")
[[]]
bytecount: {}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
# HW12_NUMPY (ไม่ลบหรือแก้ไขบรรทัดนี้ หรือเพิ่มอะไรก่อนบรรทัดนี้ โดยเด็ดขาด)
# เขียนในเซลล์นี้เท่านั้น ถ้าต้องการเขียนฟังก์ชันเพิ่ม ก็เขียนในเซลล์นี้

import numpy as np

def get_score(board):
    score = np.min(board ,axis = 1)
    point = score[score > 0 ]
    return len(point) * 40

def get_time_cap(board, time_caps):
    score = np.max(board , axis = 1)
    score = np.sum(score.reshape((len(time_caps),
                                  board.shape[0]//len(time_caps))),axis = 1)
    position = np.arange(score.shape[0])
    if len(position[score > 0])!= 0 :
        return time_caps[position[score > 0][0]]
    else :
        return time_caps[-1]
    
def rotate_right(shape):
    shape = shape.reshape(shape.shape[0],shape.shape[1])
    return shape[::-1].T

def rotate_left(shape):
    shape = shape.reshape(shape.shape[0],shape.shape[1])
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    #count_no_Zero
    Count_int = ((board.shape[0]*board.shape[1])+(shape.shape[0]*shape.shape[1]))-(np.sum(board == 0 ) - np.sum(shape == 0))
    Width_shape = shape.shape[0]
    Length_shape = shape.shape[1]
    New_drop = []
    i = 0 
    while True : #slide until break
        new_board = np.array(board)
        new_board[i:(i + Width_shape) , c:(c + Length_shape)] += shape
        #slice Broadcasting
        i += 1
        if np.sum(new_board == 0) == Count_int :
            New_drop.append(np.array(new_board))
        else : break
    return New_drop


def animate_clear(board):
    k = []
    nb = np.array(board)
    b1 = nb > 0
    r = np.sum(b1,axis = 1) == nb.shape[1] 
    nb[r,::] = 0
    k.append(nb)
    nb2 = np.array(nb)
    y = np.arange(len(board))
    n = np.sum(np.sum(nb, axis = 1) != 0)
    while True:
      if n == len(board):
        return []
      e = np.sum(nb,axis = 1)==0
      c = y[e][-1]
      if c != len(board):
        nb2[1:c+1] = nb2[0:c]
       nb2[0] = 0
    k.append(nb2)
    if np.sum(np.sum(board[-n:], axis = 1)!=0) == n: break
    return k

xxx037xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 244, 'const': 240, 'code+const': 484}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
import numpy as np
def get_score(board):
    mask = board == 0
    return np.sum(np.max(mask, axis=1) == 0) * 40
def get_time_cap(board, time_caps):
    mask = board == 0
    idx = np.sum(np.min(mask,axis=1) == 1)
    size = len(board)//len(time_caps)
    if idx//size >= len(time_caps):
        return time_caps[-1]
    return time_caps[idx//size]
def rotate_right(shape):
    s = shape.T
    return s[:,::-1]
def rotate_left(shape):
    s = shape.T
    return s[::-1]
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
    pass

xxx017xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 934, 'const': 370, 'code+const': 1304}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 9)], [('While', 40), ('While', 13)]]
import numpy as np
def get_score(board):
  TFarray = board!=0
  sum_row = np.sum(TFarray, axis=1)
  TF_sum_row = sum_row == len(board[0])
  return sum(TF_sum_row)*40
def get_time_cap(board, time_caps):
  row_b = len(board)
  row_caps = len(time_caps)
  ratio = float(row_b/row_caps)
  position = np.arange(board.shape[0])
  if (position[np.sum(board != 0,axis=1) != 0]).size > 0:
    position_want = min(position[np.sum(board != 0,axis=1) != 0])
    p_r = int(position_want/ratio)
    return time_caps[p_r]
  else :
    return time_caps[-1]
def rotate_right(shape):
  nr_shape = shape[::-1]
  return nr_shape.T
def rotate_left(shape):
  nl_shape = shape[:,::-1]
  return nl_shape.T
def animate_drop(board, shape, c):
  copy_board = np.array(board)
  list_board = []
  row_shape = len(shape)
  column_shape = len(shape[0])
  column_board = len(board[0])
  row_test = 0
  while True :
    copy_board = np.array(board)
    if len(copy_board[row_test:row_test+row_shape,c:c+column_shape]) == len(shape):
      new_board_test = copy_board[row_test:row_test+row_shape,c:c+column_shape]*shape
      axis1 = np.sum(new_board_test != 0,axis=1)
      sum_test = np.sum(axis1,axis=0)
      if sum_test ==0:
        copy_board[row_test:row_test+row_shape,c:c+column_shape] += shape
        list_board.append(copy_board)
        row_test += 1
      else:
        break
    else:
      break
  return list_board
def animate_clear(board):
  copy_board1 = np.array(board)
  list_solu = []
  TF_board = copy_board1 != 0
  TF_sum_board = np.sum(TF_board,axis=1)
  position_row = np.arange(len(copy_board1))
  clear_row = position_row[TF_sum_board==len(copy_board1[0])]
  if np.sum(clear_row,axis=0) != 0:
    copy_board1[clear_row] = 0
    copy_board3 = np.array(copy_board1)
    list_solu.append(copy_board3)
    while True:
      TF_copy_board = copy_board1 != 0
      sum_TF = np.sum(TF_copy_board,axis=1)
      position_row_zero = np.arange(len(copy_board1))
      position_want = position_row_zero[sum_TF == 0][-1]
      if np.sum(np.sum(copy_board1[0:position_want] != 0,axis=1),axis=0) != 0:
        copy_board2 = np.array(copy_board1)
        copy_board1[0:position_want] = 0
        shape = copy_board2[0:position_want]
        c = 0
        if len(animate_drop(copy_board1, shape,c)[1::]) != copy_board3.shape[0]:
          list_solu += (animate_drop(copy_board1,shape,c)[1::])
        else:
          list_solu.append((animate_drop(copy_board1, shape, c)[1::]))
        copy_board1 = animate_drop(copy_board1, shape, c)[-1]
      else: break
    return list_solu
  else:
    return list_solu

xxx038xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0Time-out: 5s
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1020, 'const': 376, 'code+const': 1396}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 14)], [('While', 23)]]
import numpy as np
def get_score(board):
  row,col = board.shape
  test1 = (board > 0)
  test2 = np.sum(test1, axis=1)
  test3 = (test2 == col)
  if np.sum(test3) > 4:
    return 4*40
  return np.sum(test3) * 40
def get_time_cap(board, time_caps):
  row,col = board.shape
  test1 = np.sum(board, axis=1)
  test2 = (test1 != 0)
  if np.sum(test2) != 0:
    range = int(row / len(time_caps))
    list_time = time_caps * range
    list_time.sort()
    time = np.array(list_time)
    test3 = time[test2]
    return test3[0]  
  return time_caps[-1]
def rotate_right(shape):
  return shape.T[:,::-1]
def rotate_left(shape):
  return shape.T[::-1,:]
def animate_drop(board, shape, c):
  row_board,col_board = board.shape
  row_shape,col_shape = shape.shape
  test1 = (board[:,:] == 0)
  test2 = (shape[:,:] != 0)
  test3 = test1[:row_shape,c:col_shape+c]
  test4 = test3 & test2
  if False in test4:
    return []
  else:
    new_board = np.array(board)
    list_board = []
    n = 0
    while False not in test4:
      con_board = np.array(new_board)
      con_board[n:row_shape+n,c:] = shape
      list_board.append(con_board)
      n += 1
      test1 = (con_board == 0)
      test3 = test1[n:row_shape+n,c:]
      test4 = test3 & test2
    return list_board
def animate_clear(board):
    if get_score(board) == 0:
      return []
    else:
      row,col = board.shape
      all_row = np.arange(row)
      test1 = (board > 0)
      test2 = np.sum(test1, axis=1)
      test3 = (test2 == col)
      valid_row = all_row[test3]
      all_zero = np.zeros((1,col))
      new_board = np.array(board)
      new_board[valid_row] = all_zero
      list_board = []
      list_board.append(new_board)
      con_board = np.array(new_board)
      n = row-1
      test5 = (con_board != 0)
      test6 = np.sum(test5, axis=1)
      test7 = np.sum(test6 > 0)
      test8 = np.sum(con_board[row-test7:,:] != 0, axis=1)
      test9 = (test8 != 0)
      while False in test9:
        if n != 0:
          test4 = (con_board == 0)
          if False not in test4[n,:] and False in test4[n-1,:]:
            con_board[n,:] = con_board[n-1,:]
            con_board[n-1,:] = np.zeros((1,col))
            n -= 1
          else:
            n -= 1
        else:
          list_board.append(con_board)
          con_board = np.array(con_board)
          test8 = np.sum(con_board[row-test7:,:] != 0, axis=1)
          test9 = (test8 != 0)
          n = row-1
      return list_board

xxx041xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 870, 'const': 324, 'code+const': 1194}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 15)]]
import numpy as np
def get_score(board):
  new_board = np.array(board)
  c=new_board.shape[1]
  y=new_board>0
  return np.sum(np.sum(y,axis=1)==c)*40
def get_time_cap(board, time_caps):
  new_board = np.array(board)
  new_time_caps=np.array(time_caps)
  r=new_board.shape[0]
  c=new_board.shape[1]
  y=int(r/len(new_time_caps))
  tot=np.sum(new_board,axis=1)
  a=np.arange(r)
  a2=a[tot>0]
  if len(a2)==0:
    return new_time_caps[-1]
  return new_time_caps[a2[0]//y]
def rotate_right(shape):
  new_shape = np.array(shape)
  return new_shape.T[:,::-1]
def rotate_left(shape):
  new_shape = np.array(shape)
  y=rotate_right(new_shape)
  return y[::-1,::-1]
def animate_drop(board, shape, c):
  b1 = np.array(board) ;b2 = np.array(board)
  ns= np.array(shape)
  rns=ns.shape[0] ; cns=ns.shape[1]
  x=[]
  for i in range(board.shape[0]-rns+1):
    if np.sum((b2[i:rns+i,c:c+cns]==0)&(ns!=0)==(ns!=0))==rns*cns:
        b1[i:rns+i,c:c+cns]+=ns
        x.append(b1)
        b1=np.array(board)
    else: break    
  return x
def animate_clear(board):
  b1= np.array(board) ; b2=np.array(board)
  bul=np.sum(b2!=0,axis=1)==b2.shape[1]
  b1[bul]=0 ; b3=np.array(b1) 
  nz=np.sum(np.sum(b1,axis=1)==0)
  rbo=board.shape[0]
  cbo=board.shape[1]
  if 0 not in np.sum(b2,axis=1):
    return []
  x=[]
  x.append(b3)
  i=rbo-1
  j=0
  while np.sum(b1[:nz,:])!=0:
      if np.sum(b1[i])==0:
          b1[1:i+1,:]=b1[0:i,:]
          b1[0]=np.zeros(cbo,int)
          bj=np.array(b1)
          x.append(bj)
          i+=1
      i-=1    
  return x

xxx201xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 824, 'const': 338, 'code+const': 1162}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 6)], [('While', 11)]]
import numpy as np
def get_score(board):
    return (((board==0).sum(axis=1))==0).sum()*40
def get_time_cap(board, time_caps):
    if np.sum(board)==0:
        return time_caps[-1]
    n=board.shape[0]//len(time_caps)
    sumlr=board.sum(axis=1)
    hl=(sumlr!=0).sum()
    if hl%n!=0:
        i=hl//n
    else:
        i=(hl//n)-1
    return time_caps[::-1][i]
def rotate_right(shape):
    return shape[::-1, :].T
def rotate_left(shape):
    return shape[:, ::-1].T
def animate_drop(board, shape, c):
    out=[]
    i=0
    sp=board[i:i+shape.shape[0], c:c+shape.shape[1]]!=0
    sh=shape!=0
    while np.sum(sp&sh)==0:
        b=np.array(board)
        b[i:i+shape.shape[0], c:c+shape.shape[1]]+=shape
        out.append(b)
        i+=1
        if i == board.shape[0]-shape.shape[0]+1:
            break
        sp=board[i:i+shape.shape[0], c:c+shape.shape[1]]!=0
    return out
def animate_clear(board):
    out=[]
    if get_score(board)==0:
        return out
    clear=((board!=0).sum(axis=1))==board.shape[1]
    new_board = np.array(board)
    new_board[clear]=np.zeros(board.shape[1])
    out.append(np.array(new_board))
    st=((new_board!=0).sum(axis=1))!=0
    row_left=np.sum(st)
    while np.sum(st[-1:-row_left-1:-1])!=row_left:
        i=new_board.shape[0]-1-(np.argmin(st[::-1]))
        move=np.array(new_board)[0:i, :]
        new_board[0, :]=np.zeros((new_board.shape[1]), int)
        new_board[1:1+move.shape[0], :]=move
        out.append(np.array(new_board))
        st=((new_board!=0).sum(axis=1))!=0
    return out

xxx207xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0ValueError('could not broadcast input array from shape (2,4) into shape (1,4)')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0IndexError('list index out of range')
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1082, 'const': 242, 'code+const': 1324}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [], [('invert', 8), ('all', 35)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep:
   [[], [], [], [], [('While', 8)], [('For', 10), ('For', 26), ('While', 44), ('ListComp', 35), ('For', 28), ('For', 31)]]
import numpy as np
def get_score(board):
  check_board = board > 0
  sum_check_board = np.sum(check_board,1)
  all_pos = np.arange(board.shape[0])
  check_pos = sum_check_board == board.shape[1]
  pos = all_pos[check_pos]
  return (board[pos].shape[0]) * 40
def get_time_cap(board, time_caps):
  check_rows = np.sum(board,1) > 0
  if np.sum(check_rows) == 0 :
    return time_caps[-1]
  all_pos = np.arange(board.shape[0])
  all_pos_rows = all_pos[check_rows]
  pos_row = all_pos_rows[0]
  return time_caps[int(pos_row/(board.shape[0]/len(time_caps)))]
def rotate_right(shape):
  return shape.T[::,::-1]
def rotate_left(shape):
  return shape.T[::-1]
def animate_drop(board, shape, c):
  drop_order = []
  if np.sum(board[:shape.shape[0]:,c:c+shape.shape[1]:] != 0) != 0 :
    return drop_order
  new_board = np.array(board)
  first_row_shape = 0
  while np.sum(board[first_row_shape:first_row_shape+shape.shape[0],c:c+shape.shape[1]] != 0) == 0 :
    new_board[first_row_shape:first_row_shape+shape.shape[0],c:c+shape.shape[1]] = shape
    drop_order.append(new_board)
    new_board = np.array(board)
    first_row_shape += 1
    if first_row_shape+shape.shape[0] > board.shape[0] : break
  return drop_order
def animate_clear(board):
  clear_order = []
  new_board = np.array(board)
  check_pos = np.sum(new_board > 0, 1) != board.shape[1]
  new_board = new_board * (check_pos*1).reshape(check_pos.shape[0],1)
  clear_order.append(new_board)
  pos_rows = np.arange(check_pos.shape[0])[np.invert(check_pos)]
  drop_order = []
  for row in pos_rows[::-1] : 
    if row != 0 :
      if row == pos_rows[-1] :
        new_shape = new_board[:row].reshape(row,board.shape[1])
        board_for_drop = np.array(new_board)
        board_for_drop[:row] = np.zeros_like(board_for_drop[:row],int)
        lis_drop = animate_drop(board_for_drop, new_shape, 0)
        drop_order.append(lis_drop)
        last_drop = lis_drop[-1]
      else :
        new_shape = new_board[:row].reshape(row,board.shape[1])
        pos_last_drop = (np.arange(board.shape[0])[np.sum(last_drop > 0,1) == 0])[-1]
        board_for_drop = last_drop[pos_last_drop:]
        lis_drop = animate_drop(board_for_drop, new_shape, 0)
        drop_order.append(lis_drop)
        last_drop = lis_drop[-1]
  for i in range(len(drop_order)) :
    if i == 0 :
      for j in range(1,len(drop_order[i])) :
        clear_order.append(drop_order[i][j])
    else :
      for array in drop_order[i] :
        outcome_board = np.zeros_like(board,int)
        outcome_board[board.shape[0]-array.shape[0]:] = array
        clear_order.append(outcome_board)
  clear_outcome = [ e for e in clear_order if not (e == board).all()]
  return clear_outcome

xxx020xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1024, 'const': 358, 'code+const': 1382}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 19)], [('For', 19)]]
import numpy as np
def get_score(board):
    zeros = np.zeros(board.shape,int)
    ncols = board.shape[1]
    sumTrue = np.sum(zeros != board, axis = 1)
    return sum(sumTrue == ncols)*40
def get_time_cap(board, time_caps):
    if np.sum(board) == 0: return time_caps[-1]
    else:
        nrows = board.shape[0]
        sumRow = np.sum(board, axis = 1)
        indices = np.arange(nrows)
        i = indices[sumRow != 0][0] 
        s = nrows//len(time_caps)
        return time_caps[i//s]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    new_board = np.array(board) 
    new_shape = np.array(shape)
    w = new_shape.shape[1]; h = new_shape.shape[0]
    rowPos = np.arange(h)
    shape_value = new_shape != 0
    sumTrue = np.sum(new_shape != 0, axis = 1)
    numRowPos = rowPos[sumTrue == w]
    out = []
    if numRowPos.shape[0] > 0:
        rowForBroadcasting = new_shape[numRowPos[0]]
        sumRow = np.sum(new_board[0:h,c:c+w] + rowForBroadcasting, axis = 1)
        notEqualPos = rowPos[sumRow != np.sum(rowForBroadcasting)]
        if notEqualPos.shape[0] > 0 and notEqualPos[0] < h-1: return out
    valid_start = (new_board[0:h,c:c+w] == 0) &  shape_value ==  shape_value
    if np.sum(valid_start) != w*h: 
        return out
    for i in range(new_board.shape[0]):
        new_board = np.array(board) 
        board_slice = new_board[i:i+h,c:c+w]
        if board_slice.shape[0] != h: break 
        board_value = board_slice == 0
        valid = board_value & shape_value == shape_value
        if np.sum(valid) != w*h: return out
        board_slice[shape_value] = new_shape[shape_value][0]
        out.append(np.array(new_board))
    return out
def animate_clear(board):
    new_board = np.array(board)
    nrows = new_board.shape[0]
    ncols = new_board.shape[1]
    sumTrue = np.sum(board != 0, axis = 1)
    indices = np.arange(nrows)
    numRowPos = indices[sumTrue == ncols]
    out = []
    if numRowPos.shape[0] == 0: return out
    new_board[numRowPos,:] = 0
    out.append(np.array(new_board))
    sumRow = np.sum(new_board, axis = 1)
    a = indices[sumRow != 0]
    if a.shape[0] == 0: return out
    firstRowNoZero = indices[sumRow != 0][0] 
    sumZero = np.sum(new_board == 0, axis = 1) 
    zeroPos = indices[sumZero == ncols][::-1]
    for i in range(zeroPos.shape[0] - firstRowNoZero):
        new_board[1:zeroPos[i]+1] = new_board[0:zeroPos[i]]
        new_board[0] = 0
        out.append(np.array(new_board))
        zeroPos += 1
    return out

xxx026xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[array([[0, 2, 0, 0],
       [2, 2, 2, 0],
       [1, 1, 0, 0]])],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 634, 'const': 356, 'code+const': 990}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 10)], []]
import numpy as np
def get_score(board):
    return sum(np.min(board,axis=1)>0)*40
def get_time_cap(board, time_caps):
    a = np.max(board,axis=1)
    if len(a)%len(time_caps)!=0:
        return time_caps[-1]
    b = a.reshape((len(time_caps),len(a)//len(time_caps)))
    c = np.max(b,axis=1)
    if np.max(c)==0:
        return time_caps[-1]
    idx = np.argmax((c!=0))
    return time_caps[idx]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    ans = []
    b = np.array(board)
    s = np.array(shape)
    word_l = s.shape[1]
    board_l = b.shape[1]
    if c > board_l-word_l:
        return ans
    for i in range(b.shape[0]):
        if np.sum(np.sum(np.array(b[i:i+s.shape[0],c:c+word_l])==0,axis=1)==word_l) == s.shape[0]:
            b[i:i+s.shape[0],c:c+word_l] += s[:s.shape[0],:]
            ans.append(b)
            b = np.array(board)
        else:
            break
    return ans
def animate_clear(board):
    new_board = np.array(board)
    new_board[np.min(board,axis=1)!=0,:]=0
    pos = np.arange(board.shape[0])
    remain = np.sum(np.sum(new_board,axis=1)!=0)
    ans = []
    ans.append(np.array(new_board))
    return ans

xxx020xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (3,6)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0IndexError('index -1 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1190, 'const': 384, 'code+const': 1574}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 15)], [('While', 27)]]
import numpy as np
def get_score(board):
    score = 0
    b = np.min(board, axis=1)
    a = b[b>0]
    n = len(a)
    score += 40*n
    return score
def get_time_cap(board, time_caps):
    lb = len(board)
    lt = len(time_caps)
    chuang = int(lb/lt)
    b = np.max(board, axis=1)
    a = b[b==0]
    n = len(a)
    if n == lb :
        return time_caps[-1]
    else :
        x = n//chuang
        return time_caps[x]
def rotate_right(shape):
    a = shape[::-1]
    k = a.T
    return np.array(k)
def rotate_left(shape):
    a = shape.T
    b = a[::-1]
    return np.array(b)
def animate_drop(board, shape, c):
    tang = len(board[0]) - len(shape[0])
    if c <= tang :
        ans = []
        new_board = np.array(board)
        new_shape = np.array(shape)
        role = new_board[:,c::]
        x = np.max(role, axis=1)
        yns = new_shape.shape[0]
        xns = new_shape.shape[1]
        k = c + xns
        hole = new_board[:,c:k]
        xh = np.max(hole,axis=1)
        for i in range(len(hole)) :
            new_board = np.array(board)
            chong = xh[i:i+len(new_shape)]
            chongT = chong[chong==0]
            if len(chong) == len(chongT) :
                new_board[i:i+len(new_shape),c::] = new_shape
                ans.append(new_board)
        return ans
    else :
        return []
def animate_clear(board):
    new_board = np.array(board)
    nb = np.array(board)
    y = new_board.shape[0]
    x = new_board.shape[1]
    bb = np.max(new_board,axis=1)
    rgb = np.max(new_board, axis=1)
    dee = np.min(new_board,axis=1)
    dee0 = dee[dee==0]
    dee1 = dee[dee!=0]
    if len(dee0) == len(dee) :
        return []
    else :
        bb[dee>0] = 0
        rgb[dee > 0] = 0
        ch = bb[:-1]
        new_board[bb==0] = np.zeros((1,x))
        nb[bb==0] = np.zeros((1,x))
        nn = np.array(new_board)
        a = True
        ans = []
        sec = bb
        zz = 0
        k = 0
        ans.append(nb)
        while a :
            if ch[-1] == 0 :
                ch = ch[:-1]
                oo = len(ch)
                o2 = oo
                chu = ch
            else :
                oo = len(ch)
                o2 = oo
                chu = ch
                nb1 = np.array(nn)
                if (zz + oo) < len(bb) :
                    if bb[zz + oo] == 0 :
                        new_board[zz:zz + oo] = np.zeros((1, x))
                        rgb[zz:zz + oo] = 0
                        zz = zz + 1
                        new_board[zz:zz + oo] = np.array((nb1[:o2]))
                        rgb[zz:zz + oo] = ch
                        bb = rgb
                        kkk = np.array(new_board)
                        ans.append(kkk)
                    else:
                        if 0 in ch and len(ch) != 0 :
                            ch = ch[:-1]
                            k += 1
                        else :
                            return ans
                else :
                    if 0 in ch and len(ch) != 0 :
                        ch = ch[:-1]
                        k += 1
                        if ch == [0] :
                            return ans
                    else :
                        return ans

xxx026xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0ValueError('zero-size array to reduction operation minimum which has no identity')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1094, 'const': 398, 'code+const': 1492}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 23)], [('While', 12)]]
import numpy as np
def get_score(board):
    a = np.min(board, axis=1)  
    return len(a[a != 0]) * 40
def get_time_cap(board, time_caps):
    len_time = len(time_caps)
    b = np.max(board, axis=1)          
    check = np.arange(board.shape[0]) 
    pos = check[b != 0]
    if pos.shape == (0,):
        return time_caps[-1]
    return time_caps[int(pos[0])//(board.shape[0]//len_time)]
def rotate_right(shape):
    c = shape[::-1, :: ]
    return c.T
def rotate_left(shape):
    d = shape.T
    return d[::-1, ::]
def animate_drop(board, shape, c):
    new_b = np.array(board)
    new_s = np.array(shape)
    s0, s1 = shape.shape
    ans = []
    f = np.arange(s0*s1).reshape(s0, s1)
    check = board[0:0+s0, c:c+s1]                             
    pos_num_shape = f[shape != 0]                            
    can_place_pos, number_pos = f[check == 0], f[check != 0] 
    pos_cant_place = np.array([])
    if len(number_pos) != 0:
        if len(check) - 1 - np.min(number_pos // 3) == 2:
            h1 = number_pos + (np.ones_like(number_pos, int) * check.shape[1])
            h2 = number_pos + (np.ones_like(number_pos, int) * check.shape[1] *2)
            pos_cant_place = np.array(list(h1) + list(h2))
        elif len(check) - 1 - np.min(number_pos // 3) == 1:
            pos_cant_place = number_pos + (np.ones_like(number_pos, int) * check.shape[1])               
    if set(pos_cant_place) & set(pos_num_shape) != set():
        return []
    daimai = set(pos_num_shape) - set(can_place_pos)
    if daimai != set():
        return []
    for i in range(board.shape[0] - s0 + 1): 
        new_b = np.array(board)
        check = board[i:i+s0, c:c+s1]
        can_place_pos = f[check == 0]
        daimai = set(pos_num_shape) - set(can_place_pos)
        if daimai == set():                    
            new_b[i:i+s0, c:c+s1] += new_s                    
            ans.append(new_b)
        else:
            break
    return ans
def animate_clear(board):
    ans = []
    nb = np.array(board)
    x = np.min(nb, axis=1)
    tf_x = (x != 0)
    if True not in tf_x:
        return ans
    tf = (x == 0)  
    zero_b = nb * tf.reshape(len(board),1) 
    y = np.array(zero_b)
    ans.append(y)
    while True:
        max_y = np.max(y, axis=1)
        w = np.arange(len(board))
        w2 = w[max_y == 0]
        lowest_o = int(np.max(w2))
        v = np.arange(len(board)) 
        v2 = v[max_y != 0]
        highest_no_o = int(np.min(v2))
        m = list(y)
        y = m[0:lowest_o] + m[lowest_o+1:]
        y.insert(0, np.zeros_like(board[0],int))
        if lowest_o < highest_no_o:
            break        
        ans.append(np.array(y))
    return ans

xxx210xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[None56, None56, None56, None56, None45, None45, None45]
test_rotate_right0.0
[array([[10, 01],
       [20, 02],
       [35, 53],
       [40, 04]]),
 array([[01, 10],
       [02, 20],
       [53, 35],
       [04, 40]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 210, 'const': 122, 'code+const': 332}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [('transpose', 2)], [('transpose', 2)], [], []]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[('For', 4), ('For', 6)], [], [], [], [], []]
import numpy as np
def get_score(board):
  Z=[]
  SC=0
  for i in board :
    Z=[]
    for a in i:
      Z.append(a)
    if 0 not in Z :
      SC +=1
    else :
      SC +=0
  get_score_final = SC*40
  return(int(get_score_final))
def get_time_cap(board, time_caps):
    pass
def rotate_right(shape):
  return(np.transpose(shape))
def rotate_left(shape):
  return(np.transpose(shape[:,::-1]))
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
    pass

xxx141xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[array([[2, 0, 0, 0],
       [1, 0, 1, 1]])],
 [array([[0, 2, 0, 0],
       [1, 0, 1, 1]]), array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 0, 0, 5, 0, 0, 0],
       [0, 1, 1, 0, 0, 0, 0, 0],
       [0, 2, 2, 2, 0, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]]),
  array([[0, 1, 0, 5, 5, 0, 0, 0],
       [0, 1, 1, 0, 5, 0, 0, 0],
       [0, 2, 2, 2, 0, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]]),
  array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[0, 0, 2, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 0, 0, 2, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 2, 2, 2, 0, 0 ... (more)
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 2, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 0, 0, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 25, 25, 4]])],
  [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1278, 'const': 438, 'code+const': 1716}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 12)]]
import numpy as np
def get_score(board):
    return (sum(np.sum((board[:,:] != 0)[:],axis=1)==board.shape[1]))*40
def get_time_cap(board, time_caps):
    b = np.sum(board.reshape((len(time_caps),board.shape[1]*int(board.shape[0]/len(time_caps))))[:,:] != 0,axis=1) != 0
    if sum(b[:]) == 0 :
        return time_caps[-1]
    else :
        return np.array(time_caps)[b][0]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    new_board = np.array(board) != 0
    new_shape = np.array(shape) != 0
    new_shape1 = np.zeros((shape.shape[0],shape.shape[1]+1), int)
    new_shape1[:,1:] = np.array(shape)
    z = []
    for i in range(board.shape[0]) :
        if i-new_shape.shape[0] < 0 :
            b = None
        else :
            b = i-new_shape.shape[0]
        a = (new_board[i:b:-1,c:c+new_shape.shape[1]] != new_shape[-1:-(i+2):-1]) | (new_board[i:b:-1,c:c+new_shape.shape[1]] == 0)
        if sum(np.sum(a, axis=1)) != a.shape[0]*a.shape[1] :
            break
        else :
            new_board1 = np.zeros((board.shape[0],board.shape[1]+1), int)
            new_board1[:,1:] = np.array(board)              
            if i-new_shape.shape[0] < 0 :
                b = None
                d = new_shape1.shape[0]-i-1
            else :
                b = i-new_shape1.shape[0]+1
                d = None
            new_board1[b:i+1,c:c+new_shape1.shape[1]] = np.array(new_shape1)[d:,:] | new_board1[b:i+1,c:c+new_shape1.shape[1]]
        z.append(np.array(new_board1[:,1:]))
    return z
def animate_clear(board):
    i = 0
    j = 0
    k = 0
    z = []
    ch = True
    new_board = np.array(board) != 0
    new_board1  = np.array(board)
    a = np.sum(new_board, axis=1) == new_board.shape[1]
    if sum(a) == 0 :
        return z
    while True :
        if i < a.shape[0] :
            if a[i:i+1] == True :
                new_board1[i:i+1] = np.zeros((1,new_board1.shape[1]), int)
            i+=1
        else :
            if ch == True :
                z.append(np.array(new_board1))
                ch = False
            if j < new_board1.shape[0] :
                new_board2 = np.array(new_board1)[::-1] != 0
                if np.sum(new_board2, axis=1)[j:j+1] == 0 :
                    new_board1[-j-1:0:-1] = new_board1[-j-2::-1]
                    new_board1[0:1] = np.zeros((1,new_board1.shape[1]), int)
                    z.append(np.array(new_board1))
                    j = -1
                    k += 1
                j+=1
            if k >= new_board1.shape[0]-np.sum(np.sum(np.array(new_board1)!= 0, axis=1)==0) :
                break
    return z

xxx018xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1206, 'const': 398, 'code+const': 1604}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('For', 23)]]
import numpy as np
def get_score(board):
  tile = np.zeros((board.shape[0] , board.shape[1]),int)
  bulean2 = (tile[:] == board[:])
  su_bu = np.sum(bulean2 , axis = 1)
  score = np.sum([su_bu == 0])*40
  return score
def get_time_cap(board, time_caps):
  seperated = (board.shape[0])//len(time_caps)
  bu2 = np.sum(board , axis =1)
  line_no_zero = np.arange(0,len(bu2))[bu2 != 0]
  if len(line_no_zero) != 0:
      position = int(line_no_zero[0])//seperated
  else:
      position = len(time_caps)-1
  time =  time_caps[position]
  return time
def rotate_right(shape):
  shape_ = np.array(shape)
  T_sh = shape_.T
  rot_right = T_sh[::1 , ::-1]
  return np.array(rot_right)
def rotate_left(shape):
  shape_ = np.array(shape)
  T_sh = shape_.T
  rot_left = T_sh[::-1 , ::1]
  return np.array(rot_left)
def animate_drop(board, shape, c):
    animate_r = []
    for i in range(len(board)): 
        new_board = np.array(board)
        new_shape = np.array(shape)
        rows0 = new_shape.shape[0] ; cols0 = c
        g = new_board[i:i+rows0 , cols0:cols0+new_shape.shape[1]]
        if ((g.shape[0] == new_shape.shape[0]) and (g.shape[1] == new_shape.shape[1]))==True:            
            g2 = np.array(g)
            find_space = [(new_shape>=0) & (g != 0)]
            true_ = np.sum(find_space , axis = 1)
            true_2 = np.sum(true_ ,axis = 1)
            if true_2[0] != 0:
                break
            else:
                after_fix = g + new_shape
                new_board[i:i+rows0 , cols0:cols0+new_shape.shape[1]] = after_fix
                animate_r.append(new_board)
        else:
            break
    return animate_r
def animate_clear(board):
    ani_clear = []
    new_board = np.array(board)
    bu_board = [new_board==0]
    bu2 = np.array(np.sum(bu_board , axis=0))
    f_bu = np.sum(bu2 , axis = 1)
    line_no_zeros = np.arange(0,len(f_bu))[f_bu == 0]
    if len(line_no_zeros) == 0:
        ani_clear = []
    else:
        new_board2 = np.array(new_board)
        new_board2[line_no_zeros] = [0]*new_board.shape[1]
        ggg = np.array(new_board2)
        ani_clear.append(ggg)
        bu_n_board2 = [new_board2!=0]
        bu2_2 = np.array(np.sum(bu_n_board2, axis=0))
        f_bu2 = np.sum(bu2_2 , axis = 1)
        line_with_nums = np.arange(0,len(f_bu))[f_bu2 != 0]
        n_ = (new_board.shape[0]-1-line_with_nums[0]) - len(line_with_nums[line_with_nums > line_with_nums[0]])
        for i in range(n_):
            new_b3 = np.array(new_board2)
            bu_c0 = np.array(np.sum([new_b3==0] , axis=0))
            f_bu0 = np.sum(bu_c0 , axis = 1)
            line_all_zeros = np.arange(0,len(f_bu))[f_bu0 == new_board.shape[1]]
            po_cut_line = line_all_zeros[-1]
            bu_n_c2= [new_b3!=0]
            bu2_c2 = np.array(np.sum(bu_n_c2, axis=0))
            f_buc2 = np.sum(bu2_c2 , axis = 1)
            line_with_nums = np.arange(0,len(f_buc2))[f_buc2 != 0]
            start_cut_po = line_with_nums[0]
            if start_cut_po < po_cut_line:
                new_board2[line_with_nums[0]+1:(po_cut_line)+1] = new_b3[line_with_nums[0]:po_cut_line]
                new_board2[line_with_nums[0]] = [0]*new_b3.shape[1]
                gg = np.array(new_board2)
                ani_clear.append(gg)
            else:
                break
    return ani_clear

xxx201xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score0.0
[40, 4120]
test_get_time_cap0.0
[56, 56, 56, 56, 45, 45, 45, 56]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 904, 'const': 394, 'code+const': 1298}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('For', 16)]]
import numpy as np
def get_score(board):
  x =  board != 0
  z =np.sum(x, axis = 1)
  return (np.sum(z == 5))*40
def get_time_cap(board, time_caps) :
  ni = board != 0
  if True not in ni  :
    return time_caps[-1]
  else :
    new_board = np.array(board)
    n = len(board) / len(time_caps)
    x = np.sum(new_board,axis = 1)
    z = np.arange(1,board.shape[0]+1)
    z = (z[x != 0])
    i = np.min(z)
    ans =( i/ n) + 0.1
    ans = round(ans, 0)
    ans = int(ans) 
    return time_caps[ans-1]
def rotate_right(shape):
  return shape[::-1].T
def rotate_left(shape):
  return (shape.T)[::-1]
def animate_drop(board, shape, c):
  ans = []
  n = np.max(shape)
  if shape.shape[1]  <= len(board[0,c:])    :
    for i in range(len(board)) :
      if shape.shape[0] + i <= len(board) :
        new_board = np.array(board)
        bool_1 = shape == n
        bool_2 = new_board[i:shape.shape[0]+i,c:c+shape.shape[1]] + shape == n
        z = bool_1 & bool_2
        z = bool_1 == z
        if False not in z :
          new_board[i:shape.shape[0]+i,c:c+shape.shape[1]] += shape
          ans.append(new_board)
        else :
            break
    return ans
  else :
   return []
def animate_clear(board):
  ans = []
  new_board = np.array(board)
  d0,d1 = new_board.shape
  min1 = np.min(board,axis = 1)
  bool_min1 = min1 != 0
  new_board[bool_min1,:] = 0
  num = np.arange(new_board.shape[0])
  nd0 = np.zeros((d0,d1),int)
  x1 = new_board != 0
  z = np.sum(x1,axis = 1)
  z1 = z == 0
  if np.sum(z1,axis = 0) != 0  :
      ans.append(np.array(new_board))
  for i in range(len(new_board)) :
      bool1 = np.max(new_board,axis = 1) == 0
      k = num[bool1]
      if  len(k) > 0 :
          a = k[-1]
          new_board[i+1:a+1,:] = new_board[i:a,:]
          new_board[i] = nd0 = np.zeros((d0,d1),int)[i]                         
          if list(np.arange(a+1)) == list(k) :
              break
          else :
              ans.append(np.array(new_board))
  return ans

xxx039xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 912, 'const': 338, 'code+const': 1250}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 10)], [('For', 13)]]
import numpy as np
def get_score(board):
    min_each_row = (board.min(axis = 1) != 0)
    scored_row = board[min_each_row]
    score = int(scored_row.shape[0]) * 40
    return score
def get_time_cap(board, time_caps):
    bool_index = board.max(axis = 1) != 0
    if np.sum(bool_index) == 0:
      return time_caps[-1]
    else:
      index = np.arange(len(bool_index))[bool_index]
      first_row = index[0]
      return time_caps[first_row//(board.shape[0]//len(time_caps))]
def rotate_right(shape):
    shape = shape.T
    return shape[: , -1::-1]
def rotate_left(shape):
    shape = shape.T
    return shape[-1::-1, :]
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    temp_board = np.array(board)
    index = new_shape != 0
    result = []
    i = 0
    if temp_board[i,c:c+new_shape.shape[1]].max() == 0:
      while len(temp_board[i:i+new_shape.shape[0], c:c+new_shape.shape[1]] * index) != 0 :
          if (temp_board[i:i+new_shape.shape[0], c:c+new_shape.shape[1]] * index).max() == 0:
              zeros = np.zeros_like(new_board, int)
              zeros[i:i+new_shape.shape[0], c:c+new_shape.shape[1]] = new_shape
              new_board += zeros
              result.append(new_board)
              new_board = np.array(board)
          else:
              break
          if i+new_shape.shape[0] == new_board.shape[0]:
              break
          i+=1  
    return result
def animate_clear(board):
    new_board = np.array(board)
    full_row = (new_board.min(axis=1) != 0) & (new_board.max(axis=1) != 0)
    if np.sum(full_row) != 0:
      index = np.arange(new_board.shape[0])
      index = index[full_row]
      new_board[index] = new_board[index] * 0
      result = []
      result.append(new_board)
      row_index = new_board.sum(axis=1) == 0
      start = 0
      for i in range(new_board.shape[0]-1, -1, -1):
        temp_board = np.zeros_like(new_board, int)
        if row_index[i]:
          if i != 0:
              if row_index[0:i].min() == 0:
                  temp_board[start+1:i+1+start] = new_board[start:i+start]
                  temp_board[i+1+start:] = new_board[i+start+1:]
                  new_board = np.array(temp_board)
                  result.append(new_board)
                  start += 1
      return result
    else:
      return []

xxx021xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 940, 'const': 388, 'code+const': 1328}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 14)]]
import numpy as np
def get_score(board):
    return np.sum(full_rows(board) * 40)
def get_time_cap(board, time_caps):
    nonzero = np.sum(board != 0, 1)
    if np.sum(nonzero) == 0:
        return time_caps[-1]
    else:
        return time_caps[np.argmax(nonzero > 0) // (board.shape[0] // len(time_caps))]
def rotate_right(shape):
    if shape.shape[0] == 1:
        return shape.reshape((shape.shape[1], 1))
    return shape.T[:, ::-1]
def rotate_left(shape):
    if shape.shape[0] == 1:
        return shape.reshape((shape.shape[1], 1))[::-1]
    return shape.T[::-1, :]
def placeable(shape, board, r, c):
    x = np.zeros_like(board)
    x[r : r + shape.shape[0], c : c + shape.shape[1]] = shape != 0
    return np.sum(x * board) == 0
def animate_drop(board, shape, c):
    l = []
    for r in range(1 - shape.shape[0], board.shape[0] - shape.shape[0] + 1):
        if r < 0 and not placeable(shape[-r:, :], board, 0, c):
            break
        if r >= 0:
            if not placeable(shape, board, r, c):
                break
            new_board = np.array(board)
            new_board[r : r + shape.shape[0], c : c + shape.shape[1]] += shape
            l.append(new_board)
    return l
def full_rows(board):
    x = np.sum(board == 0, 1)
    return x == 0
def empty_rows(board):
    x = np.sum(board != 0, 1)
    return x == 0
def remove_row(arr, r):
    x = np.zeros_like(arr)
    rows = np.ones(arr.shape[0], bool)
    rows[r] = False
    x[1:, :] = arr[rows, :]
    return x
def animate_clear(board):
    full = full_rows(board)
    if np.sum(full) == 0:
        return []
    l = []
    new_board = np.array(board)
    new_board[full, :] = 0
    l.append(new_board)
    if np.sum(new_board) == 0:
        return l
    empty = empty_rows(new_board)
    cnt_non_empty = board.shape[0] - np.sum(empty)
    while np.sum(empty[-cnt_non_empty:]) != 0:
        row_removing = np.max(np.arange(board.shape[0])[empty])
        new_board = remove_row(new_board, row_removing)
        l.append(new_board)
        empty = empty_rows(new_board)
    return l

xxx027xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0., 1.],
       [0., 2.],
       [5., 3.],
       [0., 4.]]),
 array([[1., 0.],
       [2., 0.],
       [3., 5.],
       [4., 0.]])]
test_rotate_left1.0
[array([[4., 0.],
       [3., 5.],
       [2., 0.],
       [1., 0.]]),
 array([[0., 4.],
       [5., 3.],
       [0., 2.],
       [0., 1.]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0., 0., 0., 0.],
       [0., 5., 5., 4.],
       [1., 0., 5., 4.],
       [1., 0., 2., 4.]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0., 0., 0., 0.],
       [0., 5., 5., 4.],
       [0., 0., 0., 0.],
       [0., 0., 0., 0.]]),
  array([[0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 5., 5., 4.],
       [0., 0., 0., 0.]]),
  array([[0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 5., 5., 4.]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0., 0., 0., 0.],
       [1., 2., 0., 0.],
       [0., 0., 0., 0.],
       [1., 0., 2., 4.],
       [0., 0., 0., 0.],
       [0., 0., 1., 1.]]),
  array([[0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [1., 2., 0., 0.],
       [0., 0., 0., 0.],
       [1., 0., 2., 4.],
       [0., 0., 1., 1.]]),
  array([[0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [1., 2., 0., 0.],
       [1., 0., 2., 4.],
       [0., 0., 1., 1.]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 934, 'const': 403, 'code+const': 1337}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [], [('any', 14)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('While', 9)]]
import numpy as np
def get_score(board):
    arg_min = np.argmin(board, axis=1)
    equalZero = np.sum(board[np.arange(board.shape[0]),arg_min] == 0)
    score = (board.shape[0] - equalZero)*40
    return score
def get_time_cap(board, time_caps):
    sum_row = np.sum(board,axis=1)
    zero_row = np.sum((sum_row == 0))
    if zero_row == board.shape[0]: return time_caps[-1]
    return time_caps[int(zero_row/(board.shape[0] / len(time_caps)))]
def rotate_right(shape):
    new = np.ndarray((shape.shape[1],shape.shape[0]))
    new[:,:] = shape.T[:,::-1]
    return new
def rotate_left(shape):
    new = np.ndarray((shape.shape[1],shape.shape[0]))
    new[:,:] = shape.T[::-1,:]
    return new
def animate_drop(board, shape, c):
    animation = []
    zero_cnt= np.sum(board==0)
    for row in range(0, board.shape[0]- shape.shape[0]) :
        new_board = np.array(board)
        new_board[row:row+shape.shape[0], c:c+shape.shape[1]] += shape
        if np.sum(new_board==0) != (zero_cnt - np.sum(shape!=0)) : continue 
        animation.append(new_board)
    return animation
def animate_clear(board):
    new_board = np.array(board)
    if(np.sum(np.min(board, axis=1)!=0)==0): return []
    animation = []
    new_board[np.min(new_board, axis=1)!=0] = np.array([0])
    animation.append(np.array(new_board))
    live, now = 0, board.shape[0]-1
    while(live!=now) :
      free = np.zeros(board.shape)
      free[now:board.shape[0],:] = new_board[now:board.shape[0],:]
      free[1:now+1,:] += new_board[0:now,:]
      if np.sum(free == 0) == np.sum(new_board==0) and (free != new_board).any():
        animation.append(free)
        new_board = np.array(free)
        live+=1
        if(np.sum(np.min(free, axis=1)!=0)!=0) :
          print("in")
          new_board[np.min(new_board, axis=1)!=0] = np.array([0])
          animation.append(new_board)
        continue
      now-=1
    return animation

xxx214xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 2922, 'const': 412, 'code+const': 3334}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('For', 11)]]
import numpy as np
def get_score(board):
    bb = np.sum(board[::,::] == 0,axis = 1)
    return len(board[bb == 0])*40
def get_time_cap(board, time_caps):
    bub = np.sum(board[::,::] != 0,axis = 1)
    time_caps *= int(len(board)/len(time_caps))
    time_caps.sort()
    t = np.array(time_caps)
    if len(t[bub != 0]) == 0:
        return time_caps[-1]
    else :
        return t[bub != 0][0]
def rotate_right(shape):
    return shape[::-1,::].T
def rotate_left(shape):
    return shape[::,::-1].T
def animate_drop(board, shape, c):
    k = np.sum(board[:,c:],axis = 1) == 0
    nb = np.array(board)
    l = []
    cnb = np.array(nb)
    for i in range(len(nb[k])):
        cnb = np.array(nb)
        if shape.shape[0] == 1 and k[i] :
            cnb[i,c:c+shape.shape[1]]=shape[:,:]
            l.append(cnb)
        elif shape.shape[0] == len(nb[k]) and k[i]:
            nb[i,c:c+shape.shape[1]]=shape[-(i+1),:]
            x = np.array(nb)
            l.append(x)
        elif len(nb[k]) > shape.shape[0] and k[i]:
            if i+1 <= shape.shape[0]:
                if i == 0 :
                    nb[i,c:c+shape.shape[1]] = shape[-(i+1),:]
                    y = np.array(nb)
                    l.append(y)
                if shape.shape[0]-1 >= i > 0:
                    if i==1:
                        nb[i,c:c+shape.shape[1]] = nb[i-1,c:c+shape.shape[1]]
                        nb[i-1,c:c+shape.shape[1]] = shape[-(i+1),:]
                        y = np.array(nb)
                        l.append(y)
                    if i==2:
                        nb[i,c:c+shape.shape[1]] = nb[i-1,c:c+shape.shape[1]]
                        nb[i-1,c:c+shape.shape[1]] = nb[i-2,c:c+shape.shape[1]]
                        nb[i-2,c:c+shape.shape[1]] = shape[-(i+1),:]
                        y = np.array(nb)
                        l.append(y)
                    if i==3:
                        nb[i,c:c+shape.shape[1]] = nb[i-1,c:c+shape.shape[1]]
                        nb[i-1,c:c+shape.shape[1]] = nb[i-2,c:c+shape.shape[1]]
                        nb[i-2,c:c+shape.shape[1]] = nb[i-3,c:c+shape.shape[1]]
                        nb[i-3,c:c+shape.shape[1]] = shape[-(i+1),:]
                        y = np.array(nb)
                        l.append(y)
            else :
                if shape.shape[0]==2:
                    nb[i,c:c+shape.shape[1]] = nb[i-1,c:c+shape.shape[1]]
                    nb[i-1,c:c+shape.shape[1]] = nb[i-2,c:c+shape.shape[1]]
                    nb[i-2,c:c+shape.shape[1]] = 0
                    y = np.array(nb)
                    l.append(y)
                if shape.shape[0]==3:
                    nb[i,c:c+shape.shape[1]] = nb[i-1,c:c+shape.shape[1]]
                    nb[i-1,c:c+shape.shape[1]] = nb[i-2,c:c+shape.shape[1]]
                    nb[i-2,c:c+shape.shape[1]] = nb[i-3,c:c+shape.shape[1]]
                    nb[i-3,c:c+shape.shape[1]] = 0
                    y = np.array(nb)
                    l.append(y)
                if shape.shape[0]==4:
                    nb[i,c:c+shape.shape[1]] = nb[i-1,c:c+shape.shape[1]]
                    nb[i-1,c:c+shape.shape[1]] = nb[i-2,c:c+shape.shape[1]]
                    nb[i-2,c:c+shape.shape[1]] = nb[i-3,c:c+shape.shape[1]]
                    nb[i-3,c:c+shape.shape[1]] = nb[i-4,c:c+shape.shape[1]]
                    nb[i-4,c:c+shape.shape[1]] = 0
                    y = np.array(nb)
                    l.append(y)
    return l
def animate_clear(board):
    nb = np.array(board)
    k = np.sum(nb == np.zeros_like(nb),axis = 1)==0
    nb[np.arange(len(nb))[k],:] = 0
    l = []
    if np.sum(nb == board)== (nb.shape[0]*nb.shape[1]) :
        return l
    re_nb = np.array(nb)[::-1]
    l.append(nb)
    for i in range(len(board)):
        check = np.array(re_nb)
        if np.sum(re_nb[i,:]) == 0 :
            re_nb[i:-1,:] = re_nb[i+1:,:]
            re_nb[-1,:] = 0
            x = np.array(re_nb)
            if np.sum(x == check) == (check.shape[0]*check.shape[1]) :
                    break
            l.append(x[::-1])
            if np.sum(re_nb[i,:]) == 0 :
                re_nb[i:-1,:] = re_nb[i+1:,:]
                re_nb[-1,:] = 0
                y = np.array(re_nb)
                if np.sum(check == y) == (check.shape[0]*check.shape[1]) :
                    break
                l.append(y[::-1])
                if np.sum(re_nb[i,:]) == 0 :
                    re_nb[i:-1,:] = re_nb[i+1:,:]
                    re_nb[-1,:] = 0
                    z = np.array(re_nb)
                    if np.sum(check == z) == (check.shape[0]*check.shape[1]) :
                        break
                    l.append(z[::-1])
                    if np.sum(re_nb[i,:]) == 0 :
                        re_nb[i:-1,:] = re_nb[i+1:,:]
                        re_nb[-1,:] = 0
                        A = np.array(re_nb)
                        if np.sum(check == A) == (check.shape[0]*check.shape[1]) :
                            break
                        l.append(A[::-1])
                        if np.sum(re_nb[i,:]) == 0 :
                            re_nb[i:-1,:] = re_nb[i+1:,:]
                            re_nb[-1,:] = 0
                            B = np.array(re_nb)
                            if np.sum(check == B) == (check.shape[0]*check.shape[1]) :
                                break
                            l.append(B[::-1])
    return l

xxx209xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0ValueError('zero-size array to reduction operation minimum which has no identity')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0ValueError('zero-size array to reduction operation minimum which has no identity')
[[]]
bytecount: {'code': 730, 'const': 278, 'code+const': 1008}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 5)], [('While', 10)]]
import numpy as np
def get_score(board):
    return np.sum(np.sum(board==0,axis=1)==0)*40
def get_time_cap(board, time_caps):
    r,c=board.shape
    l=len(time_caps)
    b=list(np.arange(l)[np.sum(board.reshape((l,c*(r//l)))!=0,axis=1)>0])
    b.append(l-1)
    return time_caps[b[0]]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    boards = []
    i=0
    while(True):
      if(i+shape.shape[0] > board.shape[0]): break
      sum = ((board[i:i+shape.shape[0],c:c+shape.shape[1]]>0) & (shape>0)).sum()
      if(sum != 0): break
      b = np.array(board)
      b[i:i+shape.shape[0],c:c+shape.shape[1]]+=shape
      boards.append(b)
      i+=1
    return boards
def animate_clear(board):
    boards = []
    r,c=board.shape
    b = np.array(board)
    b[(board>0).sum(1)==c]=0
    if(((board>0).sum(1)==c).sum()!=0):
      boards.append(b)
    t=np.arange(r)[(b>0).sum(1)>0].min()
    while(True):
      if(np.arange(r)[(b>0).sum(1)==0].shape[0]==0):
        break
      i = np.arange(r)[(b>0).sum(1)==0].max()
      if(t>i):
        break
      b=np.array(b)
      b[1:b.shape[0]:]=b[np.arange(r)[np.arange(r)!=i]]
      b[0]=np.zeros(b.shape[1],int)
      boards.append(b)
      t+=1
    return boards

xxx025xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0IndexError('index 4 is out of bounds for axis 0 with size 4')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[10, 20, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 878, 'const': 324, 'code+const': 1202}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 10)], [('For', 12)]]
import numpy as np
def get_score(board):
    s = np.sum(board != 0, axis = 1)
    rows = board.shape[1]
    return np.sum(s == rows) * 40
def get_time_cap(board, time_caps):
    n = len(time_caps)
    s = np.sum(board != 0, axis = 1)
    x = np.sum((s >= 1).reshape(n,len(s)//n), axis = 1)
    t = np.array(time_caps)[x >= 1]
    if len(t) == 0 : return time_caps[-1]
    return t[0]
def rotate_right(shape):
    new_shape = shape.T[:,::-1]
    return new_shape
def rotate_left(shape):
    rotate = shape[::-1,::-1].T[:,::-1]
    return rotate
def animate_drop(board, shape, c):
    l = []
    new_board = np.array(board)
    new_shape = np.array(shape)
    row = shape.shape[0]
    col = shape.shape[1]
    if np.sum((board[:row,c:col+c] == 0)) != row*col:
        return []
    for i in range(board.shape[0]-row+1):
        if np.sum((board[i:row+i,c:col+c] == 0)) == row*col:
            new_board[i:row+i,c:col+c] = shape
            l.append(new_board)
        if np.sum((board[i:row+i,c:col+c] == 0)) != row*col:
          return l
        new_board = np.array(board)
    return l
def animate_clear(board):
    l = []
    new_board = np.array(board)
    x = np.arange(board.shape[0])
    if np.sum(np.sum(board != 0, axis = 1) == board.shape[1]) == 0:
        return []
    clear_row = x[ list(np.sum(board != 0, axis = 1) == board.shape[1]) ]
    new_board[ list(clear_row) ] = 0
    l.append(new_board)
    new_board2 = np.array(new_board)  
    for i in range(np.sum(np.sum(new_board == 0, axis = 1) == board.shape[1])-1):
        zeros = x[ list(np.sum(new_board2 == 0, axis = 1) == board.shape[1]) ]
        new_board2[ list(zeros + i - 1) ] = 0
        new_board2[ list(zeros + i) ] = new_board[ list(zeros + i - 1)]
        l.append(new_board2)
        new_board2 = np.array(new_board)
    return l

xxx036xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 940, 'const': 382, 'code+const': 1322}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 11)], [('For', 18)]]
import numpy as np
def get_score(board):
    a,b=board.shape
    n=np.sum(np.sum(board!=0,axis=1)==b)
    return n*40
def get_time_cap(board, time_caps):
    a,b=board.shape
    n=a/len(time_caps)
    x= np.sum(np.sum(board==0,axis=1)==b)
    if x==a: return time_caps[-1]
    return time_caps[int(int(x)/n)]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    new_board = np.array(board); new_shape = np.array(shape)
    a,b=new_board.shape ; f,g=new_shape.shape
    result=[]
    test=np.array(new_board[0:f,c:c+g])
    if (np.min(np.sum(test==0,axis=1))<np.max(np.sum(new_shape!=0,axis=1))) and ~(str((new_board[0:f,c:c+g]==0)&(new_shape!=0))==str(new_shape!=0)):
      return result
    for i in range(a):
      if a-i<f: break
      place=new_board[i:i+f,c:c+g]
      if str((place==0)&(new_shape!=0))==str(new_shape!=0):
          new_board[i:i+f,c:c+g]+=new_shape
          result.append(new_board)
          new_board = np.array(board)
      else: break
    return result
def animate_clear(board):
    new_board = np.array(board); a,b=board.shape 
    result=[]
    pros=np.arange(a)
    index=np.sum(new_board!=0,axis=1)==b
    if np.sum(index)==0: return result
    new_board[index]=0
    result.append(new_board)
    lines=np.sum(np.sum(new_board==0,axis=1)==b)
    x=0
    find=pros[np.sum(new_board==0,axis=1)!=b]
    if len(find)!=0: x=find[0]
    n=1;m=0
    for i in range(lines-x):
      id=pros[np.sum(new_board==0,axis=1)==b][-1]
      last=np.ones(new_board.shape[0],bool)
      z=np.zeros_like(new_board,int)
      if m>0: last[:m]=False
      last[id]=False
      z[n:]+=new_board[last]
      new_board=np.array(z)
      result.append(z)
      n+=1;m+=1   
    return result

xxx040xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score0.0
[40, 4120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 952, 'const': 366, 'code+const': 1318}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 14)]]
import numpy as np
def get_score(board):
    check = np.array(board*1 != 0)
    finding = np.sum(check, axis=1)
    ans = (finding==5).sum()
    return ans*40
def get_time_cap(board, time_caps):
    check = np.array(board*1 != 0)
    finding = np.sum(check, axis=1)
    pos = np.arange(finding.shape[0])
    ans = pos[finding*1 != 0]
    if len(ans) != 0:
        return time_caps[ans[0] // ( board.shape[0] // len(time_caps)) ]
    else:
        return time_caps[-1]
def rotate_right(shape):
    return shape.T[:, ::-1]
def rotate_left(shape):
    return shape.T[::-1, :]
def animate_drop(board, shape, c):
    new_board = np.array(board)
    check_board = np.array(new_board*1 != 0)
    check_shape = np.array(shape*1 != 0)
    ans = []
    for i in range(0, check_board.shape[0] - shape.shape[0] + 1):
        get = check_board[i:i+shape.shape[0], c:c+shape.shape[1]]
        if True not in get & check_shape:
            new_shape = np.array(shape)
            target_array = new_board[i:i+shape.shape[0], c:c+shape.shape[1]]
            new_shape[(new_shape == 0) & (target_array != 0)] = target_array[(target_array != 0) & (new_shape == 0)]
            new_board[i:i+shape.shape[0], c:c+shape.shape[1]] = new_shape
            ans.append(new_board)
        else:
            break
        new_board = np.array(board)
    return ans
def animate_clear(board):
    ans = []
    new_board = np.array(board)
    check_board = np.array(board*1 != 0)
    board_summary = np.array(np.sum(check_board, axis=1))
    pos = np.arange(len(board_summary))
    line_remove = pos[board_summary*1 == board.shape[1]]
    if len(line_remove) != 0:
        new_board[line_remove, :] = np.zeros((1, board.shape[1]))
        ans.append(np.array(new_board))
    else:
        return []
    while True:
        check_new_board = np.array(new_board*1 != 0)
        find = np.array(np.sum(check_new_board, axis=1))
        pos = np.arange(len(find))
        target_pos = pos[np.array(find*1 == 0)]
        if list(np.arange((find == 0).sum())) != list(target_pos):
            new_board[1:target_pos[-1]+1, :] = new_board[:target_pos[-1], :]
            new_board[0] = np.zeros(board.shape[1], int)
            ans.append(np.array(new_board))
        else:
            break
    return ans

xxx202xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[56, 56, 56, 56, 45, 45, 45, 56]
test_rotate_right0.0
[array([[40, 01],
       [30, 52],
       [25, 03],
       [10, 04]]),
 array([[01, 40],
       [52, 30],
       [03, 25],
       [04, 10]])]
test_rotate_left0.0
[array([[04, 10],
       [03, 25],
       [52, 30],
       [01, 40]]),
 array([[10, 04],
       [25, 03],
       [30, 52],
       [40, 01]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 342, 'const': 162, 'code+const': 504}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[('For', 3)], [('For', 4), ('For', 7)], [], [], [], []]
import numpy as np
def get_score(board):
  k = 0
  for row in range(len(board[:,0])) :
    mnr = min(board[row])
    if mnr != 0 :
      k += 1
  return k * 40
def get_time_cap(board, time_caps):
  s = []
  m = 0
  for row in range(len(board[:,0])) :
    mxr = max(board[row])
    s.append(mxr)
  for i in s :
    m += 1
    if i != 0 :
      break
  a = (m + 1)//(len(board)//len(time_caps)) - 1
  return time_caps[a]
def rotate_right(shape):
  return np.array(shape.T[::-1,::])
def rotate_left(shape):
  return np.array(shape.T[::,::-1])
def animate_drop(board, shape, c):
  return
def animate_clear(board):
  return

xxx021xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [], []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 798, 'const': 338, 'code+const': 1136}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 16)]]
import numpy as np
def get_score(board):
    return np.sum(np.min(board, axis=1) !=0)*40
def get_time_cap(board, time_caps):
    boardss = board.reshape(len(time_caps),board.shape[0]*board.shape[1]//len(time_caps))
    l = np.max(boardss, axis = 1)!=0
    q = np.arange(0,boardss.shape[0])[l]
    if len(q) == 0:
        return time_caps[-1]
    q = q[0]
    return time_caps[q]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    bb,ll = shape.shape
    vv = (shape[:,:]!= 0)
    kk = []
    for i in range(len(board)-bb+1):
        new_board = np.array(board)
        m = new_board[i:i+bb,c:c+ll]!=0
        if np.sum(m==vv)!= 0:
            return kk
        new_board[i:i+bb,c:c+ll]+= shape
        kk.append(np.array(new_board))
    return kk
def animate_clear(board):
    b,tt = board.shape
    m = np.zeros((1,tt),int)
    c = np.arange(b)
    new_board = np.array(board)
    ee = np.min(board, axis = 1)!=0
    new_board[ee] = m
    hq = c[np.sum(new_board, axis = 1)==0]
    oo = hq[:-1]
    jjj = hq[1:]
    if hq.shape[0]==0:
        return []
    gg = []
    gg.append(np.array(new_board))
    while np.sum(jjj-oo) != hq.shape[0]-1:
        if hq.shape[0] == b:
            pass
        if np.sum(hq)==0:
            break
        hq = c[np.sum(new_board, axis = 1)==0]
        yy = hq[-1]
        new_board[1:yy+1:] = new_board[:yy:]
        new_board[0] = m
        gg.append(np.array(new_board))
        hq = c[np.sum(new_board, axis = 1)==0]
        oo = hq[:-1]
        jjj = hq[1:]
    return gg

xxx017xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[None56, None56, None56, None56, None45, None45, None45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 174, 'const': 168, 'code+const': 342}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
import numpy as np
def get_score(board):
    a=np.min(board,axis=1)
    b=a>0
    return sum(b*40)
def get_time_cap(board, time_caps):
    pass
def rotate_right(shape):
    x=shape
    newx=x.T
    return newx[::,::-1]
def rotate_left(shape):
    x=shape
    newx=x.T
    return newx[::-1,::]
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
    pass

xxx031xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0Time-out: 5s
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1158, 'const': 384, 'code+const': 1542}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 12)]]
import numpy as np
def get_score(board):
    checkzero = board.min(axis=1)>0
    return (checkzero.sum()) *40
def get_time_cap(board, time_caps):
    checknum = board.max(axis=1)>0
    if checknum.sum() > 0 :
        return time_caps[checknum.argmax()//(board.shape[0]//len(time_caps))]
    return time_caps[-1]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    ans = []
    checkforout = 0
    new_board = np.array(board)
    new_shape = np.array(shape)
    for i in range(new_board.shape[0]-new_shape.shape[0]+1):
        new_board = np.array(board)
        new_shape = np.array(shape)
        if new_board[i:new_shape.shape[0]+i,c:new_shape.shape[1]+c][new_shape!=0].max() == 0 :
            if (new_shape!=0).sum(axis=1).max() > (new_board[i:new_shape.shape[0]+i,c:new_shape.shape[1]+c]==0).sum(axis=1).min() :
                index = np.arange(0,(new_shape!=0).sum(axis=1).shape[0],1)
                if not(index[(new_shape!=0).sum(axis=1)==(new_shape!=0).sum(axis=1).max()][-1] > (new_board[i:new_shape.shape[0]+i,c:new_shape.shape[1]+c]==0).sum(axis=1).argmin()) :
                    new_board[i:new_shape.shape[0]+i,c:new_shape.shape[1]+c][new_shape!=0] = new_shape[new_shape!=0]
                    checkforout += 1
                    ans.append(new_board)
                else :
                    break
            else :
                new_board[i:new_shape.shape[0]+i,c:new_shape.shape[1]+c][new_shape!=0] = new_shape[new_shape!=0]
                checkforout += 1
                ans.append(new_board)
        else :
            break
        if checkforout == 0 :
            break
    return ans
def animate_clear(board):
    ans = []
    checkforout = 0
    new_board = np.array(board)
    if ((new_board!=0).sum(axis=1)==new_board.shape[1]).sum() > 0 :
        new_board[(new_board!=0).sum(axis=1)==new_board.shape[1]] = 0
        checkforout += 1
        ans.append(new_board)
    if checkforout == 0 :
        return ans
    while (new_board.shape[0]-((new_board[::-1].max(axis=1)==0).argmax())-1) > ((new_board.max(axis=1))!=0).argmax() :
        final = np.ndarray(new_board.shape,int)
        b = ((new_board[::-1].max(axis=1))==0).argmax()
        c = np.arange(0,b)
        a = np.arange(b+1,new_board.shape[0])
        final[0] = new_board[::-1][b]
        final[np.arange(1,a.shape[0]+1)] = (new_board[::-1][a])[::-1]
        final[np.arange(a.shape[0]+1,c.shape[0]+1+a.shape[0])] = (new_board[::-1][c])[::-1]
        new_board = final
        ans.append(new_board)
    return ans

xxx204xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score0.0
[40, 4120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [ array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 05, 05, 04],
       [0, 20, 20, 40]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 25, 25, 4]])],
  [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 700, 'const': 352, 'code+const': 1052}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 10)], [('For', 29)]]
import numpy as np
def get_score(board):
    b=board>0
    b=np.sum(b,axis=1)
    score=sum(b==5)
    return score*40
def get_time_cap(board, time_caps):
    nb=board.shape[0]
    nt=len(time_caps)
    n=nb//nt
    tc=time_caps*n
    tc.sort()
    b=board!=0
    b=np.sum(b,axis=1)
    b[b!=0]=1
    tc=b*tc
    tc=tc[tc!=0]
    if len(tc)!=0:
        return min(tc)
    else:
        return time_caps[-1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    nb=[]
    new_board = np.array(board)
    x=shape.shape[1]
    y=shape.shape[0]
    b=new_board==0
    new_shape=np.array(shape)
    sb=new_shape==0
    for i in range(board.shape[0]-y+1):
        new_board = np.array(board)
        d=b[i:i+y,c:c+x]|sb
        if np.sum(d)==x*y :
            new_board[i:i+y,c:c+x]=new_board[i:i+y,c:c+x]+shape
            nb.append(new_board)
        else:
            break
    return nb
def animate_clear(board):
  nb=[]
  new_board = np.array(board)
  b=new_board!=0
  b=np.sum(b,axis=1)
  new_board[b==board.shape[1]]=0
  nb.append(new_board)
  b=np.sum(new_board,axis=1)
  indexb=np.arange(b.shape[0])
  indexb=indexb[b==0]
  if indexb.shape[0]==0:
      dshape=[]
  else:    
      shape=new_board[:indexb[-1]]
      fordropboard=np.array(new_board)
      fordropboard[:shape.shape[0]]=0
      dshape=animate_drop(fordropboard, shape, 0)
  return dshape

xxx213xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 544, 'const': 188, 'code+const': 732}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], []]
import numpy as np
def get_score(board):
      k = sum(board.T != 0)
      l  = sum(k == board.shape[1])
      return int(l)*40
def get_time_cap(board, time_caps):
      pos = np.arange(board.shape[0])
      h = pos[sum(board.T != 0) > 0]
      if len(h) == 0:
          return time_caps[-1]  
      else:
          return  sorted(time_caps*(board.shape[0]//len(time_caps)))[h[0]]
def rotate_right(shape):
     return shape[::-1].T
def rotate_left(shape):
     return shape[::,::-1].T
def animate_drop(board, shape, c):
  total = np.sum(board != 0)+np.sum(shape !=0)
  result =list()
  for i in range(-shape.shape[0],len(board)-shape.shape[0]+1):
    new_board = np.array(board)
    if i<0 :
      new_board[0:-i,c:c+shape.shape[1]] += shape[i:]
      if np.sum(new_board != 0) != np.sum(board !=0 ) + np.sum(shape[i:]!=0):
        return []
    else:
        new_board[i:i+shape.shape[0],c:c+shape.shape[1]] += shape
        if np.sum(new_board != 0) != total :
          break
        result.append(np.array(new_board))
  return result
def animate_clear(board):
    pass

xxx029xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1002, 'const': 338, 'code+const': 1340}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 10)], [('While', 24)]]
import numpy as np
def get_score(board):
    m = np.arange(board.shape[0])
    b = board>0
    c = np.sum(b,axis = 1)
    d = c > board.shape[1] - 1
    return len(m[d])*40
def get_time_cap(board, time_caps):
    r = board.shape[0]
    c = board.shape[1]
    x = board != 0
    y = np.sum(x,axis=1)!= 0
    z = np.arange(0,r)[y]
    if len(z) == 0: return(time_caps[-1])
    else:
      w = z[0]  
      k = r//len(time_caps)  
      i = w//k  
      return(time_caps[i])
def rotate_right(shape):
    a = shape[::-1].T
    return a
def rotate_left(shape):
    return rotate_right(shape)[::-1,::-1]
def animate_drop(board, shape, c):
    new_board = np.array(board)
    r = board.shape[0]
    q = board.shape[1]
    rn = shape.shape[1]
    cn = shape.shape[0]
    k = shape>0
    l = []
    for i in range(r):
      a = i+cn
      b = c+rn
      if a > r or b > q: break
      if np.sum(new_board[i:a,c:b][k])==0:
        new_board[i:i+cn,c:c+rn][k] = shape[k]
        l.append(new_board)
        new_board = np.array(board)
      else:
          break
    return l
def animate_clear(board):
  l = []
  new_board1 = np.array(board)
  r = board.shape[0]
  c = board.shape[1]
  a = np.sum(board != 0,axis = 1) == c
  m = np.sum(board != 0,axis = 1) != c
  index = np.arange(0,r)
  j = index[a]
  if len(j)==0: return [] 
  else:
    j = list(j)
    new_board1[j] = np.zeros(c,int)
    l.append(new_board1)
  new_board = np.array(new_board1)
  n_z = index[np.sum(new_board != 0,axis=1)!=0]
  z = index[np.sum(new_board != 0,axis=1)==0]
  if n_z[0] > z[-1]: return l
  g = np.arange(0,r)[m][np.arange(0,r)[m] < j[-1]]
  shape = new_board1[g[0]:g[-1]+1]
  rshape = shape.shape[0]
  cshape = shape.shape[1]
  i = 0
  while n_z[0] < z[-1]:
      rp = z[-1]
      new_board[1:rp+1] = new_board[0:rp]
      new_board[0] = np.zeros(c,int)
      n_z = index[np.sum(new_board != 0,axis=1)!=0]
      z = index[np.sum(new_board != 0,axis=1)==0]
      l.append(new_board)
      new_board = np.array(new_board)
  return l

xxx044xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[array([[0, 2, 0, 0],
       [2, 2, 2, 0],
       [1, 1, 0, 0]])],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 394, 'const': 330, 'code+const': 724}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
import numpy as np
def get_score(board):
  x=(board == 0)
  a=np.sum(x, axis = 1)
  a=a[a>0]
  return (board.shape[0]-a.size)*40
def get_time_cap(board, time_caps):
  x=board>0
  n=np.sum(x, axis=1) >0
  r=np.arange(board.shape[0])
  index=r[n]
  if index.size ==0:
    return time_caps[-1]
  else:
    index1=index[0,]
  con=int(board.shape[0]/len(time_caps))
  return time_caps[int((index1//con))]
def rotate_right(shape):
  return shape.T[:,::-1]
def rotate_left(shape):
  return shape[:,::-1].T
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
  board1=np.array(board)
  x=board>0
  ans=list()
  cc=np.sum(x,axis=1)==board1.shape[1]
  k=np.arange(board1.shape[0])
  ch=k[cc]
  board1[ch,:]=0
  ans.append(board1)
  return ans

xxx016xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[56, 56, 56, 56, 45, 45, 56, 456]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 942, 'const': 338, 'code+const': 1280}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('count_nonzero', 9)], []]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 13)], [('While', 14)]]
import numpy as np
def get_score(board):
 a = np.min(board,axis=1)
 b = a[a!=0]
 return len(b)*40
def get_time_cap(board, time_caps):
 x = np.max(board,axis=1)
 x2 = x[x==0]
 x3 = len(x2)
 y = board.shape[0]//len(time_caps)
 if len(x2)%2 != 0 and len(x2) != len(board[0::,0]):
    z = (len(x2) + 1)//y -1
 elif len(x2)%2 == 0 and len(x2) != len(board[0::,0]):
    z = (len(x2)+ 2)//y - 1
 elif len(x2) == len(board[0::,0]):
    z = (len(x2))//y -1
 return time_caps[z]
def rotate_right(shape):
 return shape[::-1].T
def rotate_left(shape):
 return shape.T[::-1]
def animate_drop(board, shape, c):
 x = shape.shape[0]
 y = shape.shape[1]
 b = np.array(board)
 e = len(shape[shape!=0])
 f = len(board[board!=0])
 a = []
 b[0:x,c:c+y] = shape
 wassapbro = np.count_nonzero(b)
 if wassapbro != e + f:
     return []
 b = np.array(board)
 for i in range(board.shape[0]-x+1):
     b[i:i+x, c:c+y] += shape
     if wassapbro != len(b[b!=0]):
         break
     a += [b]
     b = np.array(board)
 return a
def animate_clear(board):
 b = np.array(board)
 pos = np.arange(board.shape[0])
 x = np.min(b,axis=1)
 y = pos[x!=0]
 b[y,:] = 0
 notzero = np.sum(np.max(b,axis=1)!= 0)
 c = []
 b2 = np.array(b)
 c.append(b2)
 i = 0
 if np.sum(np.max(b[-notzero:],axis=1)!=0) == notzero:
     return []
 while np.sum(np.max(b[-notzero:],axis=1)!=0) != notzero:
     zero = np.max(b,axis=1)==0
     if np.sum(zero) ==0:
         return []
     lastrow = pos[zero][-1]
     b[1:lastrow+1] = b[:lastrow]
     b[i] = 0
     i += 1
     b2 = np.array(b)
     c.append(b2)
 return c

xxx022xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1124, 'const': 444, 'code+const': 1568}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 4)], [('While', 13)]]
import numpy as np
def get_score(board):
    return np.sum((np.min(board,axis=1)!=0))*40
def get_time_cap(board, time_caps):
    bools = np.max(board.reshape(len(time_caps),(board.shape[0]*board.shape[1])//len(time_caps)),axis=1)>0
    pos = np.arange(bools.shape[0])
    if len(pos[bools%2==1]) == 0:
        return time_caps[-1]
    else :
        return time_caps[pos[bools%2==1][0]]
def rotate_right(shape):
    if shape.shape[1] == 1 :
        return shape.reshape(1,shape.shape[0])[::-1,::-1]
    else : return shape.T[:,::-1]
def rotate_left(shape):
    if shape.shape[1] == 1 :
        return shape.reshape(1,shape.shape[0])[::-1,::-1]
    else : return shape.T[::-1,:]
def animate_drop(board, shape, c):
    ans = [] ; j = 0 ; no_space = False
    while no_space == False and board.shape[0]-j >= shape.shape[0]:
        if np.max((np.array(board,bool)[j:j+shape.shape[0],c:c+shape.shape[1]])*np.ones_like(board[j:j+shape.shape[0],c:c+shape.shape[1]],int)+np.array(shape,bool)*np.ones_like(shape,int)) != 1 or np.max(board[0,c:c+shape.shape[0]]) != 0:
            no_space = True
        else :
            new_board = np.array(board)
            new_board[j:j+shape.shape[0],c:c+shape.shape[1]] += shape
            ans.append(new_board)
            no_space = False
            j+=1
    return ans
def animate_clear(board):
    ans = []
    new_board = np.array(board)
    if len(new_board[np.min(board,axis=1)!=0]) == 0 :
        return []
    else :
        new_board[np.min(board,axis=1)!=0] = 0
        ans_this = np.array(new_board)
        ans.append(ans_this)
    gap = set(np.arange(new_board.shape[0])[np.max(new_board,axis=1)==0])-{0}
    c = 0
    while c < len(gap):
        find_zero = np.arange(new_board.shape[0])[np.max(new_board,axis=1)==0][-1]
        new_board[1:find_zero+1,:] = np.zeros_like(new_board[:find_zero+1,:],int)[1:,]+new_board[:find_zero,:]
        new_board[0] = 0 
        ans_board = np.array(new_board)
        if np.min(np.zeros_like(new_board[:find_zero+1,:],int)[1:,]+new_board[:find_zero,:]==new_board[1:find_zero+1,:]) != True:
            ans.append(ans_board)
        c+=1
    return ans

xxx040xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 300, 'const': 240, 'code+const': 540}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
import numpy as np
def get_score(board):
    a = np.min(board,axis=1)
    b = a > 0
    return np.sum(b)*40
def get_time_cap(board, time_caps):
    new_board = board.reshape((len(time_caps),board.shape[1]*board.shape[0]//len(time_caps)))
    a = np.max(new_board!=0,axis=1)!=0
    try:
        return np.array(time_caps)[a][0]
    except:
        return time_caps[-1]
def rotate_right(shape):
    return shape.T[::, ::-1]
def rotate_left(shape):
    return shape.T[::-1, ::]
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    return []
def animate_clear(board):
    new_board = np.array(board)
    return []

xxx045xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1096, 'const': 370, 'code+const': 1466}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 21)], [('While', 11)]]
import numpy as np
def get_score(board):
    b=np.min(board,axis=1)
    c=b[b!=0]
    return c.shape[0]*40
def get_time_cap(board, time_caps):
    width=board.shape[1]*int(board.shape[0]/len(time_caps))
    x=board.reshape( ( len(time_caps),width) )
    x=np.sum(x,axis=1)
    pos=np.arange(x.shape[0])
    if(pos[x!=0].shape[0]!=0):
      return time_caps[pos[x!=0][0]]
    else:
      return time_caps[len(time_caps)-1]
def rotate_right(shape):
    return shape.T[::,::-1]
def rotate_left(shape):
    return shape.T[::-1,::]
def animate_drop(board, shape, c):
    ans=list()
    y=0
    a=np.array(board)
    b=shape.shape[0]-np.argmax(np.array(shape)[::-1,::],axis=0)-1
    che=a[0:shape.shape[0],c:c+shape.shape[1]]
    che[che!=0] = 1
    f=np.argmax(che,axis=0)
    g=np.max(che,axis=0)
    if(np.sum(np.ones(shape.shape[1])[(b >= f) & (g!=0)] )):
      pass
    else:
      bshape=shape.reshape(shape.shape[0]*shape.shape[1])
      bshape=np.arange(bshape.shape[0])[bshape!=0]
      con=che.reshape(che.shape[0]*che.shape[1])[bshape]
      che =np.array(board)[0:shape.shape[0],c:c+shape.shape[1]]
      while(np.sum( con,axis=0)==0):
        add=np.array(board)
        add[y:y+shape.shape[0],c:c+shape.shape[1]] = che + shape
        ans.append(add)
        y+=1
        if(y<=board.shape[0]-shape.shape[0]):
          che=np.array(board)[y:y+shape.shape[0],c:c+shape.shape[1]]
          con=che.reshape(che.shape[0]*che.shape[1])[bshape]
        else:
          break
    return ans
def animate_clear(board):
    ans=list()
    n=np.array(board)
    if(np.sum(np.min(n,axis=1)!=0)==0):
      return ans
    n[np.min(n,axis=1)!=0]=np.zeros(n.shape[1])
    l=n.shape[0]
    cb=np.array(n)
    ans.append(cb)
    while(l!=0):
      if(np.sum(np.max(cb[:l,::],axis=1))==0 or np.max(cb[l-1])!=0):
        l-=1
      else:
        cb=np.array(cb)
        sh=np.arange(-1,l-1)
        sh[0]=l-1
        cb[:l]=cb[sh]
        ans.append(cb)
    return ans

xxx206xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[array([[2, 0, 0, 0],
       [1, 0, 1, 1]])],
 [array([[0, 2, 0, 0],
       [1, 0, 1, 1]]), array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 0, 0, 5, 0, 0, 0],
       [0, 1, 1, 0, 0, 0, 0, 0],
       [0, 2, 2, 2, 0, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]]),
  array([[0, 1, 0, 5, 5, 0, 0, 0],
       [0, 1, 1, 0, 5, 0, 0, 0],
       [0, 2, 2, 2, 0, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]]),
  array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[0, 0, 2, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 0, 0, 2, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 2, 2, 2, 0, 0 ... (more)
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 2, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 0, 0, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1196, 'const': 294, 'code+const': 1490}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep:
   [[('For', 4)], [('For', 6), ('ListComp', 3)], [], [], [('While', 10), ('For', 13)], [('For', 7), ('While', 18), ('While', 23), ('For', 26)]]
import numpy as np
def get_score(board):
    n = board.argmin(1)
    ans = []
    for i in range(n.shape[0]):
        ans.append(board[i,n[i]])
    ans = np.array(ans)
    return len(ans[ans != 0])*40
def get_time_cap(board, time_caps):
    x,y = board.shape
    tc = [t for t in time_caps]
    t = len(tc)
    s = board.reshape((t,x*y//t)).sum(1)
    for i in range(len(s)):
        if s[i] != 0:
            return tc.pop(i)
    return tc[-1]
def rotate_right(shape):
    s = shape
    return s[::-1,:].T
def rotate_left(shape):
    s = shape
    return s[:,::-1].T
def animate_drop(board, shape, c):
    newb = np.array(board)
    brow,bcol = board.shape
    srow,scol = shape.shape
    blank = [0]*bcol
    color = shape[[0],[shape.argmax(1)[0]]][0]
    step = []
    i = 0
    full = np.array([[color]*scol])
    while i < brow:
        newmodif = np.array([blank]*brow)
        ch = True
        for r in range(brow):
            if abs(-i+r) < srow and r <= i :
                modif = shape[[-i-1+r],:]
                line = (full-modif)[0]
                b = board[[r],c:c+scol][0]
                check = [b != 0]
                ss = (b+modif)[0]
                if True in (len(tuple(b)) != len(tuple(ss)) or (check != [] and b[tuple(check)] != ss[tuple(check)])):
                    return step
                modif = list(modif[0])
                ch = False
            elif ch and r >= i:
                return step
            else:
                modif = [0]*scol
            modif = [0]*c + modif + [0]*(bcol-c-scol)
            modif = [blank]*r + [modif] + [blank]*(brow-r-1)
            newmodif += modif
        step.append(newmodif+newb)
        i += 1
    return step
def animate_clear(board):
    newb = np.array(board)
    r,c = newb.shape
    changed = []
    ans = []
    check = True
    for b in range(r):
        if not 0 in newb[b]:
            changed.append([0]*c)
            check = False
        else:
            changed.append(newb[b])
    if check:
        return []
    changed = np.array(changed)
    true = list(changed.sum(1))
    n = 0
    while 0 in true:
        true.remove(0)
        n += 1
    true = [0]*n+true
    ans.append(changed)
    while list(changed.sum(1)) != true:
        e = 0
        move = []
        for i in changed[::-1,:]:
            if list(i) != [e]*c:
                move.append(list(i))
            else:
                e = -1
        move.append([0]*c)
        ans.append(np.array(move)[::-1,:])
        changed = ans[-1]
    return ans

xxx018xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0Time-out: 5s
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0Time-out: 5s
[[]]
bytecount: {'code': 638, 'const': 404, 'code+const': 1042}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 5)], [('While', 12)]]
import numpy as np
def get_score(board):
    index = np.min(board != 0, axis=1)
    return len(board[index]) * 40
def get_time_cap(board, time_caps):
    if np.min(board == 0):
        return time_caps[-1]
    return time_caps[np.argmax(np.max(board != 0, axis=1)) * len(time_caps) // len(board)]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    animate = []
    i = 0
    while i < len(board) - shape.shape[0] + 1 and np.max(board[i:shape.shape[0]+i, c:c+shape.shape[1]][shape != 0]) == 0:
        new_board = np.array(board)
        new_board[i:shape.shape[0]+i, c:c + shape.shape[1]][shape != 0] = np.max(shape)
        animate.append(new_board)
        i += 1
    return animate
def animate_clear(board):
    new_board = np.array(board)
    listNewboard = []
    if np.max(np.min(board != 0, axis=1)):
        new_board[np.min(board != 0, axis=1)] = 0
        listNewboard.append(new_board)
    def conditionCheck():
        temp = np.max(new_board != 0, axis=1)
        start = np.argmax(temp)
        return not np.min(temp[start:])
    while conditionCheck():
        new_board = np.array(new_board)
        temp = np.min(new_board == 0, axis=1)
        end = len(temp) - np.argmax(temp[::-1])
        new_board[1:end] = new_board[0:end-1]
        new_board[0] = 0
        listNewboard.append(new_board)
    return listNewboard

xxx025xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 928, 'const': 338, 'code+const': 1266}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 10)], [('While', 10)]]
import numpy as np
def get_score(board):
   return 40*board[np.sum(board == 0 , axis = 1) == 0].shape[0]
def get_time_cap(board, time_caps):
    if np.sum(board) == 0 :
        return time_caps[-1]
    n = board.shape[0]//len(time_caps)
    r = np.arange(board.shape[0])
    b = board[np.sum(board != 0 , axis=1) != 0][0]
    return time_caps[r[ np.sum(board == b, axis = 1) == board.shape[1]][0]// n]
def rotate_right(shape):
    return shape.T[: , ::-1]
def rotate_left(shape):
    return shape.T[::-1 , :]
def animate_drop(board, shape, c):
    l = []
    nc_board = board.shape[1]
    nr_board = board.shape[0]
    nc_shape = shape.shape[1]
    nr_shape = shape.shape[0]
    if 0 <= c <= np.abs(nc_board - nc_shape) :
        r = 0
        while r < board.shape[0] :
            new_board = np.array(board)
            blank = np.zeros_like(board, int)
            blank[ r: r+ nr_shape , c:c+nc_shape] = shape
            new_board[ r : r+nr_shape , c:c+nc_shape][shape != 0] = shape[shape != 0]
            s = np.sum((new_board - board)[ r: r+ nr_shape , c:c+nc_shape ] != shape)
            if s == 0 :
                l.append(new_board)
                if r + nr_shape == nr_board :
                    break
                r += 1
            else : break
    return l
def animate_clear(board):
    l = []
    new_board = np.array(board)
    r = np.arange(board.shape[0])
    if r[np.sum(board != 0 , axis = 1) == board.shape[1]].shape[0] != 0 :
        new_board[np.sum(board != 0 , axis = 1) == board.shape[1] , :] = 0
        l.append(new_board)
        r = new_board.shape[0]-1
        while r >= 0 :
            nnew_board = np.array(l[-1])
            if np.sum(nnew_board[r] != 0) == 0 :
                nnew_board[1:r+1 , :] = nnew_board[:r , :]
                nnew_board[0 , :] = np.zeros( (1,board.shape[1]) , int)
                if np.sum(nnew_board) == 0 :
                    break
                l.append(nnew_board)
            else :
                r -= 1
            if np.sum(nnew_board[ :r , :]) == 0 :
                break
        return l
    return l

xxx210xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 906, 'const': 350, 'code+const': 1256}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 9)], [('While', 8)]]
import numpy as np
def get_score(board):
    return np.sum(np.sum(board!=0,axis=1)==board.shape[1])*40
def get_time_cap(board, time_caps):
    if np.sum(board)==0:
        return time_caps[-1]
    get_index = np.arange(0,board.shape[0])
    not_zero = np.sum(board,axis=1)!=0
    n = get_index[not_zero][0]//(board.shape[0]//len(time_caps))
    return time_caps[n]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    pos = []
    is_block = shape != 0
    r = 0
    count = 0
    while True:
        if r+shape.shape[0]>board.shape[0]:
            break
        copy = np.array(board)
        if count<shape.shape[0]:
            crop = copy[:count+1,c:c+shape.shape[1]]
            if np.sum(crop[is_block[shape.shape[0]-1-count:]])!=0:
                return []
            count+=1
        crop = copy[r:r+shape.shape[0],c:c+shape.shape[1]]
        if np.sum(crop[is_block])!=0:
            break
        else:
            crop = crop + shape
            copy[r:r+shape.shape[0],c:c+shape.shape[1]] = crop
            pos.append(np.array(copy))
            r+=1
    return pos
def animate_clear(board):
    pos = []
    is_not_full = (np.sum(board!=0,axis=1)==board.shape[1])==False
    cleared = is_not_full.reshape(board.shape[0],1)*np.array(board)
    pos.append(np.array(cleared))
    wat_row = np.arange(0,cleared.shape[0])
    while True:
        if np.sum(cleared)==0:
            break
        if len(wat_row[np.sum(cleared,axis=1)==0])==0:
            return []
        bottom_zero = wat_row[np.sum(cleared,axis=1)==0][-1]
        if len(wat_row[np.sum(cleared,axis=1)!=0])==0:
            return []
        above_nzero = wat_row[np.sum(cleared,axis=1)!=0][0]
        if bottom_zero<above_nzero:
            break
        cleared[above_nzero+1:bottom_zero+1,:] = cleared[above_nzero:bottom_zero,:]
        cleared[above_nzero,:] = np.zeros((1,cleared.shape[1]))
        pos.append(np.array(cleared))
    return pos

xxx017xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0ValueError('cannot reshape array of size 24 into shape (2,8)')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [0, 0, 0, 0],
       [1, 0, 2, 4]]),
  array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [1, 0, 5, 4],
       [1, 0, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 710, 'const': 332, 'code+const': 1042}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 9)], [('While', 10)]]
import numpy as np
def get_score(board):
    return board[np.min(board, axis=1) != 0].shape[0]*40
def get_time_cap(board, time_caps):
    rs_board = board.reshape(len(time_caps),  2*board.shape[1])
    row_0 = np.max(rs_board,1)==0
    row_0 = list(row_0)
    try:
        idx = row_0.index(False)
        return time_caps[idx]
    except: 
        return time_caps[-1]
def rotate_right(shape):
    return shape.T[:, ::-1]
def rotate_left(shape):
    return shape.T[::-1, :]
def animate_drop(board, shape, c):
    animation_frames = []
    sh, sw = shape.shape
    bh, bw = board.shape
    s = shape!=0
    if not np.sum(board[:sh, c:c+sw][s]):
      r=0
      while not r+sh > bh:
          frame = np.array(board)
          bs = frame[r:r+sh,c:c+sw]
          if np.sum((bs + shape)[s] != shape[s]):
              return animation_frames
          frame[r:r+sh,c:c+sw] = bs + shape
          animation_frames.append(np.array(frame))
          r+=1
    return animation_frames
def animate_clear(board):
    animation_frames = []
    frame = np.array(board)
    row_0 = np.sum(board==0,1) == 0
    if np.sum(row_0) != 0:
        frame[row_0] = 0
        animation_frames.append(np.array(frame))
        bh, bw = board.shape
        while True:
            non_0 = frame!=0
            non_0_row = non_0.sum(axis=1)
            idx_swap = np.arange(frame.shape[0])[non_0_row == 0]
            idx_swap = idx_swap[idx_swap>0]
            to_swap = (frame[idx_swap], frame[idx_swap-1])
            frame[idx_swap-1] = to_swap[0]
            frame[idx_swap] = to_swap[-1]
            last_frame = animation_frames[-1]
            if np.sum(last_frame==frame) == int(bh*bw):
                return animation_frames
            animation_frames.append(np.array(frame))
    return animation_frames

xxx021xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[56, 56, 56, 56, 456, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 816, 'const': 292, 'code+const': 1108}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 9)]]
import numpy as np
def get_score(board):
    a = np.sum(board != 0,axis=1)
    b = a[a == board.shape[1]]
    return (b.shape[0])*40
def get_time_cap(board, time_caps):
    c = board.shape[0]//len(time_caps)
    a = board[::c , :] + board[1::c, :]
    b = np.sum(a != 0 , 1)
    if b.max() == 0 : return time_caps[-1]
    d = np.arange(a.shape[0])
    d = d[b!=0].min()
    return time_caps[d]
def rotate_right(shape):
    a = shape[::-1]
    return a.T
def rotate_left(shape):
    a = shape.T
    return a[::-1]
def animate_drop(board, shape, c):
    y = np.array(shape)
    cols = shape.shape[1]
    rows = shape.shape[0]
    rowb = board.shape[0]
    ans = []
    for row in range(rowb-rows+1) :
        test = np.array(board)
        test[row:row+rows,c:c+cols] += shape
        cnz_shape = np.sum(shape != 0)
        cz_board = np.sum(board == 0)
        cz_test_board = np.sum(test == 0)
        if (cz_board - cz_test_board) == cnz_shape : ans.append(test)
        else : break
    return ans
def animate_clear(board):
    x = np.array(board)
    a = np.sum(x != 0,axis=1)
    b = (np.array([a]).T != board.shape[1])*x
    ans = [(np.array([a]).T != board.shape[1])*x]
    c = b.sum(1)
    if np.sum(c == 0) == 0 : return []
    while True :
        c = b.sum(1)
        d = np.arange(x.shape[0])
        d = d[c==0].max()
        if np.sum(c[:d:] == 0) == d : break  
        g = np.zeros((x.shape[0],x.shape[1]),int)
        g[1:d+1:,:] = b[:d:,:]
        g[d+1::,:] = b[d+1::,:]
        b = g
        ans.append(g)
    return ans

xxx023xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 672, 'const': 364, 'code+const': 1036}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 3)], [('For', 4)]]
import numpy as np
def get_score(board):
    return np.sum(np.min(board, axis=1) != 0) * 40
def get_time_cap(board, time_caps):
    A = np.sum(board, axis=1) != 0
    return time_caps[np.argmax(A) // (board.shape[0] // len(time_caps))] if np.sum(A) else time_caps[-1]
def rotate_right(shape):
    return shape.T[:, ::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    result = []
    for i in range(len(board)):
        new_board = np.array(board)
        if new_board[i: i + shape.shape[0]].shape[0] != shape.shape[0]: break
        new_board[i:i + shape.shape[0], c:c + shape.shape[1]] += shape
        if board[board != 0].shape[0] + shape[shape != 0].shape[0] != new_board[new_board != 0].shape[0]: break
        result.append(new_board)
    return result
def animate_clear(board):
    new_board = board * (np.min(board, axis=1) == 0).reshape(board.shape[0], 1)
    result = []
    for i in range(len(board) + 1):
        re_new_board = new_board[::-1]
        key = np.sum(re_new_board, axis=1) == 0
        if np.sum(key) == 0: break
        result.append(new_board)
        a = np.argmax(np.sum(re_new_board, axis=1) == 0)
        mb = np.array([True] * len(board))
        mb[a] = False
        A = re_new_board[mb]
        new_board = np.zeros_like(new_board, int)
        new_board[:-1] = A
        new_board = new_board[::-1]
        if np.sum(new_board == result[-1]) == board.shape[0] * board.shape[1]:
            break
    return result

xxx203xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 956, 'const': 338, 'code+const': 1294}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('For', 15)]]
import numpy as np
def get_score(board):
    s = board == 0
    g = np.sum(s,axis = 1)
    done = np.sum(g==0)*40
    return done
def get_time_cap(board, time_caps):
    l = len(time_caps)
    r = board.shape[0]//l
    b = np.sum(board,axis=1)
    cb = b!=0
    if np.sum(cb) == 0:
        return time_caps[-1]
    cb = cb.reshape((l,r))
    s = np.sum(cb,axis=1)>0
    t = np.array(time_caps)
    got = t[s]
    done = got[0]
    return done
def rotate_right(shape):
    return shape.T[:,-1::-1]
def rotate_left(shape):
    return shape.T[-1::-1]
def animate_drop(board, shape, c):
    l = []
    nb = np.array(board)
    ns = np.array(shape)
    num_shape = np.sum(ns!=0)
    for i in range(len(nb)-(ns.shape[0]-1)):
        x = np.array(nb)
        zc = x==0
        zx = np.zeros((x.shape[0],x.shape[1]),int)
        zx[i:i+ns.shape[0],c:c+ns.shape[1]] += ns
        sc = zx != 0
        put = zc&sc
        if np.sum(put) != num_shape:
            break
        x[i:i+ns.shape[0],c:ns.shape[1]+c] += ns
        l.append(x)
    return l
def animate_clear(board):
    nb = np.array(board)
    zc = nb== 0
    pos = np.arange(len(nb)).reshape((len(nb),1))
    x = np.sum(zc,axis=1).reshape((len(nb),1)) == 0
    pos_x = pos[x]
    same_check = np.array(nb)
    nb[pos_x] = np.zeros((1,nb.shape[1]),int)
    if np.sum(same_check == nb)== nb.shape[0]*nb.shape[1]:
        return []
    l = [nb]
    zc = nb.sum(axis=1)==0
    count = 0
    for i in range(len(zc)-1,-1,-1):
        y = nb
        if zc[i]:
            y = np.zeros((nb.shape[0],nb.shape[1]),int)
            y[0] = nb[i+count]
            y[1:i+count+1] = nb[0:i+count]
            y[i+count+1:] = nb[i+count+1:]
        if np.sum(y == nb) == nb.shape[0]*nb.shape[1]:
            pass
        else:
            nb = y
            l.append(nb)
            count += 1
    return l

xxx121xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[56, 56, 56, 456, 456, 456, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[array([[2, 2, 2, 0],
       [3, 0, 1, 1]])], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[ 0,  0,  0,  0,  0,  0],
       [ 0,  2,  2,  2,  0,  0],
       [ 0,  0,  0,  2,  8,  0],
       [ 1,  1,  0, 10,  8,  0],
       [ 1,  1,  0,  0,  8,  0]]),
  array([[ 0,  0,  0,  0,  0,  0],
       [ 0,  0,  0,  0,  0,  0],
       [ 0,  2,  2,  2,  8,  0],
       [ 1,  1,  0, 10,  8,  0],
       [ 1,  1,  0,  2,  8,  0]])],
 [array([[ 0,  0,  2,  2,  2,  0],
       [ 0,  0,  0,  0,  2,  0],
       [ 0,  0,  0,  0, 10,  0],
    ... (more)
test_animate_drop_30.0IndexError('index 2 is out of bounds for axis 0 with size 2')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0ValueError('could not broadcast input array from shape (3,4) into shape (0,4)')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 1006, 'const': 366, 'code+const': 1372}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 4)], [('While', 17)]]
import numpy as np
def get_score(board):
    score = 0 
    t = board==0
    t_t = np.sum(np.sum(t, axis=1)==0)
    score = (t_t)*40
    return score
def get_time_cap(board, time_caps):
    total_col = np.sum(board, axis=1)
    z = (total_col == 0)
    i = np.argmin(z)
    if i == 0 :
        c = (total_col != 0)
        if sum(c) == 0 :
            return (time_caps[-1])
        else :
            return (time_caps[0])
    if i%2 == 1 and i != 0:
        x = (time_caps[int(((i+1)*len(time_caps))/len(board))-1])
        return x
    if i%2 == 0 and i != 0 :
        y = (time_caps[int(((i+1)*len(time_caps))/len(board))])
        return y
def rotate_right(shape):
    r = np.array(shape[::-1].T)
    return r
def rotate_left(shape):
    l = np.array(shape[::,::-1].T)
    return l
def animate_drop(board, shape, c):
    ans = []
    k = 0 
    while k <= len(board) :
        new_board = np.array(board)
        m = board[k , c:c+len(shape[0])]
        if np.sum(m) == 0 :
            new_board[k : k+len(shape), c : c+len(shape[0])] += shape
            ans.append(np.array(new_board))
        if np.sum(m) != 0 :
            break
        k+=1
    if len(ans) != 0 :
        return ans
    else :
        return []
def animate_clear(board):
    t = []
    mn = np.min(board, axis=1)
    a = np.arange(mn.shape[0])
    i = a[ mn != 0]
    new_board = np.array(board)
    new_board[i] = 0
    t.append(new_board)
    z = np.sum(new_board[1:], axis =1) == 0
    x = sum(z == True)
    ans = []
    ans.append(np.array(new_board))
    c = 1
    if x == 0 :
        return ([])
    if x > 0 :
        while sum(np.sum(t[-1], axis = 1)[0:x]) != 0 or x ==1 :
            w = np.array(t[-1])
            if x > 1 :
                if np.sum(w[-c]) == 0 :
                    new_board[1: -c+1] = new_board[0:-c]
                    new_board[0] = 0
                    ans.append(np.array(new_board))
                else :
                    c += 1
            if x == 1 :
                if np.sum(w[c]) == 0 :
                    new_board[1: c+1] = new_board[0:c]
                    new_board[0] = 0
                    ans.append(np.array(new_board))
                else :
                    c += 1
            if c >= len(board) :
                break
        return (ans)

xxx031xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[ 0,  0,  0,  02,  02,  02],
       [ 0,  20,  20,  20,  0,  02],
       [ 0,  0,  0,  20,  8,  02],
       [ 1,  1,  0, 10,  8, 8, 0],
       [ 1,  1,  0,  0,  8,  0]]),
  array([[ 0,  0,  0,  0,  0,  0],
       [ 0,  0,  0,  02,  02,  02],
       [ 0,  20,  20,  20,  8,  02],
       [ 1,  1,  0, 108,  8,  02],
       [ 1,  1,  0,  20,  8,  0]])],
 [], []]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1214, 'const': 370, 'code+const': 1584}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('For', 17)]]
import numpy as np
def get_score(board):
  return len(np.min(board,axis=1)[np.min(board,axis=1)>0])*40
def get_time_cap(board, time_caps):
  step = int(board.shape[0]/len(time_caps))
  sum = np.sum(np.sum(board,axis=1).reshape((len(time_caps),step)),axis=1)
  pos = np.arange(sum.shape[0])[sum>0]
  if len(pos)>0:
      return time_caps[pos[0]]
  else:
      return time_caps[-1]
def rotate_right(shape):
  return np.array(shape[::-1].T)
def rotate_left(shape):
  return np.array(shape.T[::-1])
def animate_drop(board, shape, c):
  ans = []
  new_shape = np.array(shape)
  if len(board[0,::])>=shape.shape[1] and np.sum(board[0:shape.shape[0]:,c:c+shape.shape[1]]) == 0:
      for i in range(board.shape[0]-(shape.shape[0]-1)):
          new_board = np.array(board)
          sum = np.max(shape,axis=1)
          posnum = np.arange(sum.shape[0])[sum!=0]
          sumall = np.sum(board != 0)+np.sum(shape != 0)
          if  np.sum( board[ i:i+shape.shape[0]:,c:c+shape.shape[1]: ] ) == 0 :
              new_board[ i:i+shape.shape[0]: , c:c+shape.shape[1]: ] = shape
              ans.append(new_board)
          elif np.sum(board[i:i+shape.shape[0]:,c:c+shape.shape[1]:])!=0 and np.sum((new_board[i:i+shape.shape[0]:,c:c+shape.shape[1]:]+shape)!=0) != np.sum(shape!=0):
              new_board[ i:i+shape.shape[0]: , c:c+shape.shape[1]: ] += shape
              ans.append(new_board)
      return ans
  else:
      return []
def animate_clear(board):
  sum = np.min(board,axis=1)                        
  pos = np.arange(sum.shape[0])[sum>0]
  ans = []
  if len(pos)>0:                                    
      new_board = np.array(board)
      new_board[pos]*=0                             
      ans_board = np.array(new_board)
      ans.append(ans_board)
      sum = np.max(new_board,axis=1)                
      pos0 = np.arange(sum.shape[0])[sum==0]        
      posnum = np.arange(sum.shape[0])[sum!=0]      
      findrnd = np.sum(new_board[posnum[0]+1:pos0[-1]+1],axis=1)
      rnd = len(np.arange(findrnd.shape[0])[findrnd==0])
      for i in range(rnd):
          sum = np.max(new_board,axis=1)                
          pos0 = np.arange(sum.shape[0])[sum==0]        
          posnum = np.arange(sum.shape[0])[sum!=0]      
          new_board[posnum[0]+1:pos0[-1]+1] = new_board[posnum[0]:pos0[-1]]   
          new_board[:posnum[0]+1:,::] *= 0 
          ans_board = np.array(new_board)
          ans.append(ans_board)
      return ans
  else:
      return []

xxx216xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0ValueError('zero-size array to reduction operation minimum which has no identity')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0ValueError('zero-size array to reduction operation minimum which has no identity')
[[]]
bytecount: {'code': 944, 'const': 370, 'code+const': 1314}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 13)], [('For', 19)]]
import numpy as np
def get_score(board):
  a = board != 0
  b = np.sum(a, axis=1) == board.shape[1]
  sc = 40*np.sum(b)
  return sc
def get_time_cap(board, time_caps):
  interval = int(board.shape[0]/len(time_caps))
  ind = np.arange(board.shape[0])
  mask = np.sum(board, axis=1) != 0
  if np.sum(mask) == 0:
    ind1 = board.shape[0] - 1
  else:
    ind1 = np.min(ind[mask])
  ind2 = ind1 // interval
  return time_caps[ind2]
def rotate_right(shape):
  nw = shape.T[:, ::-1]
  return nw
def rotate_left(shape):
  nw = shape[:, ::-1].T
  return nw
def animate_drop(board, shape, c):
  op = []
  cnt = 0
  shapeBool = shape != 0
  selC = board[cnt:cnt + shape.shape[0], c:c + shape.shape[1]]
  selCBool = selC != 0
  chkSelCBot = selCBool & shapeBool[-1, :]
  if np.sum(chkSelCBot) != 0:
    return []
  while np.sum(shapeBool & selCBool) == 0:
    nw = np.array(board)
    nw[cnt:cnt + shape.shape[0], c:c + shape.shape[1]] += shape
    op.append(nw)
    cnt += 1
    selC = board[cnt:cnt + shape.shape[0], c:c + shape.shape[1]]
    selCBool = selC != 0
    if cnt >= board.shape[0] - shape.shape[0] + 1:
      break
  return op
def animate_clear(board):
  op = []
  indR = np.arange(board.shape[0])
  chk = board == np.zeros(board.shape)
  mask = np.sum(chk, axis=1) == 0
  ind = indR[mask]
  indInv = indR[~mask]
  nwB = np.array(board)
  nwB[ind] = 0
  op.append(nwB)
  mask_ = np.sum(nwB, axis=1) != 0
  min0 = np.min(indR[mask_])
  chk0 = np.sum(nwB, axis=1)[min0:] == 0
  ind0 = indR[min0:][chk0]
  if len(ind0) == 0:
    return []
  for i in range(len(ind0)):
    indT = ind0[-1]
    nwBL = list(nwB)
    del nwBL[indT]
    nwBL.insert(0, np.zeros(board.shape[1], dtype=int))
    nwB = np.array(nwBL)
    op.append(nwB)
    mask_ = np.sum(nwB, axis=1) != 0
    min0 = np.min(indR[mask_])
    chk0 = np.sum(nwB, axis=1)[min0:] == 0
    ind0 = indR[min0:][chk0]
  return op

xxx215xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0Time-out: 5s
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 784, 'const': 352, 'code+const': 1136}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 15)]]
import numpy as np
def get_score(board):
    a = np.min(board,axis=1)
    b = board[a>0]
    mango = len(b)*40
    return mango
def get_time_cap(board, time_caps):
    a = np.max(board,axis=1)
    ay = list(a)
    ax = a[a>0]
    if len(ax) == 0:
        return (time_caps[len(time_caps)-1])
    else:    
        ax = list(ax)
        almost = ax[0]
        heh = ay.index(almost)
        length = len(time_caps)
        yes = (heh)//2
        mango = time_caps[yes]
        return mango
def rotate_right(shape):
    shape1 = shape[::-1]
    mango = shape1.T
    return mango
def rotate_left(shape):
    yes = shape.T
    mango = yes[::-1]
    return mango
def animate_drop(board, shape, c):
    mango = []
    row = shape.shape[0]
    column = shape.shape[1]
    copy = np.array(board)
    hmz = np.sum(board != 0) + np.sum(shape != 0)
    for i in range (len(board)-(row-1)):
        copy[i:i+row,c:c+column] += shape
        if np.sum(copy != 0) == hmz:
            mango.append(copy)
            copy = np.array(board)
        else:
            break      
    return mango
def animate_clear(board):
    mango = []
    minvalue = np.min(board, 1)
    forpos = minvalue != 0
    copy = np.array(board)
    copy[forpos,::] *= 0
    mango.append(copy)
    rowrequired = np.sum(np.sum(copy,axis=1)!=0)
    pos = np.arange(len(board))
    check = np.max(copy,axis=1)==0
    if True not in check:
        mango = []
        return mango
    while True in check:
        apple = np.sum(copy,axis = 1)
        grape = apple == 0
        if np.sum(grape) == 0:
            return mango
        c = pos[grape][-1]
        copy = np.array(copy)
        if c != len(board):
            copy[1:c+1]=copy[0:c]
            copy[0] *= 0
            mango.append(copy)
        if np.sum(np.sum(copy[rowrequired:],axis=1)!=0)== rowrequired:
            break
    return mango

xxx033xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 756, 'const': 338, 'code+const': 1094}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 10)]]
import numpy as np
def get_score(board):
  board = np.array(board)
  board = board[np.min(board, axis=1) > 0]
  return len(board)*40
def get_time_cap(board, time_caps):
  board = np.array(board)
  time_caps = np.array(time_caps)
  mul = len(board) / len(time_caps)
  board = board[np.sum(board, axis=1) == 0]
  index = len(board) / mul
  index = int(index)
  try:
    return time_caps[index]
  except:
    return time_caps[-1]
def rotate_right(shape):
  shape = np.array(shape)
  shape = shape[::-1,:].T
  return shape
def rotate_left(shape):
  shape = np.array(shape)
  shape = shape[:, ::-1].T
  return shape
def animate_drop(board, shape, c):
    l = []
    board = np.array(board)
    shape = np.array(shape)
    ro, co = shape.shape
    for i in range(len(board)-ro+1):
        tempboard = np.array(board)
        stempboard = np.sum(tempboard[i:i+ro, c:c+co])
        if not i and stempboard:
          return []
        sshape = np.sum(shape)
        tempboardchange = tempboard[i:i+ro, c:c+co]
        tempboardchange[shape != 0] = shape[shape != 0]
        if stempboard + sshape == np.sum(tempboardchange):
            l.append(np.array(tempboard))
        elif stempboard + sshape != np.sum(tempboardchange):
            return l
    return l
def animate_clear(board):
    l = []
    board = np.array(board)
    tempmask = np.min(board, axis=1) > 0
    if len(board[tempmask]) == 0:
        return []
    board[tempmask] = 0
    l = [board]
    while True:
        board = np.array(board)
        index = len(board) - np.argmin(np.sum(board, axis=1)[::-1])
        board[1:index] = board[:index-1]
        board[0] = 0
        if np.max(board != l[len(l)-1]) == 1:
            l.append(np.array(board))
        else:
            break
    return l

xxx043xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1170, 'const': 422, 'code+const': 1592}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 17)], [('For', 14)]]
import numpy as np
def get_score(board):
    a = (board == 0)
    b = np.sum(a,axis = 1)
    c = b[b==0]
    return len(c)*40
def get_time_cap(board, time_caps):
    a = (board == 0)
    b = np.sum(a,axis = 1)
    c = np.arange(0,board.shape[0],1)
    d = (b != board.shape[1])
    e = c[d == True]
    if len(e) == 0:
        return time_caps[-1]
    else:
        f = e[0] // (board.shape[0]//len(time_caps))
    return time_caps[f]
def rotate_right(shape):
    a = shape[::-1]
    return a.T
def rotate_left(shape):
    a = shape.T
    b = a[::-1]
    return b
def animate_drop(board, shape, c):
    p = []
    nb = np.array(board)
    ns = np.array(shape)
    x = []
    x.append(list(shape[0]))
    x[-1].sort()
    k = x[-1][-1]
    ab = ns==k
    abc = np.sum(ab,axis = 1)
    aa = np.sum(abc)
    ch = nb[0][c:c+shape.shape[1]:]
    ch2 = np.zeros_like(ch,int)
    if False in (ch == ch2):
       return p
    if c >= 0 and board.shape[1]-len(ns[0]) >= c:
        for i in range(nb.shape[0]+1-shape.shape[0]):
            nz = np.zeros_like(nb,int)
            nz[i:i+shape.shape[0],c:c+shape.shape[1]] = shape
            n = nb + nz
            a = n[i:i+shape.shape[0],c:c+shape.shape[1]]
            b =  a==shape
            bb = a==k
            d = np.sum(b,axis = 1)
            dd = np.sum(bb,axis = 1)
            f = np.sum(d)
            ff = np.sum(dd)
            g = shape.shape[1]
            j = b&ab
            hh = np.sum(j,axis = 1)
            h = np.sum(hh)
            if  f >= ff and ff >= aa and h == aa:
                p.append(n)
            else:
                return p
        return p
def animate_clear(board):
    nb = np.array(board)
    nz = np.zeros_like(nb[0])
    c = np.arange(0,board.shape[0],1)
    a = nb==0
    p =[]
    b = np.sum(a,axis = 1)
    d = c[b == 0]
    if d.shape[0] == 0:
        return p
    nb[d] = nz
    p.append(nb)
    nbb = np.array(nb)
    for i in range(nb.shape[0]):
        z = np.zeros_like(nb)
        nn = np.array(p[i])
        cc = np.arange(0,board.shape[0],1)
        aa = nn==0
        bb = np.sum(aa,axis = 1)
        dd = cc[bb == nb.shape[1]]
        d2 = len(dd)
        d3 = board.shape[0]
        z[:i] = np.zeros_like(nb[0])
        z[i+1:dd[-1]+1:] = nn[i:dd[-1]:]
        z[dd[-1]+1:] = nn[dd[-1]+1:]
        p.append(z)
        if False not in (z[:d2] == 0):
            return p

xxx031xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 940, 'const': 390, 'code+const': 1330}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('For', 13)]]
import numpy as np
def get_score(board):
  return sum(np.sum(board > 0,axis=1) == board.shape[1])*40
def get_time_cap(board, time_caps):
  if np.sum(board) == 0:
    return(time_caps[-1])
  else:
    h=np.sum(board,axis=1) > 0
    s=np.arange(0,board.shape[0])
    g=s[h][0]
    m=int(board.shape[0]/len(time_caps))
    return(time_caps[g//m])
def rotate_right(shape):
  return shape.T.reshape(shape.shape[1],shape.shape[0])[:,::-1]
def rotate_left(shape):
  return shape.T.reshape(shape.shape[1],shape.shape[0])[::-1]
def animate_drop(board, shape, c):
  v=[]
  for i in range(board.shape[0]):
    new_board = np.array(board)
    new_shape = np.array(shape)
    new_board[i:new_shape.shape[0]+i,c:new_shape.shape[1]+c:]=new_board[i:new_shape.shape[0]+i,c:new_shape.shape[1]+c:]+new_shape
    f=new_shape > 0
    b=new_board[i:new_shape.shape[0]+i,c:new_shape.shape[1]+c:][f] 
    if np.sum(b) != np.sum(new_shape)  :
      break
    v.append(new_board)
    if np.sum(new_board[-new_shape.shape[0]:,c:new_shape.shape[1]+c:][f]) == np.sum(new_shape):
      break
  return v
def animate_clear(board):
  new_board = np.array(board) 
  b=new_board == 0
  new_board[np.sum(b,axis=1) == 0] = np.zeros((1,new_board.shape[1]))
  s=np.zeros_like(np.sum(new_board,axis=1)) 
  Q=np.sum(new_board,axis=1) == 0
  if np.sum(Q) == 0 :
    return []
  n=np.sum(new_board,axis=1)==0
  x=sum(n)
  tu=[np.array(new_board)]
  for i in range(new_board.shape[1]+100):
    if np.sum(new_board[:x]) == 0:
      break
    b=np.sum(new_board,axis=1)
    k=np.zeros_like(new_board,int)
    h=np.sum(new_board,axis=1) == 0
    g=np.arange(h.shape[0])
    f=np.max(g[h],axis=0)
    k[0] = new_board[f]
    k[1:f+1]=new_board[:f]
    k[f+1:]=new_board[f+1:]
    new_board=k
    tu.append(k)
  return tu

xxx027xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [], []]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 830, 'const': 292, 'code+const': 1122}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('all', 20), ('all', 20)], []]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 13)], []]
import numpy as np
def get_score(board):
    a= board!=0
    c=np.sum(a,axis=1)
    d= c==board.shape[1]
    e= sum(d)
    f=e*40
    return f
def get_time_cap(board, time_caps):
    n=int((board.shape[0])/len(time_caps))
    x=int(board.shape[0]*board.shape[1])
    a=board.reshape( (int(x/(board.shape[1]*n)),int(board.shape[1]*n)) )
    b= a!=0
    c= np.sum(b,axis=1)
    d= c!=0
    e=np.array( time_caps )
    anss=e[d]
    if np.sum(board) == 0:
        ans=time_caps[-1]
    else:
        ans=anss[0]
    return ans
def rotate_right(shape):
    new=shape[::-1]
    ans=new.T
    return ans
def rotate_left(shape):
    new=shape.T
    ans=new[::-1]
    return ans
def animate_drop(board, shape, c):
    import numpy as np
    new_board = np.array(board)
    new_shape = np.array(shape)
    x= new_board==0
    y= new_shape!=0
    a=shape.shape
    b=board.shape
    n=0
    keb=[]
    check=True
    while check==True:
     if n<=b[0]-a[0]:
        if np.sum(x[n:a[0]+n,c:a[1]+c]&y)==np.sum(x[n:a[0]+n,c:a[1]+c]) and np.sum(x[n:a[0]+n,c:a[1]+c]&y)==np.sum(y):
            new_board[n:a[0]+n,c:a[1]+c]+= new_shape
            keb.append(new_board)
            new_board = np.array(board)
            n+=1
        elif x[n:a[0]+n,c:a[1]+c].all()==True and y.all()==False :
            new_board[n:a[0]+n,c:a[1]+c]+= new_shape
            keb.append(new_board)
            new_board = np.array(board)
            n+=1
        else:
            check=False
     else:
        check=False
    return keb
def animate_clear(board):
    pass

xxx036xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 986, 'const': 338, 'code+const': 1324}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 31)]]
import numpy as np
def get_score(board):
    to_bool = (board[:,:] > 0)
    sum_to_bool = np.sum(to_bool, axis=1)
    row_with_no_zero = (sum_to_bool == board.shape[1])
    row = np.arange(board.shape[0])
    numbers = len(row[row_with_no_zero])
    return numbers*40
def get_time_cap(board, time_caps):
    row = board.shape[0]
    to_bool = (board != 0)
    sum_to_bool = np.sum(board, axis=1)
    check = (sum_to_bool != 0)
    index = np.arange(row)[check]
    if len(index) != 0:
        first_index = index[0]
        times = row // len(time_caps)
        chosen = first_index // times
        return time_caps[chosen]
    else: return time_caps[-1]
def rotate_right(shape):
    tp = shape.T
    tp_swap = tp.T[::-1]
    rotate = tp_swap.T
    return np.array(rotate)
def rotate_left(shape):
    transpose = shape.T
    return np.array(transpose[::-1])
def animate_drop(board, shape, c):
    new_board = np.array(board) ; new_shape = np.array(shape)
    row_board = board.shape[0] ; col_board = board.shape[1]
    row_shape = shape.shape[0] ; col_shape = shape.shape[1]
    list_of_board = []
    bool_of_shape = (shape!=0)
    for i in range(row_board): 
        if i+row_shape > row_board or c+col_shape > col_board: break
        if np.sum(new_board[i:i+row_shape,c:c+col_shape][bool_of_shape]) == 0:
            new_board[i:i+row_shape,c:c+col_shape][bool_of_shape] = new_shape[bool_of_shape]
            list_of_board.append(new_board)
            new_board = np.array(board)
        else: break
    return list_of_board
def animate_clear(board):
    new_board = np.array(board)
    row_board = board.shape[0] ; col_board = board.shape[1]
    list_of_board = []
    line = np.sum(board != 0,axis=1)
    not_have_zero = (line == col_board)
    have_zero = (line != col_board)
    index = np.arange(row_board)
    number_of_line = index[not_have_zero]
    if len(number_of_line) != 0:
        list_num = list(number_of_line)
        new_board[list_num] = np.zeros(col_board,int)
        list_of_board.append(new_board)
    else: return [] 
    drop_line = index[have_zero][index[have_zero] < number_of_line[-1]]
    next_board = np.array(new_board)
    packed_shape = new_board[drop_line[0]:drop_line[-1] + 1]
    row = packed_shape.shape[0] ; col = packed_shape.shape[1]
    line_next_b = np.sum(next_board != 0,axis=1)
    not_all0 = (line_next_b != 0)
    all0 = (line_next_b == 0)
    index_not_all0 = index[not_all0]
    index_all0 = index[all0]
    while index_not_all0[0] < index_all0[-1]: 
        last_all0_row = index_all0[-1]
        next_board[1:last_all0_row+1] = next_board[0:last_all0_row]
        next_board[0] = np.zeros(col_board, int)
        list_of_board.append(next_board)
        line_next_b = np.sum(next_board != 0,axis=1)
        not_all0 = (line_next_b != 0)
        all0 = (line_next_b == 0)
        index_not_all0 = index[not_all0]
        index_all0 = index[all0]
        next_board = np.array(next_board)
    return list_of_board

xxx216xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 728, 'const': 384, 'code+const': 1112}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[('all', 3)], [('all', 3)], [], [], [('all', 7)], [('any', 6), ('all', 10), ('all', 5)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 9)]]
import numpy as np
def get_score(board):
  x = (board != 0)
  x = x.all(axis = 1)
  x = (x[x == True])
  x = len(x)*40
  return x
def get_time_cap(board, time_caps):
  x = (board == 0)
  x = x.all(axis = 1)
  x = len(x[x == True])
  if x != board.shape[0]:
    x+=1
  y = board.shape[0]//len(time_caps)
  x = (x/y)
  if x%1 != 0:
    x += 1
  x = int(x)-1
  x = time_caps[x]
  return x
def rotate_right(shape):
  x = shape[::-1]
  x = x.T
  return x
def rotate_left(shape):
  x = shape.T
  x = x[::-1]
  return x
def animate_drop(board, shape, c):
  b = np.array(board)
  s = np.array(shape)
  x = []
  for i in range(s.shape[0],b.shape[0] + 1):
    if all((((b[i - s.shape[0]:i,c:c + s.shape[1]]) == 0) | (s == 0)).all(axis = 1)):
      y = np.array(b)
      y[i - s.shape[0]:i,c:c + s.shape[1]] += s
      x.append(y)
    else:
      break
  return x
def animate_clear(board):
  x = []
  b = np.array(board)
  b[b.all(axis = 1)!= 0] = np.zeros(b.shape[1])
  if not all((b==board).any(axis=1)):
    x.append(b)
  i=board.shape[0]-1
  while i > -1:
    if all((b[:i]==0).all(axis=1)):
      break
    if all(b[i]==0):
      y=np.zeros(b.shape,int)
      y[i:]=b[i:]
      y[1:i+1]=b[:i]
      b=y
      x.append(b)
    else:
      i-=1
  return x

xxx036xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score0.0
[40, 4120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [ array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[ 0,  0,  0,  0,  0,  0],
       [ 0,  2,  2,  2,  0,  0],
       [ 0,  0,  0,  2,  8,  0],
       [ 1,  1,  02, 108,  8,  0],
       [ 1,  1,  02,  0,  8,  0]])],
 [array([[ 0,  0,  2,  2,  2, 0, 0],
       [ 0,  0,  0,  0,  2, 0, 0],
       [ 0,  0,  0,  02, 108,  0],
       [ 1,  1,  0,  8,  8,  0],
       [ 1,  1,  0,  0,  8,  0]]),
  array([[ 0,  0,  0,  0,  0,  0],
       [ 0,  0,  2,  2,  2,  0],
       [ 0,  0,  0,  0, 10,  0],
       [ 1,  1,  0,  8, 10,  0],
       [ 1,  1,  0,  0,  8,  0]])],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
        ... (more)
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0])],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 856, 'const': 352, 'code+const': 1208}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 12)]]
import numpy as np
def get_score(board):
  score = 0
  zero = np.zeros((board.shape[0],board.shape[1]))
  b = np.array(zero<board)
  almost = np.sum(b,axis = 1)
  final = np.array(almost == 5)
  score += np.sum(final)*40
  return score
def get_time_cap(board, time_caps):
  if np.sum(board) > 0 :
    part = board.shape[0] // len(time_caps)
    k = np.arange(board.shape[0])
    zero = np.zeros((board.shape[0],board.shape[1]))
    b = np.array(zero<board)
    first = np.sum((b),axis=1)
    ans = first>0
    rt = k[ans]
    which = rt[0]
    return time_caps[which//part]
  else :
    return time_caps[-1]
def rotate_right(shape):
  shape = shape.T[::,::-1]
  return shape
def rotate_left(shape):
  shape = shape.T[::-1,::]
  return shape
def animate_drop(board, shape, c):
  boo = np.array((board==0)[:,c])
  boo= boo[:-shape.shape[0]:]
  new_shape = np.array(shape)
  ind = 0
  ans = []
  new_board = np.array(board)
  for i in boo :
    new_board = np.array(board)
    if i :
      new_board[ind:ind+shape.shape[0],c:c+shape.shape[1]] += shape
      ans.append(new_board)
      ind += 1
    else : break
  return ans
def animate_clear(board):
  new_board = np.array(board)
  boo = board>0
  boo = np.sum(boo,axis=1) == board.shape[1] 
  b0 = np.arange(0,board.shape[0])[boo]  
  new_board[b0,::] *= 0
  scan = np.min(np.sum(new_board,axis=1)) 
  ans = []
  ans.append(new_board)
  new_board = np.array(new_board[::-1])
  row = 0
  while True :
    if scan == 0 :
      if sum(new_board[row]) == 0 :
        new_board[row:-1] = new_board[row+1::] 
        new_board[-1] = np.zeros_like(new_board[-1],int)
        app = np.array(new_board[::-1])
        ans.append(app)
      else :
        row += 1
      if np.max(new_board[row+1:]) == 0 :
        return ans
    else: return []

xxx027xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 978, 'const': 240, 'code+const': 1218}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 7)], [('While', 11)]]
import numpy as np
def get_score(board):
  x = np.array(np.min(board,1) != 0)      
  return (np.sum(x) * 40)
def get_time_cap(board, time_caps):
  x = np.sum(np.max(board,1) == 0)        
  y = board.shape[0] / len(time_caps)     
  if x == board.shape[0]:                 
    return (time_caps[len(time_caps)-1])  
  else:                                   
    return (time_caps [int(x/y)])
def rotate_right(shape):
  return (shape[::-1].T)
def rotate_left(shape):
  return (shape[::,::-1].T)
def animate_drop(board, shape, c):
  ans = []
  i = 0
  new_board = np.array(board)
  if c <= board.shape[1] - shape.shape[1]:
      while True:
        if i <= board.shape[0] - shape.shape[0] :
          if np.max(board[i:i+shape.shape[0],c:c+shape.shape[1]]) == 0:
            new_board[i:i+shape.shape[0],c:c+shape.shape[1]] += shape
            ans.append(new_board)
            new_board = np.array(board)
            i+=1
          else:
            c_board = np.array(board != 0)
            c_shape = np.array(shape != 0)
            check = c_board[i:i+shape.shape[0],c:c+shape.shape[1]] + 0 + c_shape
            if np.max(check) > 1:
              return ans
              break
            else:
              new_board[i:i+shape.shape[0],c:c+shape.shape[1]] += shape
              ans.append(new_board)
              new_board = np.array(board)
              i+=1
        else:
          return ans
          break
  else:
    return []
def animate_clear(board):
  check = np.min(board,1) != 0
  new_board = np.array(board)
  ans = []
  round = 0
  i = 0
  n_move = True
  n_clear = True
  if np.sum(check) != 0:
    while True:
      if i < board.shape[0] and n_clear:
        if check[i] and i < board.shape[0]:
          new_board[i,::] = 0
        i+=1
      elif i == board.shape[0] and n_clear:
        n_clear = False
        i-=1
      else:
        if np.max(new_board[0:i]) == 0:
            ans.append((new_board))
            new_board = np.array(new_board)  
            return ans 
            break
        if np.max(new_board[i]) == 0 and n_move:
          ans.append((new_board))
          new_board = np.array(new_board)
          round = i
          n_move = False
        if not n_move:
          if round != 0:
            new_board[round] = new_board[round-1]
            round-=1
          else:
            n_move = True
            new_board[0] = 0
        else:
          i-=1
  else:
    return []

xxx211xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 712, 'const': 356, 'code+const': 1068}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[('all', 2)], [('all', 2)], [], [], [('all', 9)], [('all', 5), ('any', 6), ('all', 12)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 11)]]
import numpy as np
def get_score(board):
    a = ((board!=0)).all(axis=1)
    score = (a[a==1].shape[0]) * 40
    return score
def get_time_cap(board, time_caps):
    a = (board==0).all(axis=1)
    line = (a[a==1].shape[0])
    if line < board.shape[0]:
        line += 1
    scope = board.shape[0]//len(time_caps)
    line = line/scope
    if line%1>0:
        line+=1
    line-=1
    line = int(line)
    ans = time_caps[line]
    return ans
def rotate_right(shape):
    a = shape[::-1].T
    return a
def rotate_left(shape):
    a = shape.T[::-1]
    return a
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    shapeH = shape.shape[0]
    shapeW = shape.shape[1]
    ans = []
    for i in range(shapeH,new_board.shape[0]+1):
        if all((((new_board[i-shapeH : i , c : c+shapeW])==0)              | (new_shape==0)).all(axis=1)):
            new_board2 = np.array(new_board)
            new_board2[i-shapeH: i , c : c+shapeW] += new_shape
            ans.append(new_board2)
        else:
            break
    return ans
def animate_clear(board):
    new_board = np.array(board)
    ans = []
    clear_line = (new_board!=0).all(axis=1)
    if clear_line.any():
        new_board[clear_line] = np.zeros(board.shape[1])
        new_board2 = np.array(new_board)
        ans.append(new_board2)
    i = board.shape[0]-1
    while i!=-1:
        if all(new_board[i]==0) and not all((new_board[:i]==0).all(axis=1)):
            new_board[1:i+1] = new_board[:i]
            new_board[0] = np.zeros(new_board.shape[1],int)
            new_board2 = np.array(new_board)
            ans.append(new_board2)
            i = board.shape[0]-1
        i-=1
    return ans

xxx017xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[456, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (2,3) (3,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('zero-size array to reduction operation maximum which has no identity')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 904, 'const': 546, 'code+const': 1450}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 11)], [('For', 10)]]
import numpy as np
def get_score(board):
    a = np.min(board, axis=1)
    return len(a[a!=0])*40
def get_time_cap(board, time_caps):
    a = np.max(board, axis=1)
    if np.sum(a) != 0 :
        ID = len(a[a==0])//(board.shape[0]//len(time_caps))
        return time_caps[ID]
    else :
        return time_caps[0]
def rotate_right(shape):
    a = shape[::-1]
    b = a.T
    return b
def rotate_left(shape):
    a = shape.T
    b = a[::-1]
    return b
def test_part(a, b, i, j):
    return a[i:i+b.shape[0], j:j+b.shape[1]] + b
def add_part(a, b, i, j):
    a[i:i+b.shape[0], j:j+b.shape[1]] += b
    return
def clear_part(a, b, i, j):
    a[i:i+b.shape[0], j:j+b.shape[1]] = 0
    return
def animate_drop(board, shape, c):
    a = []
    new_board = np.array(board)
    new_shape = np.array(shape)
    new_board[new_board > 0] = 1
    new_shape[new_shape > 0] = 1
    N = np.array(board)
    S = np.array(shape)
    i = 0
    while(np.max(test_part(new_board, new_shape, i, c)) == 1):
        add_part(N, S, i, c)
        Z = np.zeros_like(N) + N
        a.append(Z)
        clear_part(N, S, i, c)
        i += 1
    return a
def get_position_full(board):
    ma = np.min(board, axis=1)
    r = np.arange(ma.shape[0])
    return r[ma != 0]
def get_position_0full(board):
    ma = np.max(board, axis=1)
    r = np.arange(ma.shape[0])
    return r[ma == 0]
def move(board, i):
    t = np.zeros_like(board[:i]) + board[:i]
    board[:i] = 0
    board[1:i+1] = t
    return np.zeros_like(board) + board
def animate_clear(board):
    a = []
    x = get_position_full(board)
    if(len(x) == 0):
        return a
    N = np.array(board)
    N[x] = 0
    a.append(np.zeros_like(N) + N)
    xx = get_position_0full(N)
    for i, j in enumerate(xx[::-1]):
        a.append(move(N, i+j))
    return a

xxx017xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError("non-broadcastable output operand with shape (1,3) doesn't match the broadcast shape (2,3)")
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (2,3) (3,3) (2,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 446, 'const': 252, 'code+const': 698}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], []]
import numpy as np
import numpy as np
def get_score(board):
    value = np.min(board,axis = 1)
    value = np.sum(value != 0)
    return 40 * value
def get_time_cap(board, time_caps):
    track = np.arange(board.shape[0])
    value = np.max(board, axis = 1)
    num = track[value != 0]
    if len(num) == 0:
        return time_caps[-1]
    time = len(board) // len(time_caps)
    n = int(num[0])
    return time_caps[n//time]
def rotate_right(shape):
    out = shape.T
    return np.array(out)[::,::-1]
def rotate_left(shape):
    out = shape.T
    return np.array(out)[::-1,::]
def animate_drop(board, shape, c):
    value = np.sum(board!=0)
    value += np.sum(shape!=0)
    h,l = shape.shape ; out = []
    for i in range(len(board)):
        nb = np.array(board)
        nb[i:i+h, c:c+l] += shape
        if np.sum(nb!=0)!= value:
            break
        out.append(nb)
    return out
def animate_clear(board):
    pass

xxx210xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 744, 'const': 388, 'code+const': 1132}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('For', 9)]]
import numpy as np
def get_score(board):
    return np.sum(np.sum(board == 0,axis = 1)==0) * 40
def get_time_cap(board, time_caps):
    if np.sum(board != 0) == 0:
        return time_caps[-1]
    z = np.arange(0,board.shape[0])[np.sum(board != 0,axis = 1)!=0][0]
    return time_caps[int(z//(board.shape[0]/len(time_caps)))]
def rotate_right(shape):
    return shape.T[0::,-1::-1]
def rotate_left(shape):
    return shape.T[-1::-1,0::1]
def animate_drop(board, shape, c):
    k = []
    for r in range(board.shape[0]):
        new_board = np.array(board)
        t = shape.shape[0] ; l = shape.shape[1]
        s = new_board[r:r+t:1,c:c+l:1].shape
        u = new_board[r:r+t:1,c:c+l:1]==0
        if s != shape.shape:
            break
        elif np.sum((u) | (shape==0))==shape.size :
            new_board[r:r+shape.shape[0]:1,c:c+shape.shape[1]:1] += shape 
            k.append(new_board)
        else:
            break
    return k
def animate_clear(board):
    r = np.arange(0,board.shape[0])[np.sum(board == 0,axis=1) == 0]
    if r.shape[0] == 0 : return []
    new_board = np.array(board)
    new_board[r,0::] = 0
    z = board.shape[0]-1
    a = [np.array(new_board)]
    for e in range(board.shape[0]) :
        t = False
        exper = new_board[0:z:1]
        if (np.sum(new_board[z]) == 0) and (np.sum(exper) != 0) :
            new_board[1:z+1:1] = exper
            new_board[0] = 0
            a.append(np.array(new_board))
            t = True
        if t == False :
          z -= 1     
    return a

xxx121xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 05, 05, 04],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 50, 50, 40]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[01, 02, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [01, 02, 0, 0],
       [10, 20, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 692, 'const': 338, 'code+const': 1030}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 9)]]
import numpy as np
def get_score(board):
  minrow = np.min(board, axis = 1)
  getscore =np.sum(minrow != 0 )
  score = getscore*40
  return score
def get_time_cap(board, time_caps):
  maxrow  = np.max (board , axis = 1)
  len_t = len(time_caps)
  len_b = len(board)
  n = len_b / len_t
  if sum(maxrow) != 0:
    ps = np.arange(len_b)[maxrow != 0][0]
    x = int(ps//n)
    return time_caps[x]
  else :
    return time_caps[-1]
def rotate_right(shape):
  tp = shape.T
  return tp[::,::-1]
def rotate_left(shape):
  tp = shape.T
  return tp[::-1,::]
def animate_drop(board, shape, c):
  ans = []
  S = shape.shape
  b = len(board)
  for i in range(b-S[0]+1):
    new_board = np.array(board)
    if np.sum(new_board[i:i+S[0] , c:c+S[1]]) == 0:
      new_board[i:i+S[0] , c:c+S[1]] += shape
    else:
      break
    ans.append(new_board)
  return ans
def animate_clear(board):
  ans = []
  minrow = np.min(board, axis = 1)
  i = minrow != 0
  new_board = np.array(board)
  new_board[i , :] = 0
  clear = np.sum(np.sum(new_board,axis = 1)!= 0)
  while np.sum(np.sum(new_board[-clear:],axis = 1) != 0) != clear:
    locate = np.arange(len(new_board))
    ans.append(new_board)
    r = np.sum(new_board , axis = 1) == 0
    if len(r) == 0 : return [] 
    a = locate[r][-1]
    new_board[1:a+1] = new_board[0:a]
    new_board[0] = 0
    clear = np.sum(np.sum(new_board,axis = 1)!= 0)
  return ans

xxx203xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1498, 'const': 352, 'code+const': 1850}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 20)], [('While', 22)]]
import numpy as np
def get_score(board):
    b=board>0
    s=np.sum(b,axis=1)
    ss=np.sum(s==board.shape[1])
    return ss*40
def get_time_cap(board, time_caps):
    n=board.shape[0]//len(time_caps)
    b=board>0
    s=np.sum(b,axis=1)
    index=np.arange(board.shape[0])
    index=index[s>0]
    if len(index)==0:
        return time_caps[-1]
    i=index[0]
    return time_caps[i//n]
def rotate_right(shape):
    s=shape.T
    s=s[:,::-1]
    return s
def rotate_left(shape):
    s=shape.T
    s=s[::-1,:]
    return s
def animate_drop(board, shape, c):
    r=0
    r1=1
    rshape=shape.shape[0]-1
    rowboard=board.shape[0]
    rowshape=shape.shape[0]
    ans=[]
    shapeonboard=board[r:r+shape.shape[0],c:c+shape.shape[1]]
    s=shape>0
    cutboard=board[0:r1,c:c+shape.shape[1]]
    if r1==shape.shape[0]:
        cutshape=np.array(shape)>0
    else :
        cutshape=shape[-1:rshape-1:-1,:]>0
    checkcutboard=cutboard[cutshape]==0
    r1+=1
    rshape-=1
    can=np.sum(checkcutboard)==np.sum(cutshape)
    while can:
        if r1<shape.shape[0]:
            cutboard=board[0:r1,c:c+shape.shape[1]]
            cutshape=shape[-1:rshape-1:-1,:]>0
            cutshape=cutshape[-1::-1,:]
            checkcutboard=cutboard[cutshape]==0
            r1+=1
            rshape-=1
            can=np.sum(checkcutboard)==np.sum(cutshape)
        elif r1==shape.shape[0]:
            cutboard=board[0:r1,c:c+shape.shape[1]]
            cutshape=np.array(shape)>0
            checkcutboard=cutboard[cutshape]==0
            r1+=1
            rshape-=1
            can=np.sum(checkcutboard)==np.sum(cutshape)
        else:
            newboard=np.array(board)
            newboard[r:r+shape.shape[0],c:c+shape.shape[1]]+=shape
            ans.append(newboard)
            r+=1
            if rowboard-r<rowshape:
                break
            shapeonboard=board[r:r+shape.shape[0],c:c+shape.shape[1]]
            ch=shapeonboard[s]==0
            can=np.sum(ch)==np.sum(s)
    return ans
def animate_clear(board):
    ans=[]
    colboard=board.shape[1]
    zero=np.zeros((1,colboard),int)
    index=np.arange(board.shape[0])
    newboard=np.array(board)
    clear=np.sum(newboard>0,axis=1)==colboard
    i_clear=index[clear]
    if len(i_clear)==0:
        return []
    newboard[i_clear,:]=zero
    rowzero=newboard==0
    rowzero=np.sum(rowzero,axis=1)==colboard
    i_zero=index[rowzero]
    ans.append(newboard)
    first=(np.sum(newboard>0,axis=1)>0)
    if np.sum(first)==0:
        return ans
    firstrow=index[first][0]
    rowzeroafterfirstrow=np.sum(np.sum(newboard[firstrow::,:]==0,axis=1)==colboard)
    while rowzeroafterfirstrow>0:
        replace=newboard[i_zero[-1]-1::-1]
        newboard1=np.zeros(board.shape,int)
        newboard1[-1:i_zero[-1]:-1,:]=newboard[-1:i_zero[-1]:-1,:]
        newboard1[i_zero[-1]:replace.shape[0]-i_zero[-1]:-1,:]=replace
        ans.append(newboard1)
        newboard=newboard1
        firstrow=index[(np.sum(newboard>0,axis=1)>0)][0]
        rowzeroafterfirstrow= np.sum(np.sum(newboard[firstrow::,:]==0,axis=1)==colboard)
        rowzero=newboard==0
        rowzero=np.sum(rowzero,axis=1)==colboard
        i_zero=index[rowzero]
    return ans

xxx038xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 736, 'const': 350, 'code+const': 1086}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[('any', 2)], [('any', 2), ('any', 4)], [], [], [], [('all', 4), ('any', 19)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 10)]]
import numpy as np
def get_score(board):
    b = (board==0).any(axis=1)
    b = (b[b==0]).shape[0]
    sc = b*40
    return sc
def get_time_cap(board, time_caps):
    po = (board>0).any(axis=1)
    po = (po[po==False]).shape[0]
    if board[-1].any()!=False:
        po += 1
    po = po/(board.shape[0]//len(time_caps))
    if po-int(po)!=0:
        po += 1
    po = int(po)-1
    return time_caps[po]
def rotate_right(shape):
    s = np.array(shape)[::-1]
    return s.T
def rotate_left(shape):
    s = np.array(shape).T
    return s[::-1]
def animate_drop(board, shape, c):
    li = []
    for i in range(shape.shape[0],board.shape[0]+1):
        newb = np.array(board)
        news = np.array(shape)
        newb[i-news.shape[0]:i,c:c+news.shape[1]]+=news
        if not any((newb[i-news.shape[0]:i,c:c+news.shape[1]][news!=0])!=(news[news!=0])):
            li.append(newb)
        else:
            break
    return li
def animate_clear(board):
    li = []
    newb = np.array(board)
    po = (newb!=0).all(axis=1)
    if po[po==1].shape[0]>0:
        newb[po] = np.zeros(newb.shape[1])
        newnewb = np.array(newb)
        li.append(newnewb)
    i = board.shape[0]-1
    while i>-1:
        if all(newb[i]==0):
            z = np.array(newb[i])
            newb[1:i+1] = newb[:i]
            newb[0] = z
            newnewb = np.array(newb)
            li.append(newnewb)
        else:
            i-=1
        if not any((newb[:i]!=0).any(axis=1)):
            return li

xxx025xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0Time-out: 5s
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[array([], dtype=float64),
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[array([], dtype=float64)]
bytecount: {'code': 924, 'const': 324, 'code+const': 1248}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 11)]]
import numpy as np
def get_score(board):
    a = np.sum(board > 0, axis = 1)
    return np.sum(a == board.shape[1])*40
def get_time_cap(board, time_caps):
    a = np.argmax((np.sum(board > 0, axis = 1)) > 0)
    if a != 0 or ((np.sum(board > 0, axis = 1)) > 0)[0] != 0:
        return time_caps[a//int(board.shape[0]/len(time_caps))]
    return time_caps[-1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    nboard = np.array(board, int)
    z = np.zeros(board.shape, int)
    s = []
    for i in range(board.shape[0] - shape.shape[0] + 1):
        nshape = np.array(z)
        nshape[i:shape.shape[0]+i,c:c+shape.shape[1]] = np.array(shape, int)
        if np.sum((nshape != 0)&(nboard != 0)) == 0:
            s.append(np.array((nshape + nboard), int))
        else:
            break
    return s
def animate_clear(board):
    s = []
    nboard1 = np.array(board)
    a = np.array([np.sum(board != 0, axis = 1) != board.shape[1]])
    nboard = nboard1*(a.T)
    if np.sum(nboard) == np.sum(nboard1):
        return np.array([])
    s.append(np.array(nboard, int))
    i = 1
    while i in range(1, nboard.shape[0]+1):
        if np.sum(nboard[-i] == 0) == board.shape[1] and i == 1:
            nboard[1:,:] = nboard[0:-i,:]
            nboard[:1,:] = np.zeros((1,nboard.shape[1]), int)
            s.append(np.array(nboard))
        elif np.sum(nboard[-i] == 0) == board.shape[1]:
            nboard[1:-(i-1),:] = nboard[0:-i,:]
            nboard[:1,:] = np.zeros((1,nboard.shape[1]), int)
            s.append(np.array(nboard))
        else:
            i += 1
        if np.sum(nboard[:-i + 1,:]) == 0 and i != 1:
            break
    return s

xxx218xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 848, 'const': 338, 'code+const': 1186}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('While', 9)]]
import numpy as np
def get_score(board):
    min_each_row = np.min(board, axis = 1)
    how_much_not_zero = np.sum(min_each_row != 0)
    return how_much_not_zero*40
def get_time_cap(board, time_caps):
    max_each_row = np.max(board, axis = 1)
    position = np.arange(len(board))
    check_row = position[max_each_row != 0]
    if len(check_row) == 0:
      return time_caps[-1]
    all_position = np.arange(board.shape[0])
    all_postion_row = all_position[check_row]
    postion_row = all_postion_row[0]
    return time_caps[int(postion_row/(board.shape[0]/len(time_caps)))]
def rotate_right(shape):
    return np.array(shape.T[::, ::-1])
def rotate_left(shape):
    return np.array(shape.T[::-1, ::])
def animate_drop(board, shape, c):
    width, length = shape.shape
    drop_output = []
    for slide in range(-shape.shape[0], len(board)-width+1):
      new_board = np.array(board)
      if slide < 0:
        new_board[0:-slide, c:c+length] += shape[slide:]
        if np.sum(new_board != 0) != np.sum(board != 0) + np.sum(shape[slide:] != 0):
          return []
      else:
        new_board[slide:slide+width, c:c+length] += shape
        if np.sum(new_board != 0) != np.sum(board != 0) + np.sum(shape != 0):
          break
        drop_output.append(np.array(new_board))
    return drop_output
def animate_clear(board):
    new_board = np.array(board)
    min_each_row = np.min(board, axis = 1)
    new_board[min_each_row != 0, :] = 0
    position = np.arange(len(board))
    clear_output = []
    clear_output.append(np.array(new_board))
    while True:
      empty_row = np.sum(new_board, axis = 1) == 0
      if np.sum(empty_row) == 0:
        return []
      last_row = position[empty_row][-1]
      if last_row != len(board):
        new_board[1:last_row+1] = new_board[0:last_row]
        new_board[0] = 0
        clear_output.append(np.array(new_board))
      if np.sum(np.sum(new_board[-np.sum(np.sum(new_board, axis = 1) != 0):], axis = 1) != 0)           == np.sum(np.sum(new_board, axis = 1) != 0):
          break
    return clear_output

xxx210xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 954, 'const': 398, 'code+const': 1352}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 15)]]
import numpy as np
def get_score(board):
    no = board[np.min(board, axis=1) > 0]
    sum = np.sum(len(no))*40
    return sum
def get_time_cap(board, time_caps):
    all = np.arange(len(board))
    zone = len(board)//len(time_caps)
    findmin = np.min(board, axis=1)
    findmax = np.max(board, axis=1)
    if np.sum(board[-1]) == 0:
        return time_caps[-1]
    minn = findmin == 0
    maxx = findmax > 0
    pos = all[(minn == True) & (maxx == True)][0]//zone
    return time_caps[pos]
def rotate_right(shape):
    return shape.T[:, ::-1]
def rotate_left(shape):
    return shape.T[::-1, :]
def check(board, shape, c, i):
    if i + len(shape) <= len(board):
        pos = board[i:i+len(shape):, c:c+shape.shape[1]:]
        if np.sum(pos[shape != 0]) == 0:
            return True
    return False
def animate_drop(board, shape, c):
    ans = []
    for i in range(len(board)-len(shape)+1):
        if check(board, shape, c, i):
            new_board = np.array(board)
            new_board[i:i+len(shape):, c:c+shape.shape[1]:][shape != 0] = shape[shape != 0]
            ans.append(new_board)
        else:
          break
    return ans
def animate_clear(board):
    clear = np.array(board)
    num = np.arange(len(board))
    min = np.min(board, axis=1) != 0
    index = num[min]
    clear[index] = np.array([0] * len(board[0]))
    one = np.ones(len(board))
    if np.sum(one[np.sum(np.array(board), axis = 1) == np.sum(clear, axis = 1)]) == len(board):
        return []
    copy_board = np.array(clear)
    con = np.sum(copy_board, axis = 1) != 0
    final = copy_board[con]
    i = len(copy_board)
    ans = []
    while True:
        if np.sum(copy_board[i - 1]) == 0:
            ans.append(copy_board)
            copy = np.array(copy_board)
            copy[0] = np.zeros(len(copy_board[0]))
            copy[1:i] = copy_board[:i - 1]
            copy_board = copy
            i = len(copy_board)
        else:
            i -= 1
        cond = copy_board[len(copy_board) - len(final)::]
        one = np.ones(len(final))
        if np.sum(one[np.sum(cond, axis = 1) == np.sum(final, axis = 1)]) == len(final):
            ans.append(copy_board)
            break
    return ans

xxx219xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 906, 'const': 338, 'code+const': 1244}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 9)], [('While', 12)]]
import numpy as np
def get_score(board):
  all_zero = np.zeros((board.shape[0],board.shape[1]),int)
  is_zero = (board == all_zero)
  return np.sum((np.sum(is_zero,axis=1) == 0))*40
def get_time_cap(board, time_caps):
  all_row = np.arange(board.shape[0])
  split = board.shape[0]/len(time_caps)
  all_zero = np.zeros((board.shape[0],board.shape[1]),int)
  isnot_zero = (board != all_zero)
  if np.sum(isnot_zero) == 0 : return time_caps[-1]
  first_row = all_row[np.sum(isnot_zero,axis=1) > 0][0]
  return time_caps[int((first_row)/split)]
def rotate_right(shape):
  return (shape.T)[:,::-1]
def rotate_left(shape):
  return (shape.T)[::-1,:]
def animate_drop(board, shape, c):
  rshape = shape.shape[0]
  cshape = shape.shape[1]
  emthy_shape = np.zeros_like(shape,int)
  number = int(np.mean(shape[shape != emthy_shape]))
  new_board = np.array(board)
  animate = []
  for i in range(board.shape[0]):
      next_slot = new_board[i:i+rshape,c:c+cshape]
      if np.sum(((shape - next_slot)== number) != (shape == number))==0 :
          new_board[i:i+rshape,c:c+cshape] += shape 
          animate.append(new_board)
          if np.sum(new_board[-1,:] != board[-1,:]) != 0 : break
          new_board = np.array(board) 
      else: break
  return animate
def animate_clear(board):
  new = np.array(board)
  result = []
  all_zero = np.zeros((board.shape[0],board.shape[1]),int)
  is_zero = (board == all_zero)
  new[(np.sum(is_zero,axis=1) == 0),:] = 0
  if np.sum(new != board) == 0 : return result
  result.append(new)
  r = board.shape[0]-1
  while True:
      new = np.array(new)
      if np.sum(new[r,:] != 0) == 0 and np.sum(new[0:r,:] != 0) != 0:
          new[1:r+1]  = new[0:r]
          new[0] = np.zeros_like(new[0])
          result.append(new)
          r = board.shape[0]
      elif np.sum(new[0:r,:] != 0) != 0:
          pass
      else :
          break
      r -=1
  return result

xxx027xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 274, 'const': 240, 'code+const': 514}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [('tolist', 6), ('tolist', 7)], [], [], [], []]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
import numpy as np
def get_score(board): 
    min_row=np.min(board,axis=1)
    boolean=min_row[min_row>0]
    return len(boolean)*40
def get_time_cap(board, time_caps):
    if np.sum(board)==0:
        return time_caps[-1]
    else:
        sum_array=np.sum(board,axis=1)
        sum_array_list=sum_array.tolist()
        ch=sum_array[sum_array>0].tolist()
        index=sum_array_list.index(ch[0])
        seperate=int(board.shape[0]/len(time_caps))
        return time_caps[index//seperate]
def rotate_right(shape):
    return shape[::-1,:].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
    pass

xxx141xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (3,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (3,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (2,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 904, 'const': 324, 'code+const': 1228}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 21)]]
import numpy as np
def get_score(board):
    tf_board = (board == 0)
    t = np.sum(tf_board, axis = 1)
    use = (t[t == 0])
    score = len(use) * 40
    return score
def get_time_cap(board, time_caps):
    size_tc = len(time_caps)
    tf_board = (board == 0)
    t = np.sum(tf_board, axis = 1)
    a = len(t[t == board.shape[1]])
    if a == board.shape[0]:
      return time_caps[-1]
    b = len(board)/len(time_caps)
    c = a//b
    return time_caps[int(c)]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    new_board = np.array(board)
    bz = np.zeros(len(new_board[0]), int)
    bz[c:len(list(shape[0]))+c] = shape
    sum_shape = np.array(shape)
    ans = []
    for i in range(len(new_board)):
      new_board = np.array(board)
      arr = np.array(new_board[i]+bz)
      if sum(arr[c:]) == sum(sum_shape[0]) :
        new_board[i] = arr
        ans.append(new_board)
      else:
        break
    return ans
def animate_clear(board):
    new_board = np.array(board)
    new_board2 = np.array(board)
    layer0 = np.zeros(len(new_board[0]), int)
    tf_board = (new_board == 0)
    point = np.sum(tf_board, axis = 1)
    new_board[point==0] = np.zeros_like(new_board[point==0],int)
    board3 = new_board
    tfb3 = (board3==0)
    tfb = (board==0)
    ptfb3 = np.sum(tfb3,axis = 1)
    ptfb = np.sum(tfb,axis = 1)
    if list(ptfb3) == list(ptfb):
      return []
    else:
      x = np.array(board3)
      ans = []
      ans.append(x)
      num0 = sum(np.sum(board3,axis = 1)==0)
      i=-1
      while True:
        if (sum(np.sum(board3[0:num0], axis=1)) == 0):
          break
        if (sum(board3[i])==0) and (i != -1):
          ceil = board3[-len(new_board):i]
          board3[-len(new_board)+1:i+1] = ceil
          board3[0] = layer0
          x = np.array(board3)
          ans.append(x)
          i = 0
        if (sum(board3[i])==0) and (i == -1):
          ceil = board3[-len(new_board):i]
          board3[1:len(ceil)+1] = ceil
          board3[0] = layer0
          x = np.array(board3)
          ans.append(x)
          i = 0
        i -= 1
    return ans

xxx201xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (3,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (3,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (2,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 744, 'const': 324, 'code+const': 1068}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 16)]]
import numpy as np
def get_score(board):
  b=board>0
  r=np.sum(b,axis=1)
  c1=r==board.shape[1]
  c2=np.sum(c1)
  return c2*40
def get_time_cap(board, time_caps):
  n=board.shape[0]/len(time_caps)
  a=np.sum(board,axis=1)
  a=a>0
  pos=np.arange(board.shape[0])
  new=pos[a]
  if new.shape[0] != 0:
    c=new[0]//n
  else:
    return time_caps[-1]
  return time_caps[int(c)]
def rotate_right(shape):
  new=shape.T
  return new[:,::-1]
def rotate_left(shape):
  new=shape.T
  return new[::-1,:]
def animate_drop(board, shape, c):
    d=[]
    for i in range(board.shape[0]):
      new_board = np.array(board)
      new_shape = np.array(shape)
      b= board[i,c:c+shape.shape[1]] == 0
      c1=np.sum(b)
      if c1 ==shape.shape[1]:
        new_board[i,c:c+shape.shape[1]]=shape
        d.append(new_board)
      else:
        return d
    return d
def animate_clear(board):
    new_board = np.array(board)
    b=board>0
    r=np.sum(b,axis=1)
    c1=r==board.shape[1]
    if np.sum(c1)==0:
      return []
    pos=np.arange(board.shape[0])
    new=pos[c1]
    new_board[new,:]=0
    d=[]
    j=np.array(new_board)
    d.append(j)  
    i = board.shape[0]-1
    while i !=0:       
      if np.sum(new_board[i,:]) != 0:
        i-=1
      else:
        if np.sum(new_board[0:i])==0: break
        new_board[1:i+1,:]=new_board[0:i,:]
        new_board[0,:]=0
        out=np.array(new_board)
        d.append(out)
    return d

xxx037xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0Time-out: 5s
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 956, 'const': 390, 'code+const': 1346}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 6)], [('While', 10)]]
import numpy as np
def get_score(board):
    return sum(np.sum(board != 0,axis=1) == board.shape[1])*40
def get_time_cap(board, time_caps):
    checker=board.reshape((len(time_caps),board.shape[1]*board.shape[0]//len(time_caps)))
    checker2=(np.sum(checker!=0,axis=1)!= 0)
    try :
        return (np.array(time_caps)[checker2][0])
    except:
        return (time_caps[-1])
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    k= 0
    flag=True
    result=[]
    while flag:
        try:
            new_board = np.array(board)
            checker= np.array(board)
            new_shape = np.array(shape)
            put_shape = np.zeros((new_board.shape[0],new_board.shape[1]),int)
            put_shape[k:k+new_shape.shape[0]:,c:c+new_shape.shape[1]:] = new_shape
            checker[k:k+new_shape.shape[0]:,c:c+new_shape.shape[1]:] = new_shape
            if k==0 and (np.sum(checker) != np.sum(put_shape+new_board)):
                flag = False
                return result
            elif np.sum(checker) != np.sum(put_shape+new_board):
                flag = False
            else:
                k+=1
                result.append((put_shape+new_board))
        except:
            break
    return result
def animate_clear(board):
    flag=True
    start=True
    k=0
    row_zero=0
    new_board = np.array(board)
    result=[]
    while flag:
        if start : 
            idx = np.sum(new_board == 0,axis = 1)==0
            zero = np.zeros((new_board.shape[0],new_board.shape[1]),int)
            new_board[idx]=zero[idx]
            row_zero=sum(np.sum(new_board,axis = 1) == 0)
            start=False
            check=np.arange(new_board.shape[0])
            try:
                row=check[np.sum(new_board,axis = 1) == 0][::-1][0]
            except:
                break
            copy_new_board = np.array(new_board)
            result.append((copy_new_board))
            continue
        if k < row_zero :
            check=np.arange(new_board.shape[0])
            row=check[np.sum(new_board,axis = 1) == 0][::-1][0]
            zero2 = np.zeros((new_board.shape[1]))
            new_board[k+1:row+1:,:] = new_board[k:row:,:]
            new_board[0:k+1:,:]=zero2
            copy_new_board = np.array(new_board)
            result.append((copy_new_board))
            k+=1
        else:
            flag=False
    return result

xxx022xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[456, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[array([[2, 0, 0, 0],
       [1, 0, 1, 1]])],
 [array([[0, 2, 0, 0],
       [1, 0, 1, 1]]), array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 0, 05, 5, 0, 0, 0],
       [0, 1, 1, 0, 0, 0, 0, 0],
       [0, 2, 2, 2, 0, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]]),
  array([[01, 1, 0, 5, 5, 0, 0, 0],
       [0, 1, 1, 0, 5, 0, 0, 0],
       [0, 2, 2, 2, 05, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[0, 0, 2, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 0, 0, 2, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 2, 2, 2, 0, 0 ... (more)
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 2, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 0, 0, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 1080, 'const': 358, 'code+const': 1438}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 13)], [('For', 16)]]
import numpy as np
def get_score(board):
    a = np.min(board, axis=1)
    b = np.zeros((1,len(board)), int)
    c = a != b
    return int((sum(c[0]))*40)
def get_time_cap(board, time_caps):
    a = np.max(board, axis=1)
    b = np.zeros((1,len(board)), int)
    c = a == b
    return time_caps[int(int(np.argmin(c))//(len(board)/len(time_caps)))]
def rotate_right(shape):
    a = np.zeros_like(shape.T)
    a[:,:] = shape.T[:,::-1]
    return a
def rotate_left(shape):
    a = np.zeros_like(shape.T)
    a[:,:] = shape.T[::-1,:]
    return a
def animate_drop(board, shape, c):
    nx = np.zeros((len(board)+1,len(board[0])))
    nx[:len(board),:] = board
    nx[-1,:] = 1
    a = np.zeros_like(nx)
    b = a == nx
    am = np.argmin(b,axis=0) 
    ar = np.zeros_like(shape)
    br = ar == shape
    rs = np.argmin(br[::-1],axis=0) 
    d = []
    for i in range((np.min((am[c:c+len(shape[0])])+rs))):
        new_x = np.array(board)
        if i+1 < len(shape):
            new_x[:i+1,c:c+len(shape[0])] += shape[len(shape)-1-i:,:]
        else:
            new_x[i-(len(shape)-1):i+1,c:c+len(shape[0])] += shape
        d.append(new_x)
    return d
def animate_clear(board):
    new_board = np.array(board)
    d = []
    m = np.min(board,axis=1)
    r = np.zeros((1,len(board)),int)
    b = m == r
    b = b.T
    new_board *= b
    mn = np.max(new_board,axis=1)
    bn = mn == r
    bm = mn != r
    br = np.argmax(bm[0])
    if (sum(bn[0])-int(br)) != 0:
        d.append(new_board)
    for i in range(sum(bn[0])-int(br)):
        mn = np.max(new_board,axis=1)
        t = len(mn)-np.argmin(mn[::-1])-1
        nn_board = np.array(new_board)
        nn_board[0,:] = new_board[t,:]
        nn_board[1:t+1,:] = new_board[:t,:]
        nn_board[t+1:,:] = new_board[t+1:,:]
        d.append(nn_board)
        new_board = np.array(nn_board)
    return d

xxx206xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 964, 'const': 338, 'code+const': 1302}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 6)], [('While', 12)]]
import numpy as np
def get_score(board):
  return np.sum(np.sum(board != 0, axis = 1) == board.shape[1]) * 40
def get_time_cap(board, time_caps):
  return time_caps[-1] if np.sum(board) == 0 else time_caps[np.arange(0, board.shape[0])[np.sum(board, axis=1) > 0][0] // (board.shape[0] // len(time_caps))]
def rotate_right(shape):
  return shape.T[:,::-1]
def rotate_left(shape):
  return shape.T[::-1]
def animate_drop(board, shape, c):
  new_board = np.array(board)
  row = 0
  shape_row = 1
  result = []
  while True:
    if row + shape.shape[0] > board.shape[0]:
      break
    if shape_row > shape.shape[0]:
      shape_row = shape.shape[0]
    else:
      row = 0
    shape_mask = shape[shape.shape[0] - shape_row: shape.shape[0], :] != 0
    board_cut = new_board[row: row + shape_row, c: c + shape.shape[1]]
    if np.sum(board_cut[shape_mask]) != 0:
      break
    new_board[row: row + shape_row, c: c + shape.shape[1]][shape_mask] = shape[shape.shape[0] - shape_row: shape.shape[0], :][shape_mask]
    if shape_row == shape.shape[0]:
      result.append(new_board)
    new_board = np.array(board)
    row += 1
    shape_row += 1
  return result
def animate_clear(board):
  clear_row = np.arange(0, board.shape[0])[np.sum(board != 0, axis = 1) == board.shape[1]]
  new_board = np.array(board)
  new_board[clear_row] = np.zeros((board.shape[1]))
  zero_row = np.arange(0, board.shape[0])[np.sum(new_board == 0, axis = 1) == board.shape[1]]
  nonzero = np.arange(0, board.shape[0])[np.sum(new_board != 0, axis = 1) != 0]
  result = [np.array(new_board)]
  if len(zero_row) == 0:
    return []
  if len(nonzero) == 0:
    return [new_board]
  while True:
    zero_row = np.arange(0, board.shape[0])[np.sum(new_board == 0, axis = 1) == board.shape[1]]
    nonzero = np.arange(0, board.shape[0])[np.sum(new_board != 0, axis = 1) != 0]
    if zero_row[-1] < nonzero[0]:
      break
    new_board[1:zero_row[-1]+1, :] = new_board[0:zero_row[-1], :]
    new_board[0, :] = np.zeros((board.shape[1]))
    result.append(np.array(new_board))
  return result

xxx030xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
  [array([[0, 05, 05, 04],
       [0, 50, 50, 40],
       [10, 0, 50, 40],
       [10, 0, 0, 2, 40]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [10, 0, 0, 5, 40],
       [10, 0, 0, 2, 40]])],
 [ array([[0, 50, 50, 40],
       [0, 0, 0, 0],
       [0, 05, 05, 04],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 50, 50, 40],
       [0, 0, 0, 0],
       [0, 05, 05, 04]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 714, 'const': 324, 'code+const': 1038}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('While', 14)]]
import numpy as np
def get_score(board):
  new=np.min(board,axis=1)
  new=new[new>0]
  s = new.shape[0]
  s*=40
  return s
def get_time_cap(board, time_caps):
  n = len(time_caps)
  m,p = board.shape
  k = m/n
  x=[]
  s = np.max(board,axis=1)
  b = np.arange(0,len(s))
  b = b[s>0]
  if b.shape[0]>0:
    x.append(b[0])
    a=x[0]
    a=int(a//k)
    return time_caps[a]
  else:
    return time_caps[-1]
def rotate_right(shape):
  ans=shape[::-1]
  ans=ans.T
  return ans
def rotate_left(shape):
  ans=shape.T
  ans=ans[::-1]
  return ans
def animate_drop(board, shape, c):
  m,n = board.shape
  r,l=shape.shape
  ans=[]
  for i in range(m-r+1):
    new = np.array(board)
    a=new[i:i+r,c:c+l]
    b=a[a==0]
    q=b.shape[0]
    if r*l<=q:
      new[i:i+r,c:c+l]=shape
      ans.append(new)
    else:
        break
  return ans
def animate_clear(board):
    r,c = board.shape
    r-=1
    ans=[]
    new = np.array(board)
    m = new==0
    m = np.sum(m,axis=1)
    new[m==0]=0
    p = new==board
    x,y=p.shape
    if np.sum(p)!=x*y:
        ans.append(new)
        s = np.array(new)
        while 1<=r:
            if np.sum(s[r])==0 and np.sum(s[r-1])!=0:
                s[r]=s[r-1]
                s[r-1]*=0
                ans.append(s)    
            r-=1
    return ans

xxx027xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 808, 'const': 338, 'code+const': 1146}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 15)]]
import numpy as np
def get_score(board):
    logic = np.sum(board == 0, axis=1)
    return sum(logic == 0) * 40
def get_time_cap(board, time_caps):
    pos = np.arange(1, board.shape[0]+1)
    logic = np.sum(board != 0, axis=1)
    min_line = pos[logic != 0]
    if len(min_line) == 0:
        return time_caps[-1]
    else:
        return time_caps[-(-min_line[0] // (board.shape[0] // len(time_caps) ) ) - 1]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:, ::-1].T
def animate_drop(board, shape, c):
    show = list()
    for i in range(board.shape[0]-shape.shape[0]+1):
        place = board[i:shape.shape[0]+i, c:c+shape.shape[1]] != 0
        new_shape = shape != 0
        if sum(place[new_shape]) == 0:
            new_board = np.array(board)
            new_board[i:shape.shape[0] + i, c:c+shape.shape[1]][new_shape] = shape[new_shape]
            show.append(np.array(new_board))
        else:
            break
    return show
def animate_clear(board):
    show = list()
    new_board = np.array(board)
    pos = np.arange(board.shape[0])
    logic = np.sum(board == 0, axis=1) == 0
    if sum(logic == 1) == 0:
        return show
    new_board[pos[logic == 1]] = np.zeros(board.shape[1])
    show.append(np.array(new_board))
    for_zero = np.sum(new_board != 0, axis=1) == 0
    zero = pos[for_zero == 1]
    block = pos[for_zero != 1]
    new_boards = np.zeros_like(new_board, int)
    while zero[-1] > block[0]:
        i = zero[-1]
        new_boards[0] = np.zeros(board.shape[1])
        new_boards[1:i+1] = new_board[:i]
        new_boards[i+1:] = new_board[i+1:]
        show.append(np.array(new_boards))
        for_zero = np.sum(new_boards != 0, axis=1) == 0
        zero = pos[for_zero == 1]
        block = pos[for_zero != 1]
        new_board = new_boards
    return show

xxx206xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1120, 'const': 390, 'code+const': 1510}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('For', 15)]]
import numpy as np
def get_score(board):
    r = np.arange(0,board.shape[0])
    c = np.sum(board[r,::1] != 0,axis=1) == board.shape[1]
    s = board[r,:][c]
    return s.shape[0]*40
def get_time_cap(board, time_caps):
    ct = len(time_caps)
    r = np.arange(0,board.shape[0])
    c = np.sum(board[r,::1] != 0,axis=1) != 0
    if np.sum(c) == 0:
        return time_caps[-1]
    else:
        return time_caps[r[c][0]//(board.shape[0]//ct)]
def rotate_right(shape):
    if shape.shape[0] == 1:
        return shape.reshape((shape.shape[1],shape.shape[0]))
    else:
        a = shape.T
        return a[:,::-1]
def rotate_left(shape):
    if shape.shape[0] == 1:
        return shape.reshape((shape.shape[1],shape.shape[0]))[::-1,::-1]
    else:
        a = shape.T
        return a[::-1,:]
def animate_drop(board, shape, c):
    result = []
    a = shape != 0
    for i in range(board.shape[0]-shape.shape[0]+1):
        new_board = np.array(board)
        b = (new_board[i:i+shape.shape[0],c:c+shape.shape[1]][a])
        if np.sum(b) == 0:
            y = np.zeros_like(new_board,int)
            y[i:i+shape.shape[0],c:c+shape.shape[1]] = shape
            x = new_board + y
            result.append(x)
        else:
            break
    return result
def animate_clear(board):
    rb = board.shape[0]
    cb = board.shape[1]
    a = board[:,::1] != 0
    pos = np.sum(a,axis=1) == cb
    x = []
    new_board = np.array(board)
    b = np.arange(0,rb)
    new_board[b[pos],:] = [0]*cb
    pos = new_board[b,:] == [0]*cb
    c = np.sum(pos,axis=1) == cb
    d = b[c]
    x.append(np.array(new_board))
    for n in range(1,d.shape[0]+1):
        new_board[n:d[-1]+1,:] = new_board[n-1:d[-1],:]
        new_board[n-1,:] = 0
        b = np.arange(0,rb)
        pos = new_board[b,:] == 0
        c = np.sum(pos,axis=1) == cb
        d = b[c]
        if np.sum(np.array(new_board) == x[-1]) != board.shape[0]*board.shape[1]:
            x.append(np.array(new_board))
    if len(x) == 1 and np.sum(x == np.array(board)) == board.shape[0]*board.shape[1]:
        return []
    else:       
        return x

xxx042xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [], []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1026, 'const': 370, 'code+const': 1396}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 5)], [('For', 12)]]
import numpy as np
def get_score(board):
    return np.sum(np.sum(board != 0, axis=1) == board.shape[1]) * 40
def get_time_cap(board, time_caps):
    idxs = np.arange(board.shape[0])[ np.sum(board, axis=1) != 0 ]
    if len(idxs) == 0: return time_caps[-1]
    return time_caps[ idxs[ 0 ] // (board.shape[0]//len(time_caps)) ]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    boards = []
    k = 0
    while True:
        new_board = np.array(board)
        fill_shape = new_board[k:k+shape.shape[0], c:c+shape.shape[1]]
        if fill_shape.shape == shape.shape:
            if np.sum(((fill_shape == 0) & (shape != 0)) == (shape != 0)) == shape.shape[0]*shape.shape[1]:
                rows = (np.arange(shape.shape[0])).reshape(shape.shape[0],1) + np.zeros(shape.shape[1], int)
                cols = (np.arange(shape.shape[1])).reshape(1,shape.shape[1]) + np.zeros(shape.shape[0], int).reshape(shape.shape[0],1)
                i = rows[ shape + fill_shape != shape ]
                j = cols[ shape + fill_shape != shape ]
                if np.sum( i < ( np.argmax(shape, axis=0) )[ j ] ) > 0 : break
                new_board[k:k+shape.shape[0], c:c+shape.shape[1]] = shape + fill_shape
                boards.append(new_board)
                k += 1
            else: break
        else: break
    return boards
def animate_clear(board):
    boards = []
    new_board = np.array(board)
    if board.shape[1] in np.sum(board != 0, axis=1):
        new_board[list( np.arange(board.shape[0])[ np.sum(board != 0, axis=1) == board.shape[1] ] )] = 0
        boards.append(new_board)
    if np.sum( np.sum(new_board, axis=1) != 0 ) != 0 and np.sum( np.sum(new_board, axis=1) == 0 ) != 0:
        x = np.arange(new_board.shape[0])[ np.sum(new_board, axis=1) != 0 ][ 0 ]
        y = np.arange(new_board.shape[0])[ np.sum(new_board, axis=1) == 0 ][ -1 ] + 1
        k = np.sum( np.sum(new_board[x:y] == 0, axis=1) == new_board.shape[1] )
        for i in range(k):
            j = np.arange(new_board.shape[0])[ np.sum(new_board, axis=1) == 0 ][ -1 ]
            new_board = new_board[ [j] + list(range(j)) + list(range(j+1,board.shape[0])) ]
            boards.append(new_board)
    return boards

xxx028xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 864, 'const': 374, 'code+const': 1238}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 12)]]
import numpy as np
def get_score(board):
    b = np.min(board, axis = 1)
    score = len(b[b != 0]) * 40
    return score
def get_time_cap(board, time_caps):
    row = len(board)
    b = np.max(board, axis=1)
    num = np.arange(row)
    if np.max(board) == 0:
        return time_caps[-1]
    first = num[b!=0][0]
    gtm = time_caps[first//(row//len(time_caps))]
    return gtm
def rotate_right(shape):
    s = shape[::-1].T
    return s
def rotate_left(shape):
    s = shape[..., ::-1].T
    return s
def animate_drop(board, shape, c):
    ani = []
    for i in range(len(board)):
        new_board = np.array(board)
        if i + len(shape) <= len(new_board) and np.sum(board[i:i+shape.shape[0]:, c:c+shape.shape[1]:][shape != 0]) == 0:
            new_board[i:i+shape.shape[0], c:c+shape.shape[1]][shape != 0] = shape[shape != 0]
            ani.append(new_board)
        else:
            break
    return ani
def animate_clear(board):
    ani = []
    row = -2
    new_board = np.array(board)
    m = np.min(board, axis=1) != 0
    new_board[m] = [0]*len(board[0])
    num = np.max(new_board, axis=1) == 0
    num = len(num[num])
    if num == 0:
        return []
    while True:
        if np.sum(new_board[-1]) == 0:
            ani.append(np.array(new_board))
            new_board[1:] = new_board[0:-1]
            new_board[0] = np.zeros(len(board[0]))
        elif np.sum(new_board[row]) == 0:
            ani.append(np.array(new_board))
            new_board[1:row+1] = new_board[0:row]
            new_board[0] = np.zeros(len(board[0]))
        else:
            row -= 1
        if np.sum(new_board[0:num]) == 0:
            ani.append(np.array(new_board))
            break
    if len(ani) >= 2 :    
        one = np.ones(len(board))
        a = np.sum(ani[0], axis = 1)
        b = np.sum(ani[1], axis = 1)
        if np.sum(one[a == b]) == len(board):
            ani = ani[1:]
    return ani

xxx218xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 798, 'const': 352, 'code+const': 1150}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 9)], [('For', 16)]]
import numpy as np
def get_score(board):
  result = board > 0
  sumrs = np.sum((result),axis = 1)
  out = np.sum(sumrs == len(board[0]))
  return int(out*40)
def get_time_cap(board, time_caps):
  r,c = board.shape
  size = r*c
  new_board = board.reshape((len(time_caps),size//len(time_caps)))
  sum_b = np.sum(new_board, axis = 1)
  pos = np.arange(len(time_caps))
  result = sum_b != 0
  if len(pos[result]) != 0:
    return time_caps[pos[result][0]]
  else:
    return time_caps[-1]
def rotate_right(shape):
  out = shape.T
  return np.array(out[:,::-1])
def rotate_left(shape):
  out = shape.T
  return np.array(out[::-1,:])
def animate_drop(board, shape, c):
  out = []
  rows,cols = shape.shape
  rowb,colb = board.shape
  nb = np.sum(board == 0)
  ns = np.sum(shape != 0)
  range1 = list(np.arange(0,rowb-rows+1))
  for i in range1:
    new_board = np.array(board)
    new_board[i:i+rows,c:c+cols] += shape
    if np.sum(new_board == 0) == nb-ns:
      out.append(new_board)
  return out
def animate_clear(board):
  out = []
  row,col = board.shape
  new_board = np.array(board)  
  new_board1 = new_board > 0
  sumnb = np.sum(new_board1 , axis = 1)
  new_board_for_row = sumnb == col
  if np.sum(new_board_for_row) == 0:
    return out
  pos = np.arange(0,row)
  new_board[pos[new_board_for_row]] = 0
  new_board1 = new_board
  out.append(np.array(new_board))
  c = 0
  for i in range(1,row+1):
    e = row-i+c
    if np.sum(new_board1[e]) == 0:
      new_board1[1:e+1] = new_board1[0:e]
      new_board1[0] = 0
      new_board2 = np.array(new_board1)
      out.append(new_board2)
      c += 1
  if list(out[-1].reshape(row*col)) == list(out[-2].reshape(row*col)):
    out.pop(-1)
  return out

xxx205xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1138, 'const': 366, 'code+const': 1504}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 14)], [('While', 24)]]
import numpy as np
def get_score(board):
    new_board = np.array(board)
    count = len(new_board[0])
    value_board = new_board > 0
    sumvalue = (np.sum(value_board,axis=1) >= count)
    return np.sum(sumvalue)*40
def get_time_cap(board, time_caps):
    new_board = np.array(board)
    new_time_caps = time_caps
    period = new_board.shape[0]//len(new_time_caps)
    value_board = new_board > 0
    sumvalue = np.sum(value_board,axis=1) >0
    if np.sum(sumvalue)==0 :
        return new_time_caps[-1]
    index = np.arange(new_board.shape[0])
    count =index[sumvalue][0]//period
    return new_time_caps[count]
def rotate_right(shape):
    new_shape = np.array(shape)
    ans = new_shape[::-1,]
    return ans.T
def rotate_left(shape):
    new_shape = np.array(shape)
    ans = new_shape.T
    return ans[::-1,]
def animate_drop(board, shape, c):
    new_shape = np.array(shape) ; new_board = np.array(board)
    ans = []
    if True in (new_board[0][c:c+new_shape.shape[1]:]+new_shape[-1]!=new_shape[-1]):
        return ans
    if np.sum(np.zeros_like(new_shape,int)!=new_board[0:new_shape.shape[0],c:c+new_shape.shape[1]])!=0:
        return ans
    start = 0
    check_board = new_board[start:start+ new_shape.shape[0],c:c+new_shape.shape[1]]
    check_shape = (new_shape != 0)
    check_plate = check_board[check_shape]==0
    while np.sum(check_plate) == np.sum(check_shape):
        nnew_board = np.array(new_board)
        nnew_board[start:start+ new_shape.shape[0],c:c+new_shape.shape[1]] += new_shape
        ans.append(nnew_board)
        start +=1
        if start == new_board.shape[0]- new_shape.shape[0] +1 :
            break
        check_board = new_board[start:start+ new_shape.shape[0],c:c+shape.shape[1]]
        check_plate = check_board[check_shape]==0
    return ans
def animate_clear(board):
    new_board = np.array(board)
    ans = []
    if get_score(board) == 0:
        return []
    check_animate = np.zeros_like(new_board, int)
    check_board = np.sum(new_board!=0,axis=1)== new_board.shape[1]
    index_no = np.arange(new_board.shape[0])
    zeros_in = index_no[check_board]
    clear_board = np.array(board)
    clear_board[zeros_in,:]=0
    ans.append(clear_board)
    all_zero = np.sum(clear_board==0,axis=1)
    n = all_zero==clear_board.shape[1]
    index_zeros = np.arange(clear_board.shape[0])
    index_zeros_no = index_zeros[n]
    while np.sum(clear_board[0:index_zeros_no[-1],:])!=0:
        nclear_board = np.zeros_like(clear_board,int)
        nclear_board[1:index_zeros_no[-1]+1,:]=clear_board[:index_zeros_no[-1],:]
        nclear_board[index_zeros_no[-1]+1:,:]=clear_board[index_zeros_no[-1]+1:,:]
        ans.append(nclear_board)
        clear_board = nclear_board
        all_zero = np.sum(clear_board==0,axis=1)
        n = all_zero==clear_board.shape[1]
        index_zeros = np.arange(clear_board.shape[0])
        index_zeros_no = index_zeros[n]
    return ans

xxx028xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0., 0., 0., 0.],
       [0., 5., 5., 4.],
       [1., 0., 5., 4.],
       [1., 0., 2., 4.]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0., 0., 0., 0.],
       [0., 5., 5., 4.],
       [0., 0., 0., 0.],
       [0., 0., 0., 0.]]),
  array([[0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 5., 5., 4.],
       [0., 0., 0., 0.]]),
  array([[0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 5., 5., 4.]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0., 0., 0., 0.],
       [1., 2., 0., 0.],
       [0., 0., 0., 0.],
       [1., 0., 2., 4.],
       [0., 0., 0., 0.],
       [0., 0., 1., 1.]]),
  array([[0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [1., 2., 0., 0.],
       [0., 0., 0., 0.],
       [1., 0., 2., 4.],
       [0., 0., 1., 1.]]),
  array([[0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [0., 0., 0., 0.],
       [1., 2., 0., 0.],
       [1., 0., 2., 4.],
       [0., 0., 1., 1.]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 720, 'const': 366, 'code+const': 1086}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 6)], [('While', 12)]]
import numpy as np
def get_score(board):
    r,c = board.shape
    bool_array = board > 0  
    h_sum = np.sum(bool_array, axis=1)  
    return np.sum(h_sum == c) * 40
def get_time_cap(board, time_caps):
    h_sum = np.sum(board, axis=1)
    bool_sum = h_sum > 0  
    index = np.argmax(bool_sum)  
    multiplier = len(h_sum) / len(time_caps)
    if True not in bool_sum:  
        return time_caps[-1]
    else:
        return time_caps[int(index // multiplier)]
def rotate_right(shape):
    return shape.T[:, ::-1]
def rotate_left(shape):
    return shape.T[::-1, :]
def animate_drop(board, shape, c):
    s = shape.shape
    buffer = []
    i = 0
    while True:
        new_board = np.array(board)
        field = new_board[i : s[0] + i, c : s[1] + c]
        if field.shape != s or np.sum(field[shape != 0] != 0) != 0:
            break
        new_board[i : s[0] + i, c : s[1] + c] += shape
        buffer.append(new_board)
        i += 1
    return buffer
def animate_clear(board):
    buffer = []
    new_board = np.array(board)
    s = new_board.shape
    bool_min = np.min(new_board, axis=1) != 0
    copy_board = np.array(new_board)
    new_board[bool_min, :] = 0
    if not np.sum(new_board != copy_board) == 0:
        buffer.append(new_board)
    while True:
        bool_max = np.max(new_board, axis=1) == 0
        index = len(new_board) - np.argmax(bool_max[::-1]) - 1
        if True not in bool_max:
            break
        blank_board = np.zeros(s)
        blank_board[1:index+1, :] = new_board[:index, :]  
        blank_board[index+1:, :] = new_board[index+1:, :]  
        if np.sum(blank_board != new_board) == 0:  
            break
        new_board = blank_board
        buffer.append(new_board)
    return buffer

xxx211xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1150, 'const': 324, 'code+const': 1474}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 14)]]
import numpy as np
def get_score(board):
    a=np.min(board,axis=1)
    return (np.sum(a!=0))*40
def get_time_cap(board, time_caps):
    if np.sum(board)==0:
        return time_caps[-1]
    l=len(time_caps)
    scol=np.max(board,axis=1)
    dex=np.arange(board.shape[0])
    dexmax=dex[scol>0]
    ans=(dexmax[0])//(board.shape[0]/l)
    return time_caps[int(ans)]
def rotate_right(shape):
    return shape.T[:,-1::-1]
def rotate_left(shape):
    return shape.T[-1::-1,:]
def animate_drop(board, shape, c):
    new=board[:,c:]
    s=shape.shape
    ans=[]
    a=np.arange(board.shape[0]*board.shape[1]).reshape((board.shape[0],board.shape[1]))
    b=a[board>0]
    for i in range (board.shape[0]):
        newboard=np.array(board)
        if board.shape[0]-i>=shape.shape[0]:
            newboard[i:s[0]+i:,c:c+s[1]:]=newboard[i:s[0]+i:,c:c+s[1]:]+shape
            fi=np.array(newboard)
            d=a[fi>0]
            if len(d)-len(b)==np.sum(shape>0):
                ans.append(fi)
            else:
                break
        else:
            break
    return ans
def animate_clear(board):
    newboard=np.zeros_like(board,int)+board 
    ans=[]
    c=0
    newboard=np.array(board)
    min1=np.min(newboard,axis=1)
    max2=np.max(min1)
    if max2>0:
        newboard[min1>0,:]=newboard[min1>0,:]*0
        fi=np.array(newboard)
        ans.append(fi)
    i=0
    while i<newboard.shape[0]:
        if (np.sum(newboard[-(i+1),:])==0) and (np.sum(newboard[:newboard.shape[0]-i:,:])==0):
            break 
        if (np.sum(newboard[-(i+1),:])==0) :
            cop=np.array(newboard)
            newboard[:(newboard.shape[0]-i):,:]=newboard[:(newboard.shape[0]-i):,:]*0
            if i==0:
                newboard[i+1:(newboard.shape[0]-i):,:]=newboard[i+1:(newboard.shape[0]-i):,:]+cop[i:(cop.shape[0]-i-1):,:]
                c+=1
            else:
                newboard[c+1:(newboard.shape[0]-i):,:]=newboard[c+1:(newboard.shape[0]-i):,:]+cop[c:(cop.shape[0]-i-1):,:]
                c+=1
            fi=np.array(newboard)
            ans.append(fi)
        else :
            i+=1  
    return ans

xxx033xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1116, 'const': 551, 'code+const': 1667}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 14)], [('While', 13)]]
import numpy as np
def get_score(board):
    min_board = np.min(board,axis = 1)
    min_board[min_board > 0] = 1
    total_allzero = np.sum(min_board)
    return total_allzero*40
def get_time_cap(board, time_caps):
    numrow = np.shape(board)[0]
    rowslist = np.arange(0,numrow)
    pos = np.sum(board,axis = 1)
    numlist = rowslist[pos > 0]
    if len(numlist) == 0:
        return time_caps[-1]
    num = numlist[0]
    index = int(num//(numrow/len(time_caps)))
    if index > len(time_caps)-1:
        return time_caps[-1]
    return time_caps[index]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    out = []
    row_shape = np.shape(shape)[0]
    column_shape= np.shape(shape)[1]
    row_board = np.shape(board)[0]
    column_board= np.shape(board)[1]
    nshape = np.array(shape)
    fix = np.max(nshape)
    n2shape = np.array(nshape)
    n2shape[n2shape != 0] = -1
    nboard = np.array(board)
    count = 0
    for i in range(row_board):
        nboard = np.array(board)
        bigboard = np.zeros((row_board+row_shape-1,column_board),int)
        bigboard2 = np.array(bigboard)
        bigboard[row_shape-1:,:] = nboard
        bigboard2[i:i+np.shape(shape)[0],c:c+np.shape(shape)[1]] = n2shape
        fusboard = np.array(bigboard)
        fusboard[bigboard2 != 0] = bigboard2[bigboard2 != 0]
        if list(fusboard[bigboard != 0]) != list(bigboard[bigboard != 0]):
            break
        if count >= row_shape-1:
            fusboard[fusboard == -1] = fix
            out.append(fusboard[row_shape-1:,:])
        count += 1
    if count < row_shape:
        return []
    return out
def animate_clear(board):
    out = []
    row = np.shape(board)[0]
    col = np.shape(board)[1]
    srowlist = np.arange(0,row)
    nboard = np.array(board)
    pos = np.min(nboard,axis=1)
    if len(pos[pos > 0]) == 0:
        return []
    nboard[srowlist[pos > 0]] = np.array([0]*col)
    out.append(nboard)
    while check(nboard):
        revboard = nboard[::-1]
        rowlist = list(range(0,row))
        pos = np.sum(revboard,axis = 1)
        pos = list(pos)
        zero = pos.index(0)
        rowlist.remove(zero)
        use = revboard[rowlist,:]
        use = list(use)
        use.append(np.array([0]*col))
        use = np.array(use)
        nboard = use[::-1]
        out.append(nboard)
    return out
def check(board):
    nboard = np.array(board)
    strboard = np.zeros_like(nboard,str)
    strboard = nboard
    pos = np.sum(nboard,axis = 1)
    pos[pos > 0] = 1
    use = str(pos)
    use = use.strip('[]')
    use = use.split(' ')
    use = ''.join(use)
    if '10' in use:
        return True
    else:
        return False

xxx043xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 308, 'const': 248, 'code+const': 556}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
import numpy as np
def get_score(board):
    x = np.min(board,axis = 1)
    return np.sum(x != 0) * 40
def get_time_cap(board, time_caps):
    x = np.max(board,axis = 1)
    y = np.arange(len(board))
    z = y[x != 0]
    if len(z) == 0: return time_caps[-1]
    z = int(z[0])
    idx = ceil(z+1,len(board)//len(time_caps))-1
    return time_caps[idx]
def rotate_right(shape):
    return np.array(shape.T[::,::-1])
def rotate_left(shape):
    return np.array(shape.T[::-1,::])
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
    pass
def ceil(a,b):
    return -(-a//b)

xxx038xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0ValueError('cannot reshape array of size 24 into shape (2,8)')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 258, 'const': 240, 'code+const': 498}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [('For', 4)], [], [], [], []]
import numpy as np
def get_score(board):
    b = np.min(board, axis =1) 
    c = b[b != 0]
    return len(c)*40
def get_time_cap(board, time_caps):
    b = board.reshape((len(time_caps),(board.shape[1])*2))
    c = np.max(b, axis =1)
    for i in range(len(c)):
        if c[i] != 0:
            return time_caps[i]
def rotate_right(shape):
    b = shape[::-1,::]
    return(b.T)
def rotate_left(shape):
    b = shape[::,::-1]
    return(b.T)
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
    pass

xxx215xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 922, 'const': 338, 'code+const': 1260}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 11)], [('While', 19)]]
import numpy as np
def get_score(board):
    r, c = board.shape
    a = np.sum((board != 0), axis=1)
    b = np.sum(a == c)
    return b*40
def get_time_cap(board, time_caps):
    r, c = board.shape
    if np.sum(board) == 0:
        return time_caps[-1]
    else:
        row_per_cap = r//len(time_caps)
        quadrant = np.arange(0,r,row_per_cap)
        pos_quadrant = np.arange(0,len(quadrant),1)
        a = np.sum((board != 0),axis=1)
        pos = np.arange(0,a.shape[0],1)
        min0 = pos[(a != 0)][0]
        find = np.max(pos_quadrant[(min0 - quadrant) >= 0])
        return time_caps[find]
def rotate_right(shape):
    rotateR = shape.T
    rotateR[:,:] = shape.T[:,::-1]
    return rotateR
def rotate_left(shape):
    rotateL = shape.T
    rotateL[:,::-1] = shape.T[::-1,::-1]
    return rotateL
def animate_drop(board, shape, c):
    boardz, shapez = np.array(board), np.array(shape)
    height_shape, wide_shape = shape.shape
    height_board, wide_board = board.shape
    before = np.sum(boardz != 0) + np.sum(shapez != 0)
    lstAns = []
    k = 0
    while k <= (height_board - height_shape):
        new_board = np.array(boardz)
        new_board[k:k+height_shape, c:c+wide_shape] += shapez
        after = np.sum(new_board != 0)
        if before != after:
            break
        else:
            lstAns.append(new_board)
        k += 1
    return lstAns
def animate_clear(board):
    r,c = board.shape
    newboard = np.array(board)
    a = np.sum((newboard != 0), axis=1)
    newboard[a == c] = 0
    lstAns = []
    lstAns.append(np.array(newboard))
    pos_row = np.arange(0,r,1)
    num_row_nozero = np.sum((np.sum(newboard,axis=1) != 0) != 0)
    ind_all_zero = (np.sum(newboard, axis=1) == 0) 
    if np.sum(ind_all_zero) == 0:
        return []
    x = np.sum(newboard[-num_row_nozero:,:], axis=1) 
    while np.sum(x != 0) != num_row_nozero:
        ind_all_zero = (np.sum(newboard, axis=1) == 0)
        lastZero_row = pos_row[ind_all_zero][-1]
        if lastZero_row != r:
            newboard[1:lastZero_row+1] = newboard[0:lastZero_row]
            newboard[0,:] = 0
            lstAns.append(np.array(newboard))
        x = np.sum(newboard[-num_row_nozero:,:], axis=1) 
    return lstAns

xxx040xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 654, 'const': 338, 'code+const': 992}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [('transpose', 2)], [('transpose', 2)], [], []]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('For', 9)]]
import numpy as np
def get_score(board):
    m = np.min(board,axis=1)
    count = np.sum(m>0)
    return count*40
def get_time_cap(board, time_caps):
    m = np.max(board,axis=1)==0
    idx = np.sum(m)*len(time_caps)//len(board)
    if idx == len(time_caps):
        return time_caps[-1]
    return time_caps[idx]
def rotate_right(shape):
    newshape = np.transpose(shape)
    return newshape[::,::-1]
def rotate_left(shape):
    newshape = np.transpose(shape)
    return newshape[::-1]
def animate_drop(board, shape, c):
    l = []
    row,col = np.shape(shape)
    for i in range(len(board)-(row-1)):
        check = board[i:i+row,c:c+col]*shape
        newboard = np.array(board)
        if np.max(check) == 0:
            newboard[i:i+row,c:c+col] += shape
            l.append(newboard)
        else:
            break
    return l
def animate_clear(board):
    new = np.array(board)
    x = np.min(board,axis=1) != 0
    new[x] = np.zeros(np.shape(board)[1])
    l = [new]
    lock = np.array(new)
    count = 0
    for i in range(len(board)-1,-1,-1):
        new = np.array(new)
        if np.sum(lock[i]) == 0:
            if np.sum(lock[:i]) == 0:
                break
            new[1:i+count+1] = new[0:i+count]
            new[0] = np.zeros(np.shape(board)[1])
            count += 1
            l.append(new)
    if count == 0: return []
    else: return l

xxx024xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0TypeError("'list' object is not callable")
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0TypeError("'list' object is not callable")
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 05, 05, 04],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 50, 50, 40]]),
  array([[0, 0, 0, 0],
       [0, 05, 05, 04],
       [0, 0, 0, 0],
       [0, 50, 50, 40]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 05, 05, 04],
       [0, 50, 50, 40]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[01, 2, 0, 0],
       [2, 2, 2, 0],
       [1, 1, 0, 0]])],
 [array([[0, 0],
       [1, 0, 02, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [01, 02, 0, 0],
       [0, 0, 0, 0],
       [1, 20, 02, 04],
       [10, 0, 0, 2, 40],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [01, 02, 0, 0],
       [10, 20, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 1072, 'const': 366, 'code+const': 1438}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep:
   [[], [], [], [], [('all', 17), ('all', 12), ('all', 14)], [('all', 27), ('all', 24), ('any', 17), ('any', 21)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 10)], [('While', 13), ('For', 16), ('For', 19)]]
import numpy as np
def get_score(board):
    a = np.min(board,axis = 1)
    a = a[a > 0]   
    return len(a)*40
def get_time_cap(board, time_caps):
    a = np.max(board,axis = 1)
    b = len(time_caps)
    a = a.reshape((b,len(a)//b))
    a = np.max(a,axis = 1)
    c = np.arange(1,len(a)+1,1)
    time_caps = np.array(time_caps)
    if len(time_caps[a*c != 0]) != 0:
        return time_caps[a*c != 0][0]
    return time_caps[-1]
def rotate_right(shape):
    b = shape[::-1]
    return b.T
def rotate_left(shape):
    b = shape[::1,::-1]
    return b.T
def animate_drop(board, shape, c):
    total = []
    new_board = np.array(board)
    new_shape = np.array(shape)
    zeros_board = np.zeros((new_shape.shape[0],new_shape.shape[1]),int)
    zeros_x_board = np.zeros((new_shape.shape[1]),int)
    x = new_shape.shape[1]
    y = new_shape.shape[0]
    anew_board = np.array(board)
    for i in range(new_board.shape[0]):
        g = np.array(anew_board)
        if np.all(new_board[i:i+y,c:c+x] == zeros_board)&(i == 0):
            anew_board[i:i+y,c:c+x] = new_shape
        if np.all(new_board[i:i+y,c:c+x] == zeros_board)&(i != 0):
            anew_board[i:i+y,c:c+x] = new_shape
            anew_board[i-1,c:c+x] = zeros_x_board          
        if np.all(g == anew_board):break
        total(anew_board)
    return total
def animate_clear(board):
    total = []
    t = True
    new_board = np.array(board)
    a = np.min(new_board,axis = 1)
    a[a==0] = -1
    a[a>0] = 0
    a[a<0] = 1
    a = a.reshape(len(a),1)
    new_board = a*new_board
    zeros_board = np.zeros((new_board.shape[1]),int)
    total.append(new_board)    
    while t == True:
        move = []
        anew_board = np.array(new_board)
        for i in range(new_board.shape[0]):
            if (np.any(new_board[i] != zeros_board)) & (i != new_board.shape[0]-1):
                move.append(i)
        for j in move:
            b = 1
            if (np.any(new_board[j+b] != zeros_board))&(j+b != new_board.shape[0]-1):
                move.pop(move.index(j)+1)
                b += 1
            if np.all(new_board[j+b] == zeros_board):
                new_board[j+1:j+b+1,:] = new_board[j:j+b,:]
                new_board[j] = zeros_board               
        if np.all(anew_board == new_board):
            break
        total.append(new_board)
    return total

xxx022xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (4,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (6,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (3,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 488, 'const': 298, 'code+const': 786}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 10)], []]
import numpy as np
def get_score(board):
    x = np.min(board,axis=1)
    y = x[x!=0]
    return len(y)*40
    pass
def get_time_cap(board, time_caps):
    l = len(time_caps)
    n = board.shape[0]/l
    pos = np.arange(board.shape[0])
    a = np.max(board,axis = 1)
    b = a.reshape(a.shape[0])
    bol = pos[a != 0]
    if len(bol) != 0:
        ans = bol[0]
    else:
        return time_caps[-1]
    return time_caps[int(ans//n)]
    pass
def rotate_right(shape):
    shape2 = shape[::-1,::]
    return shape2.T
    pass
def rotate_left(shape):
    shape2 = shape[::-1,::]
    shape3 = shape2[::-1,::-1]
    return shape3.T
    pass
def animate_drop(board, shape, c):
    nb = np.array(board)
    ns = np.array(shape)
    li = []
    b2 = nb[::,c:len(shape):]
    zero_check = np.sum(b2,axis=1)
    pos = np.arange(zero_check.shape[0])
    pas = pos[zero_check == 0]
    for i in pas:
        if pas[0] != 0:
            li.append([])
        else:
            nb[i,c::] = shape
            li.append(nb)
            nb = np.array(board)
    return li
    pass
def animate_clear(board):
    pass

xxx027xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0.0, 120.0]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 740, 'const': 332, 'code+const': 1072}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 9)]]
import numpy as np
def get_score(board):
  k = np.min(board,axis=1)
  j = np.sum((k/k)[k!=0])
  return j*40
def ceil(a,b):
  return -(-a//b)
def get_time_cap(board, time_caps):
  x = np.max(board,axis = 1)
  y = np.arange(len(board))
  z = y[x != 0]
  if len(z) == 0:
    return time_caps[-1]
  z = int(z[0])
  lol = ceil(z+1,len(board)//len(time_caps))-1
  return time_caps[lol]
def rotate_right(shape):
  x = np.array(shape.T[::,::-1])
  return x
def rotate_left(shape):
  x = rotate_right(shape)
  x = rotate_right(x)
  x = rotate_right(x)
  return x
def animate_drop(board, shape, c):
  a = np.sum(board != 0) + np.sum(shape != 0)
  b,q = shape.shape
  lmao = list()
  for i in range(len(board)-b + 1):
    new_board = np.array(board)
    new_board[i:i+b,c:c+q] += shape
    if np.sum(new_board != 0) != a: 
      break
    lmao.append(np.array(new_board))
  return lmao
def animate_clear(board):
  new_board = np.array(board)
  new_board[np.min(board,axis=1) != 0,:] = 0
  nr = np.sum(np.sum(new_board,axis = 1) != 0)
  pos = np.arange(len(board))
  lmao = list()
  lmao.append(np.array(new_board))
  while(True):
    lol = np.sum(new_board,axis =1) == 0
    if np.sum(lol) == 0 : 
      return []
    c = pos[lol][-1]
    if c != len(board):
      new_board[1:c+1] = new_board[0:c]
      new_board[0] = 0
      lmao.append(np.array(new_board))
    if np.sum(np.sum(new_board[-nr:],axis = 1) != 0) == nr: 
      break
    return lmao

xxx032xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (2,3) (3,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 798, 'const': 336, 'code+const': 1134}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 5)], [('While', 14)]]
import numpy as np
def get_score(board):
    score = 0
    t = np.sum(board != 0, axis = 1)
    al = 40* (t == board.shape[1])
    score = sum(al)
    return score
def get_time_cap(board, time_caps):
    t = np.sum(board != 0, axis = 1)
    cap = board.shape[0]//len(time_caps)
    time_caps += (cap-1)*(time_caps)
    time_caps.sort()
    if np.sum(t) == 0:
        return time_caps[-1]
    sum0 = sum(t == 0)
    return time_caps[sum0]
def rotate_right(shape):
    ns = shape[::-1,::]
    nsT = ns.T
    return nsT
def rotate_left(shape):
    ns = shape[::,::-1]
    nsT = ns.T
    return nsT
def animate_drop(board, shape, c):
    new_shape = np.array(shape)
    get = []
    a = 0
    while np.sum(board[a:a+shape.shape[0],c:c+shape.shape[1]]*shape) == 0:
        new_board = np.array(board)
        if new_board[a:a+shape.shape[0],c:c+shape.shape[1]].shape != shape.shape:
            break
        new_board[a:a+shape.shape[0],c:c+shape.shape[1]] = shape+ board[a:a+shape.shape[0],c:c+shape.shape[1]]
        a+= 1       
        get += [new_board]
    return get
def animate_clear(board):
    result = []
    new_board = np.array(board)
    t = np.sum(board == 0,axis = 1)
    y = (t != 0)
    x = y.reshape(len(y),1)
    h = x*new_board
    a = h.shape[0]-1
    if [False] in x:
        result += [h]
        g = np.array(h)
        num = np.sum(g != 0,axis= 1)
        num0 = np.sum(num == 0)
        while a > 0:
            if np.max(g[0:num0]) == 0:
                break
            elif np.max(g[a]) == 0:
                g[1:a+1] = g[0:a]
                g[0] = 0
                result += [np.array(g)]            
            else:
                a -= 1            
    return result

xxx030xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 824, 'const': 364, 'code+const': 1188}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('For', 13)]]
import numpy as np
def get_score(board):
        return (np.sum(np.min(board,axis = 1)!=0))*40
def get_time_cap(board, time_caps):
        slot = board.shape[0]/len(time_caps)
        x = np.sum(board, axis = 1 )
        b = x!=0
        if np.sum(b) == 0 :
                return time_caps[-1]
        else:
                w = np.arange(1,board.shape[0]+1)
                inx = int(np.ceil(w[b][0]/slot)-1)
                return time_caps[inx]
def rotate_right(shape):
        ans = shape.T
        ans = ans[:,::-1]
        return ans
def rotate_left(shape):
        ans = shape.T
        ans = ans[::-1,:]
        return ans
def animate_drop(board, shape, c):
        new_board = np.array(board)
        ans = []
        shape_len = shape.shape[0]
        shape_len2 = shape.shape[1]
        new_board2 = np.array(board)
        for i in range(new_board.shape[0]-(shape_len-1)):
                b = shape != 0 
                a = new_board2[i:shape_len+i,c:shape_len2+c][b]
                if np.sum(a==0) == np.sum(b):             
                        new_board[i:shape_len+i,c:shape_len2+c] = new_board[i:shape_len+i,c:shape_len2+c] + shape
                        ans.append(new_board)
                        new_board = np.array(new_board2)
                else:
                        break
        return ans
def animate_clear(board):
        ans = []
        new_board =np.array(board)
        x = np.min(new_board,axis = 1) != 0
        if np.sum(x) == 0 :
                return ans
        new_board[x,:] = np.array([0])
        ans.append(new_board)
        count = 0
        for i in range(new_board.shape[0])[::-1]:
                i += count
                if np.sum(new_board[:i,:])==0:
                        return ans
                if np.sum(new_board[i,:]) == 0:         
                        b = np.array([True]*new_board.shape[0])
                        b[i] = False
                        new_board = new_board[b]
                        temp = np.zeros((new_board.shape[0]+1,new_board.shape[1]),int)
                        temp[1:,:] = new_board
                        new_board = temp
                        ans.append(new_board)
                        count += 1
        return ans

xxx203xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (4,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (5,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (3,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 684, 'const': 312, 'code+const': 996}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [], [('tolist', 18), ('tolist', 19), ('all', 22)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 10)]]
import numpy as np
def get_score(board):
  a=np.min(board, axis=1)
  a=np.sum(a>=1)
  return a*40
def get_time_cap(board, time_caps):
  h=board.shape[0]//len(time_caps)
  a=np.max(board, axis=1)
  if np.sum(a)==0:
    return time_caps[-1]
  a=a>=1
  a=np.argmax(a)
  return time_caps[a//h]
def rotate_right(shape):
    return shape.T[::,::-1]
def rotate_left(shape):
    return shape.T[::-1,::]
def animate_drop(board, shape, c):
    l=[]
    lenOfShape=shape>0
    lenOfShape=np.sum(lenOfShape)
    nb=board*0
    lenOfboard=board>0
    lenOfboard=np.sum(lenOfboard)
    for i in range(board.shape[0]):
      nb[i,c:c+lenOfShape:]=shape
      nb=nb+board
      x=nb==0
      x=np.sum(x)
      if x!=lenOfboard+lenOfShape:
        break
      l+=[nb]
      nb=board*0
    return l
def animate_clear(board):
    l=[]
    nb=board
    nb=np.min(nb,axis=1)
    nb=nb==0
    nb = nb.reshape((1,board.shape[0]))
    nb=nb.T
    board=board*nb
    l+=[board]
    while 1:
      x=np.sum(board,axis=1)
      x=x[::-1]
      if min(x)>0:
        return []
      index0=np.argmin(x)
      n=[]
      n+=[list([0]*board.shape[1])]
      n+=board[:board.shape[0]-index0-1:].tolist()
      n+=board[board.shape[0]-index0::].tolist()
      board=np.array(n)
      if len(l)>0:
        if (board==l[-1]).all():
          break
      l+=[board]
    return l

xxx203xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 896, 'const': 362, 'code+const': 1258}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('For', 12)]]
import numpy as np
def get_score(board):
  fact = (board == 0)
  point = np.sum(fact,axis = 1)
  ans = (point == 0)
  score = np.sum(ans) * 40
  return score
def get_time_cap(board, time_caps):
  if np.sum(board) == 0:
      return time_caps[-1]
  else:
      fact = (board == 0)
      point = np.sum(fact,axis = 1)
      True_pow = point == board.shape[1]
      tieb = True_pow.reshape((len(time_caps),int(board.shape[0]/len(time_caps))))
      tieb_sum = np.sum(tieb,axis=1)
      True_pow2 = tieb_sum == tieb.shape[1]
      pos = np.argmin(True_pow2)
      return time_caps[int(pos)]
def rotate_right(shape):
  return shape[::-1].T
def rotate_left(shape):
  return shape[::,::-1].T
def animate_drop(board, shape, c):
  ans = []
  new_board = np.array(board)
  new_shape = np.array(shape)
  for i in range(new_board.shape[0] - new_shape.shape[0] + 1):
      new_shape = np.array(shape)
      board_empty = new_board[i:i+shape.shape[0],c:c+shape.shape[1]] == np.array([0])
      shape_empty = new_shape == np.array([0])
      blank_space = board_empty | shape_empty
      if False in blank_space:
          break
          new_board = np.array(board)
      else:
          new_board[i:i+shape.shape[0],c:c+shape.shape[1]] += new_shape
          jarb = np.array(new_board)
          ans.append(jarb)
          new_board = np.array(board)
  return ans
def animate_clear(board):
  ans = []
  c = 0
  new_board = np.array(board)
  rose = new_board != np.array([0])
  count_zero = np.sum(rose,axis=1)
  change_mhai = count_zero == new_board.shape[1]
  if True in change_mhai:
      new_board[change_mhai] = np.zeros_like(new_board.shape[1])
      ans.append(new_board)
  news_board = np.array(new_board)
  for i in range(1,board.shape[0]+1):
      if False not in (new_board[-i] == np.zeros_like(new_board.shape[1])) and False in (new_board[0:-i] == np.zeros_like(new_board.shape[1])):
          c += 1
          news_board[1:new_board.shape[0]-i+c,::] = news_board[0:new_board.shape[0]-i-1+c,::]
          news_board[0,::] = np.zeros_like(new_board.shape[1])
          jiapin = np.array(news_board)
          ans.append(jiapin)
  return ans

xxx030xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[]]
bytecount: {'code': 1112, 'const': 390, 'code+const': 1502}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('For', 20)]]
import numpy as np
def get_score(board):
    zero = np.zeros_like(board,int)
    zero[board > 0] = 1
    count = np.sum(zero > 0,axis = 1) 
    one = np.ones_like(count,int)
    one[count != board.shape[1]] = 0
    return sum(one)*40
def get_time_cap(board, time_caps):
    if np.sum(board) != 0:
      pos = np.arange(board.shape[0])
      sum_in_row = np.sum(board,axis = 1)
      first_not0_r = pos[sum_in_row > 0][0]
      times = len(board)//len(time_caps)
      return time_caps[first_not0_r//times]
    else:
      return time_caps[-1]
def rotate_right(shape):
    if len(shape.shape) <= 1:
      return shape.reshape(1,shape.shape[0]).T
    else:
      return shape.T[:,::-1]
def rotate_left(shape):
    if len(shape.shape) <= 1:
      return shape[::-1].reshape(1,shape.shape[0]).T
    else:
      return shape[::-1,:].T[::-1,::-1]
def animate_drop(board, shape, c):
    all_step = []
    new_board = np.array(board)
    first = board[:shape.shape[0],c:c+shape.shape[1]]
    if 0 <= c <= board.shape[1]-shape.shape[1]:
      if np.sum(first) == 0:
        for i in range(len(board)-len(shape)+1):
          if np.sum(new_board[i:i+shape.shape[0],c:c+shape.shape[1]]) == 0 :
            new_board[i:i+shape.shape[0],c:c+shape.shape[1]] = shape
            all_step.append(new_board)
            new_board = np.array(board)
        return all_step
      else: return all_step
    else: return all_step
def animate_clear(board):
    final = []
    zero = np.zeros_like(board,int)
    new_board = np.array(board)
    one_board = np.ones_like(board,int)
    one_board[new_board == 0] = 0
    pos = np.arange(len(board))
    lis_p = list(pos)
    full_rr = pos[np.sum(one_board,axis = 1) == board.shape[1]]
    lis_row = list(full_rr)
    full_zero = pos[np.sum(one_board,axis = 1) == 0]
    lis_zero = list(full_zero)
    lis_a = lis_row + lis_zero
    lis_a.sort()
    full_r = np.array(lis_a)
    if len(full_r) != 0: 
      new_board[full_r] = np.zeros((1,board.shape[1]),int)
      final.append(new_board)
      for e in full_r[::-1]:
          lis_p.remove(e)
          ad = np.array(new_board)
          ad = ad[lis_p]
          zero[zero.shape[0]-ad.shape[0]:] = ad
          final.append(zero)
          x = pos[np.sum(zero, axis = 1) != 0][0]
          if np.sum(zero[:x]) == 0 and  len(pos[x:][np.sum(zero[x:], axis =1) == 0]) == 0 : break
          zero = np.zeros_like(board,int)
      return final
    else: return final

xxx001xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('operands could not be broadcast together with shapes (4,) (2,3) ')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (6,) (3,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('operands could not be broadcast together with shapes (3,) (3,2) ')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0Time-out: 5s
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 784, 'const': 328, 'code+const': 1112}
check_import({'allowable': ['numpy']}): [[('numpy.core', 1)]]
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 14)]]
from numpy.core import shape_base
import numpy as np
def get_score(board):
  column_size = board.shape[1]
  count_true_elements_in_each_row = np.sum(board > 0, axis=1)
  count_only_true_row = sum(count_true_elements_in_each_row == column_size)
  result = count_only_true_row  * 40
  return result
def get_time_cap(board, time_caps):
  time_caps_size = len(time_caps)
  group_size = int(board.shape[0] / time_caps_size)
  pos_index = np.arange(board.shape[0])
  count_true_elements_in_each_row = np.sum(board > 0, axis=1)
  all_index = pos_index[count_true_elements_in_each_row != 0]
  time_cap_index = time_caps_size - 1
  if(len(all_index) > 0):
    time_cap_index = int(all_index[0]/group_size)
  result = time_caps[time_cap_index]
  return result
def rotate_right(shape):
  transpose_board = shape.T
  result = transpose_board[::,::-1]
  return result
def rotate_left(shape):
  transpose_board = shape.T
  result = transpose_board[::-1]
  return result
def animate_drop(board, shape, c):
  board_list = []
  for i in range(board.shape[0]):
    new_board = np.array(board)
    shape_board = new_board [i,c::]
    sum = np.sum(shape_board)
    if(i == 0 and sum != 0):
      break
    if(sum != 0):
      continue
    new_board [i,c::] = shape_board + shape
    board_list.append(new_board)
  return board_list
def animate_clear(board):
  board_list = []
  i=0
  n=0
  n_board = np.array(board)
  min = np.min(n_board,axis=1)
  sum = np.sum(min)
  filter = min > 0
  n_board[filter] = 0
  if(sum != 0):
    board_list.append(n_board)
    while(i<n_board.shape[0] ):
        new_board = np.array(n_board)
        shape_board = new_board [n_board.shape[0] - i-1]
        sum = np.sum(shape_board)
        if(sum != 0):
          i = i+1;
          board_forexit = n_board[0:n_board.shape[0] - i-1]
          if(np.sum(board_forexit)<=0):
            break;
          continue
        else :
            if(i>0) :
                new_board [i:n_board.shape[0] - i] = n_board[i-1:n_board.shape[0]-i - 1]
                new_board [0:i] = 0
            else :
                new_board [1:n_board.shape[0] ] = n_board[0:n_board.shape[0]- 1]
                new_board [0] = 0
            n_board = new_board
            board_list.append(new_board)
  return board_list

xxx037xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[array([[2, 0, 0, 0],
       [1, 0, 1, 1]])],
 [array([[0, 2, 0, 0],
       [1, 0, 1, 1]]), array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 0, 0, 5, 0, 0, 0],
       [0, 1, 1, 0, 0, 0, 0, 0],
       [0, 2, 2, 2, 0, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]]),
  array([[0, 1, 0, 5, 5, 0, 0, 0],
       [0, 1, 1, 0, 5, 0, 0, 0],
       [0, 2, 2, 2, 0, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]]),
  array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[0, 0, 2, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 0, 0, 2, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 2, 2, 2, 0, 0 ... (more)
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 2, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 0, 0, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1148, 'const': 424, 'code+const': 1572}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('For', 23)]]
import numpy as np
def get_score(board):
  b = board==0
  b = np.sum(b,axis=1)
  c = np.sum(b==0)
  return c*40
def get_time_cap(board, time_caps):
  b = board.reshape((len(time_caps),(board.shape[0]//len(time_caps))*board.shape[1]))
  b = b!=0
  b = np.sum(b,axis=1)
  c = b!=0
  if True not in c:
    return time_caps[-1]
  else:
    d = np.array(time_caps)
    d = d[c]
    return d[0]
def rotate_right(shape):
  a = np.array(shape)
  a = a[::-1]
  return a.T
def rotate_left(shape):
  a = rotate_right(shape)
  b = rotate_right(a)
  c = rotate_right(b)
  return c
def animate_drop(board, shape, c):
    b = np.array(board)
    b1 = np.sum(b)
    a = np.array(shape)
    l = []
    for i in range(b.shape[0]):
      g = np.zeros_like(b)
      if i<a.shape[0]:
        g[0:i+1:,c:c+a.shape[1]:] = a[a.shape[0]-i-1:a.shape[0]:,:]
        g1 = g==0 ; b0 = b==0
        g1 += b0 ; g += b
        if b1+np.sum(a[a.shape[0]-i-1:a.shape[0]:,:])==np.sum(g) and False not in g1:
          l.append(g)
        else:
          break
      else:
        g[i-a.shape[0]+1:i+1:,c:c+a.shape[1]:] = a[:,:]
        g1 = g==0 ; b0 = b==0
        g1 += b0 ; g += b
        if b1+np.sum(a)==np.sum(g) and False not in g1:
          l.append(g)
        else:
          break
    return l
def clear_step(b,c,i):
    z = np.zeros_like(b)
    x = np.array(c)
    x[:] = True
    x[i] = False
    b = b[x]
    z[1:,:] = b[:,:]
    return z
def animate_clear(board):
    b = np.array(board)
    b1 = b==0
    c = np.sum(b1,axis=1)
    c = c!=0
    if False not in c:
      return []
    d = c.reshape(b.shape[0],1)
    c1 = np.sum(d,axis=1)
    c1 = c1.reshape(b.shape[0],1)
    b *= c1
    b1 = b!=0
    c = np.sum(b1,axis=1)
    c = c!=0
    c[0] = True
    d = c.reshape(b.shape[0],1)
    c1 = np.sum(d,axis=1)
    c1 = c1.reshape(b.shape[0],1)
    c1 = c1[::-1]
    l = [] ; q = 1
    l.append(b)
    for i in range(c1.shape[0]):
      if c1[i]==0:
        b = clear_step(b,c,c1.shape[0]-i-q)
        q -= 1
        l.append(b)
    return l

xxx036xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[array([0, 0, 0, 0, 0, 0]), array([0, 0, 0, 0, 0, 1]), array([0, 056, 056, 056, 156, 1])45,
 array([045, 0, 0, 1, 1, 1]), array([0, 0, 1, 1, 1, 1]), array([0, 1, 1, 1, 1, 1]),
 array([1, 1, 1, 1, 1, 1])45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (4,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (6,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (3,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0OSError("stdout's size exceeds 100")
[[0 0 0 0]
 [0 0 0 0]
 [0 0 0 0]
 [0 0 0 0]]
[[0 5 5 4]
 [1 0 5 4]
 [1 0 2 4]
 [0 0 0 0]]
[[0 5 5 4]...(more)
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
  [array([[0, 05, 05, 04],
       [01, 0, 05, 04],
       [01, 0, 02, 04],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 05, 05, 04],
       [01, 0, 05, 04],
       [01, 0, 02, 04]])],
  [array([[0, 05, 05, 04],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [ array([[0, 50, 50, 40],
       [10, 05, 5, 4],
       [10, 0, 0, 2, 40],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 50, 50, 40],
       [10, 05, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 50, 50, 40],
       [10, 0, 20, 40],
       [0, 05, 05, 04]])],
  [array([[0, 0, 0, 0],
       [10, 0, 50, 40],
       [10, 0, 20, 40],
       [0, 02, 02, 04]])]]
test_animate_clear_20.0OSError("stdout's size exceeds 100")
[[0 2 0 0]
 [2 2 2 0]
 [1 1 0 0]]
[[1 2 0 0]
 [0 0 0 0]
 [1 0 2 4]
 [0 0 0 0]
 [0 0 0 0]
 [0 0 1 1]]...(more)
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [20, 20, 20, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 10, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [20, 20, 20, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[0 0 0 0]
 [0 0 0 0]
 [0 0 0 0]
 [0 0 0 0]]
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 508, 'const': 266, 'code+const': 774}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [], [('all', 24)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 12)], [('For', 22)]]
import numpy as np
def get_score(board):
 all=np.min(board,axis=1)
 new=all[all != 0]
 return len(new)*40
def get_time_cap(board, time_caps):
 part=len(board)//len(time_caps)
 new_board=np.max(board,axis=1)
 return new_board
def rotate_right(shape):
 return shape[::-1].T
def rotate_left(shape):
 return shape.T[::-1]
def animate_drop(board, shape, c):
 l=[]
 for i in range(len(board)):
   new_board = np.array(board)
   if new_board[i,c] != 0:
     break
   new_board[i,c::]=shape
   l.append(new_board)
 return l
def animate_clear(board):
 zero_board=np.zeros_like(board,int)
 k=np.arange(board.shape[0])
 k1=k.reshape((board.shape[0],1))
 k2=k1+zero_board
 n=k2[board ==0]
 new_n=set(k)-set(n)
 new_n=list(new_n)
 new_board = np.array(board)
 new_board[new_n,:]=0
 print(new_board)
 l=[]
 i=0
 for i in range(len(new_board),0,-1):
   new1_board = np.array(new_board)
   if new1_board[i::].all()==0:
     new1_board[1:i]=new1_board[:i-1]
     new1_board[0,:]=0
   l.append(new1_board)
 return l

xxx023xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('operands could not be broadcast together with shapes (2,4) (3,4) ')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (2,3) (3,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('operands could not be broadcast together with shapes (2,2) (3,2) ')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 780, 'const': 338, 'code+const': 1118}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('For', 14)]]
import numpy as np
def get_score(board):
  b=np.sum((board>0),axis=1)
  return len(b[b==board.shape[1]])*40
def get_time_cap(board, time_caps):
  n=board.shape[0]//len(time_caps)
  b=np.sum(board,axis=1)
  c=np.arange(b.shape[0])
  d=(b!=0)
  if np.sum(d) != 0:
    x=c[b>0]
    return time_caps[x[0]//n]
  else:
    return time_caps[-1]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    l=[]
    for i in range(board.shape[0]):
      nb = np.array(board)
      ns = np.array(shape)
      check=nb[i:ns.shape[0]+i,c:c+ns.shape[1]]
      a=(check!=0)
      s=(ns!=0)
      if np.sum(a&s) ==0:
        nb[i:ns.shape[0]+i,c:c+ns.shape[1]]=ns  
        l.append(nb)
    return l
def animate_clear(board):
    l=[]
    nb = np.array(board)
    f=np.sum(nb!=0,axis=1)
    c=np.arange(f.shape[0])
    ind=c[(f==0)|(f==nb.shape[1])]
    if ind.shape[0]==0:
      return []
    nb[ind, ::]=np.array([0]*(nb.shape[1]))
    l.append(nb)
    ind = ind[::-1]
    n = 0
    for i in range(ind.shape[0]):
      nb = np.array(nb)
      if np.sum(nb[0:ind[i]+n, ::]) == 0 : break
      nb[1:ind[i]+n+1, ::]=nb[0:ind[i]+n, ::]
      nb[0]=[0]*(nb.shape[1])
      n+=1
      l.append(nb)
    return l

xxx202xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[array([0, 0, 0, 0]), array([0, 0, 0, 0]), array([0, 0, 0, 0]), array([0, 0, 0, 0]),
 array([0, 1, 0, 0]), array([056, 156, 056, 0])56, array([045, 1, 045, 0])45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 144, 'const': 142, 'code+const': 286}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[('all', 2)], [], [('rot90', 2)], [('rot90', 2)], [], []]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
import numpy as np
def get_score(board):
  return  len(board[np.all(board, axis=1)])*40
def get_time_cap(board, time_caps):
  time_caps_size = len(time_caps)
  return board[time_caps_size]
def rotate_right(shape):
  return np.rot90(shape, 3)
def rotate_left(shape):
  return np.rot90(shape)
def animate_drop(board, shape, c):
  pass
def animate_clear(board):
  pass

xxx039xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [], []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1272, 'const': 338, 'code+const': 1610}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 13)], [('For', 20)]]
import numpy as np
def get_score(board):
    b=np.array([0])
    z=np.sum((board!=b),axis=1)
    return np.sum(z==board.shape[1])*40
def get_time_cap(board, time_caps):
    n=int(board.shape[0]/len(time_caps))
    arange=np.arange(board.shape[0])
    ans1=arange[np.sum(board,axis=1)!=0]
    if ans1.shape[0]==0:
       return time_caps[-1]
    else:
        ans2=time_caps[ans1[0]//n]
    return ans2
def rotate_right(shape):
    return shape[::-1,:].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    ans=[]
    key=board[:shape.shape[0],c:shape.shape[1]+c]==np.array([0])
    bl=shape==np.array([0])
    fk=np.array(key)
    fbl=np.array(bl)
    z=np.sum(key|bl)
    i=0
    checkpoint=0
    a1=np.arange(key.shape[1])
    a2=np.arange(key.shape[0])
    while z == ((key|bl).shape[0]*(key|bl).shape[1]): 
            new_board = np.array(board)
            new_board[i:shape.shape[0]+i,c:shape.shape[1]+c]=shape+board[i:shape.shape[0]+i,c:shape.shape[1]+c]
            ans.append(new_board)
            i+=1
            key=board[i:shape.shape[0]+i,c:shape.shape[1]+c]==np.array([0])
            bl=shape==np.array([0])
            if bl.shape!=key.shape:
                break
            z=np.sum(key|bl)
            if checkpoint !=len(a1):
                abl=list(a2[fbl[:,checkpoint]==0])
                ak=list(a2[fk[:,checkpoint]==0])
                if len(abl)!=0 and len(ak)!=0:
                  if list(ak)[0]<list(abl)[0]:
                      return[]
                checkpoint+=1
    return ans
def animate_clear(board):
    ans=[]
    s1=np.sum((board!=np.array([0])),axis=1)
    arange=np.arange(board.shape[0])
    delete=arange[s1==board.shape[1]]
    if len(delete)==0:
        return[]
    new_board = np.array(board)
    new_board[delete]=np.zeros((1,board.shape[1]))
    s2=np.sum((new_board!=np.array([0])),axis=1)
    s3=(np.sum((new_board!=np.array([0])),axis=1)!=0)
    ans.append(new_board)
    new_delete=arange[s2==0]
    hope=new_delete[-1]
    if np.sum(s3)==0:
        return ans
    if len(arange[s3])!=0 :
      pre=arange[s3][0] 
    for i in range(len(new_delete)-pre) :
      new_board = np.array(new_board)
      if hope==new_board.shape[0]:
        new_board[1:]=new_board[:hope]
        new_board[0]=np.zeros((1,new_board.shape[1]))
        ans.append(new_board)
      else:
        new_board[1:hope+1]=new_board[:hope]
        new_board[0]=np.zeros((1,new_board.shape[1]))
        ans.append(new_board)
      s2=np.sum((new_board!=np.array([0])),axis=1)
      new_delete=arange[s2==0]
      hope=new_delete[-1] 
    return ans

xxx203xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 944, 'const': 364, 'code+const': 1308}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 10)]]
import numpy as np
def get_score(board):
    x = np.min(board[:,:], axis = 1)
    y = np.sum(x!=0)
    return 40*y
def get_time_cap(board, time_caps):
    k = int(board.shape[0]/len(time_caps))
    x = np.max(board[:,:], axis = 1)
    y = (x!=0)
    if True not in y:
      return time_caps[-1]
    z = np.arange(y.shape[0])
    w = (z[y][0])//k
    return time_caps[w]
def rotate_right(shape):
    return shape[::-1, :].T
def rotate_left(shape):
    return shape[:, ::-1].T
def animate_drop(board, shape, c):
    k = [] ; a = np.arange(shape.shape[1])
    if (c<=(board.shape[1]-shape.shape[1])) and (board[0,c]==0):
      x = board[:,c::]==0 ;y = shape[:,:]!=0
      for i in range(x.shape[0]):
        new_board = np.array(board)
        new_shape = np.array(shape)
        l = board[i:i+shape.shape[0]:,c:c+shape.shape[1]:]!=0
        if (len(new_shape[l])>0) and (sum(new_shape[l])!=0):
          return k
        else:
          new_board[i:i+new_shape.shape[0],c:c+shape.shape[1]:] += new_shape[:new_shape.shape[0]:]
          k.append(new_board)
          if i + new_shape.shape[0] == new_board.shape[0]:
            break
    return k
def animate_clear(board):
    k = []
    new_board = np.array(board)
    a = np.min(new_board,axis = 1) ; b = np.arange(new_board.shape[0])
    new_board[b[a!=0]] = np.zeros((1,new_board.shape[1]))
    if False in (new_board[:,:] == board[:,:]):
      j = np.array(new_board)
      k.append(j)
      while(True):
        c = np.max(new_board,axis = 1)==0 ; q = b[c][::-1]
        new_board[1:q[0]+1:] = new_board[:q[0]:]
        new_board[0] = np.zeros((1,len(new_board[0])))
        j = np.array(new_board)
        k.append(j)
        d = np.max(new_board,axis = 1)==0 ; e = b[d]
        if False not in d[0:e[-1]]:
          break
    return k

xxx032xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[None56, None56, None56, None56, None45, None45, None45]
test_rotate_right0.0
[Nonearray([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, None0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left0.0
[Nonearray([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, None4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 128, 'const': 108, 'code+const': 236}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
import numpy as np
def get_score(board):
    i=board!=0
    j=sum(i.T)==board.shape[1]
    k=sum(j)
    g=k*40
    return g
def get_time_cap(board, time_caps):
    pass
def rotate_right(shape):
    pass
def rotate_left(shape):
    pass
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
    pass

xxx034xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 992, 'const': 384, 'code+const': 1376}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('For', 16)]]
import numpy as np
def get_score(board):
  a = board != 0
  b = np.sum(a, axis = 1)
  c = b == board.shape[1]
  return int(40 * (sum(c)))
def get_time_cap(board, time_caps):
  a = board == 0
  b = np.sum(a, axis = 1)
  c = b == board.shape[1]
  minimize_log_time = np.reshape(c, (int(len(time_caps)), int(board.shape[0] / len(time_caps))))
  sum_log = np.sum(minimize_log_time, axis = 1)
  ary_time = np.array(time_caps)
  ans = ary_time[sum_log < int(board.shape[0] / len(time_caps))]
  if ans.shape[0] == 0 :
    return time_caps[-1]
  else:
    return int(ans[0])
def rotate_right(shape):
  return shape[::-1].T
def rotate_left(shape):
  return (shape.T)[::-1]
def animate_drop(board, shape, c):
  lst = []
  ary_minus = np.zeros_like(shape) - 1
  check_noblock = (ary_minus + shape) == -1
  new_board = np.array(board)
  new_shape = np.array(shape)
  for i in range(new_board.shape[0] - new_shape.shape[0] + 1) :
      check_vacancy = board[i:i+new_shape.shape[0], c:c+new_shape.shape[1]]
      logic_vacancy = check_vacancy == 0
      placable = logic_vacancy | check_noblock
      if np.sum(np.sum(placable, axis = 1)) == new_shape.shape[0] * new_shape.shape[1] :
          new_board[i:i+new_shape.shape[0], c:c+new_shape.shape[1]] += new_shape
          lst.append(new_board)
          new_board = np.array(board)
      else :
          break
  return lst
def animate_clear(board):
  lst = []
  new_board = np.array(board)
  old_board = np.array(board)
  a = new_board != 0
  b = np.sum(a, axis = 1)
  c = b == new_board.shape[1]
  new_board[c] = np.array([0])
  row = new_board.shape[0]
  column = new_board.shape[1]
  fixed_board = np.array(new_board)
  if np.sum(np.sum(fixed_board == old_board, axis = 1)) != new_board.shape[0] * new_board.shape[1] :
    lst.append(fixed_board)
  j = 0
  for i in range(row) :
    if np.sum(new_board[row - 1 - i + j] == 0) == column :
      new_board[1:row - i + j, :] = new_board[0:row - 1 - i + j, :]
      new_board[0, :] = np.array([0])
      j += 1
      if len(lst) == 0 or np.sum(np.sum(new_board == lst[-1], axis = 1)) != new_board.shape[0] * new_board.shape[1] :
        lst.append(new_board)
        new_board = np.array(new_board)
      new_board = np.array(new_board)
  return lst

xxx033xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 782, 'const': 338, 'code+const': 1120}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 8)], [('While', 9)]]
import numpy as np
def get_score(board):
  mn = np.min(board,axis =1)
  fact = mn != 0
  return  sum(fact) * 40
def get_time_cap(board, time_caps):
  row = board.shape[0]
  col = board.shape[1]
  timecap = np.array(time_caps)
  new = board.reshape(len(time_caps),(row//len(time_caps))*col)
  total = np.sum(new,axis=1)
  fact = total!=0
  timelist = list(timecap[fact])
  if timelist != []:
      t = timelist[0]
  else:
      t = timecap[-1]
  return t
def rotate_right(shape):
  new_shape = np.array(shape)
  return new_shape.T[:,::-1]
def rotate_left(shape):
  new_shape = np.array(shape)
  return new_shape.T[::-1,:]
def animate_drop(board, shape, c):
  out = []
  tall = shape.shape[0]
  wide = shape.shape[1]
  cnot0 = np.sum(board!=0) + np.sum(shape != 0)
  i = 0
  j = c
  while True:
    new_board = np.array(board)
    if i > len(board) - tall:
        break
    new_board[i:i+tall,j:j+wide] += shape
    if np.sum(new_board != 0) != cnot0:
      break
    out.append(new_board)
    i += 1
  return out
def animate_clear(board):
  new_board = np.array(board)
  new_board[np.min(board,axis=1) != 0,:] = 0
  allrow = np.sum(np.max(new_board,axis=1) != 0)
  seq = np.arange(len(board))
  out = []
  start = np.array(new_board)
  out.append(start)
  while True:
    blankindex = np.sum(new_board,axis=1) == 0
    if np.sum(blankindex) == 0:
      return []
    j = seq[blankindex][-1]
    if j != len(board):
      new_board[1:j+1,:] = new_board[0:j,:]
      new_board[0,:] = 0
      if str(new_board) != str(start):
        out.append(np.array(new_board))
    if np.sum(np.sum(new_board[-allrow:],axis=1) != 0) == allrow:
      return out

xxx038xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 826, 'const': 350, 'code+const': 1176}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 11)], [('While', 9)]]
import numpy as np
def get_score(board):
    return int(int(len(board[board.min(axis = 1)> 0])) * 40)
def get_time_cap(board, time_caps):
    if len(board[board>0]) == 0:
        return time_caps[-1]
    numberOfZerosRow = len(board[board.max(axis=1) == 0])
    divideFactor = len(board) // len(time_caps)
    n = (numberOfZerosRow) // divideFactor
    return time_caps[n]
def rotate_right(shape):
    ns = np.array(shape)
    return ns.T[::,::-1]
def rotate_left(shape):
    ns = np.array(shape)
    return ns[::,::-1].T
def animate_drop(board, shape, c):
    l = []
    s = np.array(shape)
    shapeRow = s.shape[0]
    shapeCol = s.shape[1]
    testBoard = board[:shapeRow:,c:c+shapeCol:]
    te = testBoard[testBoard*shape != 0]
    if len(te) != 0:return []
    for i in range(len(board)-shapeRow+1):
        copyOfBoard = np.array(board)
        testBoard = board[i:i+shapeRow:,c:c+shapeCol:]
        te = testBoard[testBoard*shape != 0]
        if len(te) == 0:
            ns = np.array(s)
            ns = ns + testBoard
            newBoard = np.array(copyOfBoard)
            newBoard[i:shapeRow+i:,c:c+shapeCol:] = ns
            l.append(newBoard)
        else:
            break
    return l
def animate_clear(board):
    l = []
    board1 = np.array(board)
    lastBoard = np.array(board)
    j=0
    change = True
    listOfChangedIndex = []
    while change:
        if board1.min(axis = 1).max() != 0:
            board1[board1.min(axis = 1) > 0] = 0
            l += [board1]
            lastBoard = np.array(board1)
            board1 = np.array(board1)
            j = 0
        elif board1[j+1].max() == 0 and             board1[j].max() > 0 and             j not in listOfChangedIndex:
            board1[j+1] = board1[j]
            board1[j] = 0
            listOfChangedIndex += [j,j+1]
            j = 0
        else:
            j += 1
        if j >= (len(board1)-1):
            if False in (board1 == lastBoard):
                l += [board1]
                j = 0
                lastBoard = np.array(board1)
                board1 = np.array(board1)
                listOfChangedIndex = []
            else:
                change = False
    return l

xxx028xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 864, 'const': 376, 'code+const': 1240}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 10)], [('For', 10)]]
import numpy as np
def get_score(board):
  a = board > 0
  result = (np.sum(a,axis = 1))
  p = len(board[1])
  k = p == result
  return (np.sum(k) *40)
def get_time_cap(board, time_caps):
  box = (board.shape[0])// len(time_caps)
  check = np.sum(board>0,axis =1)
  k = check >0
  if np.sum(k) >0:
    mx = np.argmax(k)
    p = (mx // box)
    return time_caps[p]
  else:
    return time_caps[-1]
def rotate_right(shape):
    p = shape.T
    return (p[::,::-1])
def rotate_left(shape):
    p = shape.T
    return(p[::-1,::])
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    p = board ==0
    pshape = np.zeros((shape.shape[0],board.shape[1]),int)
    pshape[:,c:new_shape.shape[1]+c] = new_shape
    result = []
    check = pshape ==0
    for x in range(board.shape[0]-pshape.shape[0]+1):
        isFound = True
        m = check | p[x:x+check.shape[0]]
        y = m == False
        z = np.sum(y) ==0
        if z:
            new_board = np.array(board)
            new_board[x:x+check.shape[0]] += pshape
            result.append(new_board)
            isFound = False
        if isFound:
            break
    return result
def animate_clear(board):
    nb = np.array(board)
    k = nb>0
    sk = np.sum(k , axis = 1)
    ismaxlength = sk == board.shape[1]
    nb[ismaxlength] = 0
    allzero = np.zeros_like(board, int)
    l = []
    for i in range(board.shape[0]-1):
      allzero = np.zeros_like(board, int)
      nb2 = nb == 0
      sumrow = np.sum(nb2,axis =1)
      pos = np.arange(sumrow.shape[0])[sumrow==board.shape[1]]
      if pos.shape[0] == 0:
          break
      if len(l) == 0:
          l.append(nb)
      allzero[pos[-1]+1:] = nb[pos[-1]+1:]
      allzero[1:pos[-1]+1]  = nb[:pos[-1]]
      nb = allzero
      z = nb == l[-1]
      y = z ==False
      if np.sum(y) ==0:
          break
      l.append(nb)
    return l

xxx016xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0IndexError('index 6 is out of bounds for axis 0 with size 6')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[],
 [array([[01, 01, 2, 2],
       [1, 1, 0, 2],
       [1, 0, 2, 2]]),
       array([[1, 1, 0, 10],
       [1, 1, 12, 02]])],
 [], [],
 []]
test_animate_clear_10.0IndexError('index -5 is out of bounds for axis 0 with size 4')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0IndexError('index -4 is out of bounds for axis 0 with size 3')
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 974, 'const': 381, 'code+const': 1355}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep:
   [[('For', 3)], [('For', 4)], [('For', 4), ('For', 5)], [('For', 4), ('For', 5)], [('While', 11), ('For', 12), ('For', 14)], [('While', 8)]]
import numpy as np
def get_score(board):
    a=0
    for i in board:
        if 0 not in i:
            a+=1
    return a*40
def get_time_cap(board, time_caps):
    a=len(board)/len(time_caps)
    b='k'
    for i in range(len(board)):
        if list(board[i]) != list(np.zeros(len(board[i]))):
            b='s'
            break
    if b=='s':
        c=i//a
        return time_caps[int(c)]
    else:
        return time_caps[-1]
def rotate_right(shape):
    x=shape.shape
    c=np.ndarray((x[1],x[0]),int)
    for a in range(len(shape)):
        for b in range(len(shape[a])):
            c[b][x[0]-a-1]=shape[a][b]
    return c
def rotate_left(shape):
    x=shape.shape
    c=np.ndarray((x[1],x[0]),int)
    for a in range(len(shape)):
        for b in range(len(shape[a])):
            c[x[1]-b-1][a]=shape[a][b]
    return c
def animate_drop(board, shape, d):
    new_board = np.array(board)
    new_shape = np.array(shape)
    a=new_board.shape
    b=new_shape.shape
    y=0
    k=0
    j='horse'
    g=[]
    while k<a[0]-b[0]-1:
        for i in range(d+b[1]+1):
            if i>d:
                for x in range(b[0]):
                    if new_board[x+k][i]==0:
                        new_board[x+k][i]=new_shape[x][y]
                    else:
                        j='aspa'
                        break
                y+=1
        if j!='aspa':
            g.append(new_board)
            new_board = np.array(board)
            y=0
            k+=1
        else:
            break
    return g
def animate_clear(board):
    new_board = np.array(board)
    b=board.shape
    c=0
    d=[]
    j='sleep'
    while True:
        if list(new_board[b[0]-c-1])==list(np.zeros(b[1],int)):
            new_boardd=new_board.reshape(b)
            new_board=np.array([list(np.zeros(b[1],int))]+list(new_board[:b[0]-c-1])+list(new_board[b[0]-c:]))
            if list(new_board.reshape(b[0]*b[1]))==list(new_boardd.reshape(b[0]*b[1])):
                break
            else:
                d.append(new_board.reshape(b))
                c=-1
        c+=1
    return d

xxx121xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (4,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (4,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (2,) into shape (1,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 454, 'const': 280, 'code+const': 734}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 5)], []]
import numpy as np
def get_score(board):
    a = board>0
    x = np.min(a,axis=1)
    y = len(x[x==True])*40
    return y
def get_time_cap(board, time_caps):
    s = np.max(board,axis=1)
    b = board[s==0]
    m = len(s[b])
    n = board.shape[0]/len(time_caps)
    if board.shape[0] == m :
       ans = time_caps[-1]
       return ans
    if m/n < 1:
       ans = time_caps[0]
       return ans    
    if m%n == 0 :
       ans = time_caps[int(m//n)]
       return ans
    else:
       ans = time_caps[int(m+1//n)]
       return ans
def rotate_right(shape):
    x = shape.T
    x = x[::,::-1]
    return x
def rotate_left(shape):
    x = shape.T
    x = x[::-1,::]
    return x
def animate_drop(board, shape, c):
    ans = []
    n = 0 
    while n < board.shape[0]:
        new_board = np.array(board)
        if board[n,c] == 0:
            new_board[n,c:shape.shape[1]+1:] = shape
            ans.append(new_board)
        n += 1
    return ans
def animate_clear(board):
    pass

xxx019xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0Time-out: 5s
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 868, 'const': 324, 'code+const': 1192}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 5)], [('While', 8)]]
import numpy as np
def get_score(board):
    a = board != 0
    z = np.sum(a,axis = 1)
    k = len(board[0])
    f = z[z == k]
    return len(f)*40
def get_time_cap(board, time_caps):
    i = len(board)
    n = len(time_caps)
    k = i/n
    z = np.sum(board,axis = 1)
    f = z != 0
    if len(np.arange(len(board))[f]) != 0:
        d = np.arange(len(board))[f][0]
        m = int(d//k)
    else:
        m = -1
    return time_caps[m]
def rotate_right(shape):
    return shape.T[::,-1::-1]
def rotate_left(shape):
    return shape.T[::,-1::-1].T[::,-1::-1].T[::,-1::-1]
def animate_drop(board, shape, c):
    l = []
    z = np.zeros_like(board,int)
    i = 0
    while True:
        z[i:i+len(shape):,c:c+len(shape[0]):] += shape
        k = board + z
        if np.sum((k[i:i+len(shape):,c:] != z[i:i+len(shape):,c:]) & (k[i:i+len(shape):,c:] != board[i:i+len(shape):,c:])) != 0: break
        l.append(k)
        z[i:i+len(shape):,c:c+len(shape[0]):] -= shape
        i += 1
        if i+len(shape) > len(board): break
    return l
def animate_clear(board):
    l = []
    if get_score(board) != 0:
        new_board = np.array(board)
        new_board[np.min(board,axis=1)>0] = np.zeros_like(board[0],int)
        l.append(np.array(new_board))
        i = len(board)-1
        while True:
            if np.sum(new_board,axis=1)[i] == 0:
                new_board[1:i+1:] = new_board[:i:]
                new_board[0] = np.zeros_like(board[0],int)
                l.append(np.array(new_board))
            else:
                if np.sum(np.sum(new_board,axis=1)[:i:]) == 0:
                    break
                i -= 1   
    return l

xxx204xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0ValueError('cannot reshape array of size 24 into shape (2,3,5)')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0Time-out: 5s
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0ValueError('attempt to get argmax of an empty sequence')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1062, 'const': 352, 'code+const': 1414}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 7)], [('While', 16)]]
import numpy as np
def get_score(board):
    t = np.zeros([board.shape[0],board.shape[1]],int)
    s = np.sum((t==board),axis=1) == 0
    s = s.sum()
    return s * 40
def get_time_cap(board, time_caps):
    s = np.array(board)
    s = s.reshape([len(time_caps),s.shape[0]//len(time_caps),5])
    s = (s.sum(axis=1).sum(axis=1))
    s = s!=0
    t = np.array(time_caps)
    t = t[s]
    t = list(t)
    if len(t)!= 0:
      return t[0]
    else:
      return time_caps[-1]
def rotate_right(shape):
    s = np.array(shape)
    m,n = s.shape
    s = s.T[::,::-1]
    return s
def rotate_left(shape):
    s = np.array(shape)
    m,n = s.shape
    s = s.T[::-1,::]
    return s
def animate_drop(board, shape, c):
    r = 0
    crop = board[r:r+shape.shape[0],c:c+shape.shape[1]] != 0
    s = shape == 0
    ret = []
    while (np.sum(s | crop)) == 0:
      b = np.array(board)
      b[r:r+shape.shape[0],c:c+shape.shape[1]] = shape
      ret += [b]
      r+=1
      crop = board[r:r+shape.shape[0],c:c+shape.shape[1]] != 0
    return ret
def animate_clear(board):
    ret = []
    b = np.array(board)
    t = np.zeros([board.shape[0],board.shape[1]],int)
    s = np.sum((t==board),axis=1) == 0
    b[s] = np.zeros([1,b.shape[1]])
    r = (b.sum(axis=1)!=0).argmax()
    if s.sum() == 0:
      return []
    ret += [b]
    t = np.zeros([b.shape[0]-r,b.shape[1]],int)
    s = np.sum((t==b[r:]),axis=1) == b.shape[1]
    s = s[::-1]
    p = board.shape[0]-s.argmax()-1
    while s.sum() != 0 and len(s)!=0:
      b = list(np.zeros([1,board.shape[1]],int))+list(b[:p,:]) + list(b[p+1:,:])
      b = np.array(b)
      r += 1
      t = np.zeros([b.shape[0]-r,b.shape[1]],int)
      s = np.sum((t==b[r:]),axis=1) == b.shape[1]
      s = s[::-1]
      p = board.shape[0]-s.argmax()-1
      ret += [b]
    return ret

xxx032xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 894, 'const': 338, 'code+const': 1232}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('For', 18)]]
import numpy as np
def get_score(board):
    b = board.sum(axis = 1)
    x = np.array(board)
    x[x==0] = 1
    b1 = x.sum(axis = 1)
    ans = list(b1-b)    
    return ans.count(0)*40
def get_time_cap(board, time_caps):
    b = board.sum(axis = 1)
    b = b.reshape(len(time_caps),board.shape[0]//len(time_caps))
    b1 = b.sum(axis=1)
    check = list(b1)
    if check.count(0)==len(check):
        return time_caps[-1]
    b1[b1!=0] = 1
    return time_caps[b1.argmax()]
def rotate_right(shape):
    a = np.array(shape)
    return a[::-1].T
def rotate_left(shape):
    a = np.array(shape)
    return (a.T)[::-1]
def animate_drop(board, shape, c):
    b = np.array(board)
    s = np.array(shape)
    b1 = np.array(board)
    k= []
    for i in range(0,(b.shape[0]-s.shape[0])+1,1):
        b[i:i+s.shape[0],c:c+s.shape[1]] += s
        check = b[b!=0]
        check1 = b1[b1!=0]
        check2 = s[s!=0]
        if len(check)-len(check2)==len(check1):
            k.append(b)
        else:break
        b = np.array(board)
    return k
def animate_clear(board):
    b = board.sum(axis = 1)
    x = np.array(board)
    x[x==0] = 1
    b1 = x.sum(axis = 1)
    ans = list(b1-b) 
    ans1 = np.array([ans])
    ans1[ans1!=0] = 1
    y = np.array(board)
    k = []
    s1 = np.array(ans1.T*y)
    if (y-s1).sum() != 0:
        k.append(s1)
    z = np.array(s1[::-1])
    x1 = list(s1.sum(axis=1)).count(0)
    check_list = []
    if len(k) != 0:
        for i in range(x1):
            y =z.sum(axis = 1)
            k1 = y.argmin()
            z[k1:-1:1,:] = z[k1+1::,:]
            z[-1] = 0
            z1 = np.array(z[::-1])
            check = np.array(z)
            check1 = list(check.sum(axis = 1))
            if check1 not in check_list:
                k.append(z1)
            check_list.append(check1)
    return k

xxx022xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 760, 'const': 338, 'code+const': 1098}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 5)], [('For', 12)]]
import numpy as np
def get_score(board):
    a = np.min(board, axis=1)
    b = (a != 0) 
    return sum(b)*40
def get_time_cap(board, time_caps):
    lb = board.shape[0]
    lt = len(time_caps)
    a = np.arange(0,lb,1)
    boo = (np.max(board, axis=1) != 0)
    if 1 not in boo : return time_caps[-1]
    ind = np.min(a[boo])//(lb//lt)
    return time_caps[ind]
def rotate_right(shape):
    return (shape[::-1, ::]).T
def rotate_left(shape):
    return (shape[::, ::-1]).T
def animate_drop(board, shape, c):
    ans = []; row = 0; col = c
    size = shape.shape
    while row + size[0] <= board.shape[0] :
        new_board = np.array(board)
        new_shape = np.array(shape)
        check_board = new_board[row:row+size[0]:1,col:col+size[1]:1] != 0
        check_shape = (new_shape != 0)
        check = check_board & check_shape
        if 1 in check : return ans
        else :
            new_board[row:row+size[0]:1,col:col+size[1]:1] += new_shape
            ans.append(new_board)
        row += 1
    return ans
def animate_clear(board):
    ans = []; lap = 0
    row = board.shape[0]; col = board.shape[1]
    top = np.zeros((1,col), int)
    ref = np.arange(0,row,1)
    a = ref[((np.min(board, axis=1) == 0) & (np.max(board, axis=1) == 0)) | (np.min(board, axis=1) != 0)]
    if len(a) == 0 : return ans
    new_board = np.array(board)
    new_board[a] = top
    ans.append(new_board)
    for e in a[::-1] :
        if e != 0 :
            new_board = np.array(new_board)
            x = e + lap
            if np.sum(new_board[0:x:, ::]) == 0 : return ans
            new_board[1:x+1] = new_board[0:x]
            new_board[0] = top
            ans.append(new_board)
            lap += 1
    return ans

xxx122xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1128, 'const': 398, 'code+const': 1526}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 12)], [('For', 12)]]
import numpy as np
def get_score(board):
  check = board > 0
  return board[::,::][np.sum(check,axis=1)==board.shape[1]].shape[0] * 40
def get_time_cap(board, time_caps):
  r = board.shape[0] // len(time_caps)                
  position = np.arange(0,board.shape[0])
  check = np.sum(board[::,::],axis=1) > 0
  ok_position = position[check]
  if np.sum(ok_position) == 0: return time_caps[-1]
  else:
    first = ok_position[0]
    return time_caps[first//r]
def rotate_right(shape):
  return shape.T[::,::-1]
def rotate_left(shape):
  return shape.T[::-1,::]
def animate_drop(board, shape, c):
  new_board = np.array(board)
  new_shape = np.array(shape) 
  first_has_number = np.sum(new_board[::,c:c+new_shape.shape[1]],axis=1) > 0 
  first_has_number[-1] = True 
  first = min(np.arange(new_board.shape[0])[first_has_number])
  can_drop = np.sum(new_board[::,c:c+new_shape.shape[1]],axis=1) == 0
  row_available = np.arange(new_board.shape[0])[can_drop]
  screen_row_available = row_available[(row_available < first+1) & (row_available <= new_board.shape[0]-new_shape.shape[0])]
  out = []
  for row in screen_row_available:
    position_zero = new_board[row:row+new_shape.shape[0],c:c+new_shape.shape[1]] == 0
    TF_shape = new_shape[::,::] != 0
    NET = position_zero & TF_shape
    if np.sum(NET) == np.sum(TF_shape):
      new_board[row:new_shape.shape[0]+row,c:c+new_shape.shape[1]] += new_shape
      out.append(new_board)
    new_board = np.array(board)
  return out
def animate_clear(board):
    new_board = np.array(board)
    check = new_board[::,::] > 0
    can_clear = np.sum(check,axis=1) == new_board.shape[1]
    row_available = np.arange(new_board.shape[0])[can_clear]
    new_board[row_available,::] = np.zeros(new_board.shape[1],int)
    row = np.arange(0,new_board.shape[0])
    out = []
    out.append(new_board)
    n_move = np.sum(np.sum(new_board[::,::],axis=1) == 0)
    for i in range(n_move):
      new_board = out[-1]
      checkzero = np.sum(new_board[::,::],axis=1) == 0
      row_for_down = row[checkzero][-1]
      copyboard = np.array(new_board)
      copyboard[1:row_for_down+1] = new_board[:row_for_down]
      copyboard[0,::] = np.zeros(new_board.shape[1],int) 
      if np.sum(copyboard == out[-1]) != copyboard.shape[0] * copyboard.shape[1]: out.append(copyboard) 
    if len(out) == 1 and np.sum(out[-1]==board) == board.shape[0]*board.shape[1]: return []
    else: return out

xxx028xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[array([[2, 2, 2, 0],
       [3, 0, 1, 1]])], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]]),
  array([[0, 1, 0, 0, 0, 0, 0, 0],
       [0, 1, 6, 5, 0, 0, 0, 0],
       [0, 2, 2, 7, 5, 2, 2, 2],
       [3, 3, 3, 3, 5, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[ 0,  0,  0,  0,  0,  0],
       [ 0,  2,  2,  2,  0,  0],
       [ 0,  0,  0,  2,  8,  0],
       [ 1,  1,  0, 10,  8,  0],
       [ 1,  1,  0,  0,  8,  0]]),
  array([[ 0,  0,  0,  0,  0,  0],
       [ 0,  0,  0,  0,  0,  0],
       [ 0,  2,  2,  2,  8,  0],
       [ 1,  1,  0, 10,  8,  0],
       [ 1,  1,  0,  2,  8,  0]])],
 [array([[ 0,  0,  2,  2,  2,  0],
       [ 0,  0,  0,  0,  2,  0],
       [ 0,  0,  0,  0, 10,  0],
    ... (more)
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]]),
  array([[0, 0, 0, 0],
       [1, 3, 2, 0],
       [1, 0, 2, 0],
       [1, 3, 2, 1],
       [1, 1, 1, 0]]),
  array([[0, 0, 0, 0],
       [1, 1, 0, 0],
       [1, 2, 2, 0],
       [1, 1, 2, 1],
       [1, 3, 3, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]]),
  array([[0, 0, 0, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 1],
       [1, 3, 3, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]]),
  array([[0, 1, 0, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 1],
       [1, 3, 3, 0]])]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 536, 'const': 286, 'code+const': 822}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [('For', 3), ('For', 6)], [], [], [('For', 5), ('For', 10), ('For', 11)], []]
import numpy as np
def get_score(board):
  min = np.min(board,axis=1)
  score = np.sum(min != 0)*40
  return score
def get_time_cap(board, time_caps):
  found = False
  for i in range(len(board)):
    if found == True:
      break
    for j in range(len(board[i])):
      if board[i][j] != 0:
        row = i
        found = True
        break
  if found == False:
      return time_caps[-1]
  else:      
      index = row//2  
      return time_caps[index]
def rotate_right(shape):
  output = np.array(shape.T[::,::-1]) 
  return output
def rotate_left(shape):
  output = np.array(shape.T[::-1,::])
  return output
def animate_drop(board, shape, c):
  output = []
  high,wide = shape.shape
  for i in range(len(board)-high+1):
    new_board = np.array(board)
    new_board[i:i+high,c:c+wide] += shape
    canputin = True
    for k in range(len(shape)):
      for z in range(len(shape[0])):
        if(shape[k][z]==0):
          pass
        else:
          if(shape[k][z]!=new_board[i+k][c+z]):
            break
          else:
            canputin = False
    if(canputin==False)    :
        output.append(np.array(new_board))  
  return output
def animate_clear(board):
  pass

xxx025xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('operands could not be broadcast together with shapes (3,4) (3,6) ')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (3,3) (3,5) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0Time-out: 5s
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 736, 'const': 366, 'code+const': 1102}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 4)], [('While', 10)]]
import numpy as np
def get_score(board):
  return board[np.min(board,axis=1) > 0].shape[0]*40
def get_time_cap(board, time_caps):
  return time_caps[[-1,round((board.shape[0] - len(board[np.sum(board,axis=1) > 0]))/(board.shape[0]/len(time_caps)))][not np.sum(board) == 0]]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    if c <= 0: return []
    o,k = [],1 
    while True:
      s = k-1
      p = shape.shape[0] -1 + k
      r = shape == 0
      j = board[s:p,c:] != 0
      if True in (r|j).reshape(-1):
        return o
      else:
        n = np.array(board)
        z = n[s:p,c:] + shape
        n[s:p,c:] = z
        o.append(n)
        k += 1
def animate_clear(board):
    b = np.array(board)
    o,k = [],0 
    z = np.zeros(b.shape)
    b[np.min(board,axis=1) != 0] = np.zeros(board[np.min(board,axis=1) != 0].shape)
    o.append(np.array(b))
    c = b.shape[0]-2
    if np.sum(b != board) == 0:
        return []
    while True:
      if sum(b[c+1,::]) == 0 and sum(b[c,::]) != 0:
        b[c+1,::] = b[c,::]
        b[c,::] = 0
        k += 1
      if c == 0 and k != 0:
        o.append(np.array(b))
        c = b.shape[0]-1
        k = 0
      elif c + k == 0:
        break
      c -= 1
    return o

xxx217xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 760, 'const': 338, 'code+const': 1098}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 12)]]
import numpy as np
def get_score(board):
    a = np.sum(board>0, axis = 1)
    return len(a[a == board.shape[1]])*40
def get_time_cap(board, time_caps):
    n = board.shape[0]//len(time_caps)
    point = np.sum(board, axis = 1) != 0
    check = np.arange(0,board.shape[0])[point]
    time = time_caps*n
    time.sort()
    if sum(check) == 0:
        return time_caps[-1]
    else:
        return time[check[0]]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return (shape.T)[::-1]
def animate_drop(board, shape, c):
    ans = []
    for i in range(board.shape[0]):
        new_board = np.array(board)
        new_shape = np.array(shape)
        check_board = new_board[i:i+new_shape.shape[0],c:c+new_shape.shape[1]] == 0
        check_shape = new_shape != 0
        if np.sum(board[0,c:shape.shape[1]+c]) != 0:
            return []
        if check_board.shape[0] == check_shape.shape[0]:
            if np.sum(check_board & check_shape) == np.sum(check_shape == True):
                new_board[i:i+new_shape.shape[0],c:c+new_shape.shape[1]] += new_shape
                ans.append(new_board)
            else:
                break
        else:
            break
    return ans
def animate_clear(board):
    ans = []
    new_board = np.array(board)
    new = np.sum(new_board != 0, axis = 1) == board.shape[1]
    if np.sum(new) != 0:
        row = np.arange(board.shape[0])
        new_board[row[new]] = 0
        ans.append(new_board)
        i = board.shape[0] - 1
        new_board = np.array(new_board)
        while i != 0:
            if np.sum(new_board[:i+1]) == 0:
                break
            if np.sum(new_board[i]) == 0:
                new_board[1:i+1] = new_board[:i]
                new_board[0] = 0
                ans.append(np.array(new_board))
            else:
                i -= 1
    return ans

xxx036xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 810, 'const': 338, 'code+const': 1148}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 14)], [('While', 13)]]
import numpy as np
def get_score(board):
    return 40*np.sum(np.sum(board == np.zeros_like(board,int),axis=1)==0)
def get_time_cap(board, time_caps):
    if np.sum(board) == 0 : return time_caps[-1]
    else : return time_caps[(board.shape[0]-np.sum(np.sum((board != np.zeros_like(board,int)),axis=1) != np.zeros_like(board.shape[0],int)))//(board.shape[0]//len(time_caps))]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    i = 0 ; o = []
    while board[i:i+len(shape),c:shape.shape[1]+c].shape == shape.shape and np.sum((board != np.zeros_like(board,int))[i:i+len(shape),c:shape.shape[1]+c]&(shape != np.zeros_like(shape,int))) == 0 :
        x = np.array(board)
        x[i:i+len(shape),c:shape.shape[1]+c][shape != np.zeros_like(shape,int)] = np.array(shape)[shape != np.zeros_like(shape,int)]
        o.append(x)
        i += 1
    return o
def animate_clear(board):
    if 0 not in np.sum(board == np.zeros_like(board,int),axis=1) : return []
    else :
        o = []
        x = np.array(board)
        x[np.sum(board == np.zeros_like(board,int),axis=1) == np.zeros_like(np.sum(board == np.zeros_like(board,int),axis=1),int)] = 0
        o.append(x) 
        while True :
            x = np.array(o[-1])
            i = np.arange(len(x))[np.sum(x != np.zeros_like(x),axis=1)==np.zeros(len(x))][-1]
            if np.sum(x[:i]) == 0 : break
            a = np.zeros_like(x)
            a[1:i+1] = x[:i]
            a[i+1:] = x[i+1:]
            o.append(a)
        return o

xxx023xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1136, 'const': 288, 'code+const': 1424}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('For', 16), ('For', 35)]]
import numpy as np
def get_score(board):
    a = sum(board.T != 0)
    return 40*sum(a==board.shape[1])
def get_time_cap(board, time_caps):
    a = np.arange(len(board)//len(time_caps)) + np.arange(0,len(board),len(board)//len(time_caps)).reshape(len(np.arange(0,len(board),len(board)//len(time_caps))),1)
    b = board[a,:].sum(axis=1).sum(axis=1)
    pos = np.arange(len(time_caps))
    c = pos[b > 0]
    if len(c) > 0:
      return time_caps[c[0]]
    return time_caps[-1]
def rotate_right(shape):
    return np.array(shape.T[:,::-1])
def rotate_left(shape):
    return np.array(shape.T[::-1])
def animate_drop(board, shape, c):
    ans = []
    check = len(board[board == 0])-len(shape[shape != 0])
    for i in range(len(board)-shape.shape[0]+1):
      new_board = np.array(board)
      shape1 = np.zeros((new_board.shape[0],new_board.shape[1]),int)
      shape1[i:i+shape.shape[0],c:c+shape.shape[1]] = shape
      new_board = new_board + shape1
      if len(new_board[new_board == 0]) == check:
        ans.append(new_board)
      else:
        break
    return ans
def animate_clear(board):
    new_board = np.array(board)
    a = sum(new_board.T != 0)
    if len(a[a!=new_board.shape[1]]) == len(a):
      return []
    b = -np.argmax(a[::-1])+len(new_board)-1
    new_board[a == new_board.shape[1]] = np.zeros(new_board.shape[1],int)
    shape1 = new_board[:b]
    new_board2 = np.array(new_board)
    new_board2[:b] = np.zeros((b,new_board.shape[1]),int)
    if np.sum(new_board2) == 0 and np.sum(shape1) == 0:
      return np.array(new_board2)
    ans = animate_drop(new_board2,shape1,0)
    c = sum(ans[-1].T != 0)
    for i in range(len(c[c==0])):
      e = sum(ans[-1].T != 0)
      if len(e[::-1][e[::-1].argmin():]) == len(e[::-1][e==0]):
        break
      elif e[::-1][e[::-1].argmin():].argmin() == 0:
        new_board3 = np.array(ans[-1])
        d = -np.argmin(e[::-1])+len(new_board3)-1
        new_board4 = np.array(new_board3)
        new_board4[:d] = np.zeros((d,new_board3.shape[1]),int)
        shape2 = new_board3[:d]
        if len(animate_drop(new_board4,shape2,0)) > 2:
          ans += animate_drop(new_board4,shape2,0)[1:]
        else:
          ans.append(animate_drop(new_board4,shape2,0)[-1])
    return ans

xxx211xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 896, 'const': 338, 'code+const': 1234}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 11), ('For', 38)]]
import numpy as np
def get_score(board):
    a = board != 0
    b=np.sum(a, axis=1)
    return sum(b==board.shape[1])*40
def get_time_cap(board, time_caps):
    n=board.shape[0]/len(time_caps)
    a = board == 0
    b=np.sum(a, axis=1)
    pos=np.arange(board.shape[0])
    if len(pos[b<board.shape[1]])==0:
        return time_caps[-1]
    index=pos[b<board.shape[1]][0]
    return time_caps[int(index//n)]
def rotate_right(shape):
    return shape.T[:, ::-1]
def rotate_left(shape):
    return shape[:, ::-1].T
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    out=[]
    a= new_board[:, c:c+new_shape.shape[1]]
    for i in range(a.shape[0]):
        last_board = np.array(board)
        b=a[i:i+shape.shape[0], 0:shape.shape[1]]
        if b.shape[0] != shape.shape[0]:
            break
        d = (b==0) | (shape==0)
        if np.sum(d)==new_shape.shape[0]*new_shape.shape[1]:
            e=b+shape
            last_board[i:i+shape.shape[0], c:c+shape.shape[1]]=e
            out.append(last_board)
        else:
            break
    return out
def animate_clear(board):
    new_board = np.array(board)
    b=new_board==0
    a=new_board[np.sum(b, axis=1)==0]
    pos=np.arange(board.shape[0])
    new_board[pos[np.sum(b, axis=1)==0]]=0
    out=[new_board]
    row=board.shape[0]-1
    while row>=0:
        if np.sum(new_board[row])==0:
            if row==board.shape[0]-1:
                default=np.zeros((board.shape[0],board.shape[1]), int)
            else:
                default=np.zeros((board.shape[0],board.shape[1]), int)
                default[row+1:]=new_board[row+1:]
            shape=new_board[:row]
            if np.sum(shape)==0:
                break
            result=animate_drop(default, shape, 0)
            out+=result[1:]
            new_board=result[-1]
        else:
            row-=1
    if len(out)==1:
        return []
    return out

xxx204xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 830, 'const': 228, 'code+const': 1058}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [], [('all', 12), ('all', 13), ('all', 21)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 8)], [('While', 14)]]
import numpy as np
def get_score(board):
    return ((board != 0).sum(1) == board.shape[1]).sum() * 40
def get_time_cap(board, time_caps):
    rows, cols = board.shape
    lines = np.arange(rows)
    not_empty_mask = ((board).sum(1) != 0)
    index = -1 
    if not_empty_mask.sum() == 0:
      return time_caps[-1]
    first_not_empty = lines[not_empty_mask][0]
    index = int(first_not_empty / int(rows / len(time_caps)))
    return time_caps[index]
def rotate_right(shape):
    new_shape = shape[::-1]
    return new_shape.T
def rotate_left(shape):
    new_shape = shape.T
    return new_shape[::-1]
def animate_drop(board, shape, c):
    result = []
    h, w = shape.shape
    shape_only = shape[shape!=0]
    shape_only_list = np.reshape(shape_only, (shape != 0).sum())
    i = 0
    while True:
      new_board = np.zeros((board.shape[0]+h - 1, board.shape[1]), int)
      new_board[h-1:,:] = board
      zero_count = (new_board == 0).sum() - (shape != 0).sum()
      if (i+h) > new_board.shape[0]: break
      new_board[ i:i+h , c:c+w ][shape != 0] = shape_only_list
      if (new_board == 0).sum() == zero_count:
        result.append(new_board[h-1:,:])
        i+=1
      else:
        break
    return result[h-1:] if len(result) >= h else []
def animate_clear(board):
    rows, columns = board.shape
    current_index = rows -1
    new_board = np.array(board)
    new_board[((new_board !=0).sum(1) == columns),:] = 0
    count_zero_row = ((new_board == 0).sum(1) == columns).sum()
    lower_last_board = new_board[(new_board != 0).sum(1) > 0]
    last_board = np.zeros_like(board)
    last_board[count_zero_row:,:] = lower_last_board  
    res = [np.array(new_board)]
    if (new_board == board).all(): return []
    if (new_board == last_board).all(): return res
    while True:
      current_row = new_board[current_index]
      if (current_row==0).sum() == columns:
        new_board[[current_index, current_index-1]] = new_board[[current_index-1, current_index]] 
      current_index -= 1
      if current_index == 0 :
        res.append(np.array(new_board))
        if (new_board == last_board).all():
          return res
        else:
          current_index = rows-1

xxx218xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0IndexError('boolean index did not match indexed array along dimension 0; dimension is 1 but corresponding boolean dimension is 2')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0IndexError('boolean index did not match indexed array along dimension 0; dimension is 2 but corresponding boolean dimension is 3')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 680, 'const': 324, 'code+const': 1004}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 10)]]
import numpy as np
def get_score(board):
    result = np.sum(board.min(axis=1) != 0) * 40
    return result
def get_time_cap(board, time_caps):
    posit = int(board[np.sum(board, axis=1) == 0].shape[0] / board.shape[0]* len(time_caps) )
    if 0 <= posit <= len(time_caps)-1:
        return time_caps[posit]
    else:
        return time_caps[-1]
def rotate_right(shape):
    new_shape = shape.T
    return new_shape[:, ::-1]
def rotate_left(shape):
    new_shape = shape.T
    return new_shape[::-1, :]
def animate_drop(board, shape, c):
    result = []
    shape_mask = shape != 0
    shape_x, shape_y = shape.shape
    new_board = np.array(board)
    old_board_sum = np.sum(new_board)
    for r in range(board.shape[0]):
        board_at_shape = new_board[r:shape_x+r , c:shape_y+c]
        board_at_shape[shape_mask] = shape[shape_mask]
        if (old_board_sum + np.sum(shape)) != np.sum(new_board):
            break
        result.append(new_board)
        new_board = np.array(board)
        old_board_sum = np.sum(new_board)
    return result
def animate_clear(board):
    result = []
    new_board = np.array(board)
    if len(new_board[np.min(board, axis=1) > 0]) == 0:
        return result
    new_board[np.min(board, axis=1) > 0] = 0
    result.append(new_board)
    new_board = np.array(new_board)
    while 1:
        new_board_row_sum = np.sum(new_board, axis=1)
        new_board_row_sum = new_board_row_sum[::-1]
        argmin_row = np.argmin(new_board_row_sum)
        new_board[1:board.shape[0] - argmin_row] = new_board[:board.shape[0] - argmin_row-1]
        new_board[0] = 0
        if all((new_board == result[len(result)-1]).reshape(-1)):
            return result
        result.append(np.array(new_board))
        new_board = np.array(new_board)
    return result

xxx024xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[array([[2, 0, 0, 0],
       [1, 0, 1, 1]])],
 [array([[0, 2, 0, 0],
       [1, 0, 1, 1]]), array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 0, 0, 5, 0, 0, 0],
       [0, 1, 1, 0, 0, 0, 0, 0],
       [0, 2, 2, 2, 0, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]]),
  array([[0, 1, 0, 5, 5, 0, 0, 0],
       [0, 1, 1, 0, 5, 0, 0, 0],
       [0, 2, 2, 2, 0, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]]),
  array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]]),
  array([[0, 1, 0, 0, 0, 0, 0, 0],
       [0, 1, 6, 5, 0, 0, 0, 0],
       [0, 2, 2, 7, 5, 2, 2, 2],
       [3, 3, 3, 3, 5, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[0, 0, 2, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 0, 0, 2, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 2, 2, 2, 0, 0 ... (more)
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 2, 2, 0],
       [1, 1, 0, 0],
       [1, 0, 0, 0],
       [1, 0, 0, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1172, 'const': 432, 'code+const': 1604}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 9)], [('While', 11)]]
import numpy as np
def get_score(board):
  score = 40*len(board)
  score_board = np.min(board,axis = 1)
  score_board = score_board[score_board==0]
  score -= 40*len(score_board)
  return score
def get_time_cap(board, time_caps):
  scale = len(board)/len(time_caps)
  time_board = np.max(board,axis = 1)
  pos = len(board) - len(time_board[time_board!=0])
  if pos == len(board) :
    return time_caps[-1]
  else :
    return time_caps[int(pos)//int(scale)]
def rotate_right(shape):
  new_shape = shape.T
  return new_shape[:,::-1]
def rotate_left(shape):
  new_shape = shape.T
  return new_shape[::-1,:]
def animate_drop(board, shape, c):
  list_board = []
  base_board = np.array(board)
  new_board = np.array(board)
  new_shape = np.array(shape)
  check = (new_shape != 0)[-1]
  n = 0
  while list((new_board[n:n+1,c:c+new_shape.shape[1]][0] != 0) & check) == list(np.array([False]*new_shape.shape[1])):
    if n == 0 :
        new_board[0,c:c+new_shape.shape[1]] += new_shape[-1]
    elif n == 1 and new_shape.shape[0] >= 2:
        new_board[0:2,c:c+new_shape.shape[1]] += new_shape[new_shape.shape[0]-2:,:]
    elif n == 2 and new_shape.shape[0] >= 3:
        new_board[0:3,c:c+new_shape.shape[1]] += new_shape[new_shape.shape[0]-3:,:]
    elif n == 3 and new_shape.shape[0] >= 4:
        new_board[0:4,c:c+new_shape.shape[1]] += new_shape[new_shape.shape[0]-4:,:]
    else :
        new_board[n-new_shape.shape[0]+1:n+1,c:c+new_shape.shape[1]] += new_shape
    list_board.append(new_board)
    n+=1
    if list(new_board[-1]) != list(base_board[-1]) :
        break
    new_board = np.array(board)
  return list_board
def animate_clear(board):
  list_board = []
  new_board = np.array(board)
  check = np.min(board,axis = 1)
  new_board[check!=0,:] = 0
  list_board.append(np.array(new_board))
  num_0 = np.sum(np.max(new_board,axis = 1) != 0)
  finished = False
  line = np.arange(len(board))
  while not finished :
    check_0 = np.max(new_board,axis = 1)
    if np.sum(check_0 != 0) == 0 :
      return []
    if list(check_0!=0) == [True]*len(check_0) :
      return []
    last_line = line[check_0==0][-1]
    if last_line != len(board) :
      new_board[1:last_line+1] = new_board[0:last_line]
      new_board[0] = 0
      list_board.append(np.array(new_board)) 
    if np.sum(np.max(new_board[-num_0:],axis = 1)!=0) == num_0 :
      break
  return list_board

xxx017xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1026, 'const': 324, 'code+const': 1350}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 9)], [('While', 11)]]
import numpy as np
def get_score(board):
    check = np.array(board!=0)
    check_sum = np.sum(check,axis=1)
    return board[check_sum==board.shape[1],:].shape[0]*40
def get_time_cap(board, time_caps):
    length = np.arange(len(time_caps))
    b = np.sum(board,axis=1).reshape(len(time_caps),board.shape[0]//len(time_caps))
    s = np.sum(b,axis=1)
    if np.sum(length[s!=0]) == 0:
        return time_caps[-1]
    out = np.array(length[s!=0])
    return time_caps[out[0]]
def rotate_right(shape):
    return shape[::-1,:].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    out = []
    if c > board.shape[1] - shape.shape[1]:
        return out
    new_board = np.array(board)
    add_position = np.array(new_board[:shape.shape[0],c:c+shape.shape[1]])
    i = 0
    while np.sum(shape!=0) == np.sum((shape!=0)&(add_position==0)):
        new_board[i:shape.shape[0]+i,c:c+shape.shape[1]] = np.array(add_position + shape)
        out.append(new_board)
        i+=1
        new_board = np.array(board)
        add_position = np.array(new_board[i:shape.shape[0]+i,c:c+shape.shape[1]])
        if shape.shape != add_position.shape:
            break
    return out
def animate_clear(board):
    check = np.array(board!=0)
    out = []
    new_board = np.array(board)
    if np.sum(np.sum(check,axis=1)==board.shape[1]) == 0:
        return out
    new_board[np.sum(check,axis=1)==board.shape[1]] = 0
    getitin = np.array(new_board)
    out.append(getitin)
    while True:
        index = np.arange(board.shape[0])
        index_is_zero = np.array(index[np.sum(new_board,axis=1) == 0])
        cut = np.array(new_board[:np.max(index_is_zero),:])
        new_board[1:np.max(index_is_zero)+1,:] = np.array(cut)
        new_board[0,:] = 0
        index_is_not_zero = np.array(index[np.sum(new_board,axis=1)!=0])
        getitin = np.array(new_board)
        if len(out)==1:
            if list(np.sum(out[0],axis=1)) == list(np.sum(getitin,axis=1)):
                break
        out.append(getitin)
        if np.sum(np.sum(new_board[index_is_not_zero[0]:,:],axis=1)!=0) == new_board[index_is_not_zero[0]:,:].shape[0]:
            break
    return out

xxx018xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1040, 'const': 350, 'code+const': 1390}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 13)]]
import numpy as np
def get_score(board):
    a = np.min(board,axis=1)
    b = np.sum(a != 0)
    point = b*40
    return point
def get_time_cap(board, time_caps):
    t = len(time_caps)
    b = board.reshape((t,int(board.shape[1]*board.shape[0]/t)))
    c = np.max(b,axis=1)
    p = np.array(time_caps)[c != 0]
    if len(p) == 0:
        return time_caps[-1]
    else:
        return p[0]
def rotate_right(shape):
    return shape.T[::,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)[-1]
    p = []
    for i in range(new_board.shape[0]):
        if i+shape.shape[0]-1 < board.shape[0]:
            x = np.array(board[i+shape.shape[0]-1,c:c+shape.shape[1]:1])
            x2 = x==0
            y = np.array(shape[shape.shape[0]-1])
            y2 = y==0
            z = x2 | y2
        else:
            z = np.array(False)
        if  False not in z:
            new_board[i:i+shape.shape[0]:1,c:c+shape.shape[1]:1] += shape
            n1 = board[i:i+shape.shape[0]:1,c:c+shape.shape[1]:1] == 0
            n2 = shape == 0
            n3 = n1 | n2
            if False not in n3:
                p.append(new_board)
                new_board = np.array(board)
            else:
                break
        else :
            break
    return p
def animate_clear(board):
    new_board = np.array(board)
    new_board2 = np.min(new_board,axis=1)
    zero = np.array([0]*new_board.shape[1])
    new_board[new_board2!=0] = zero
    copy_board = np.array(new_board)
    if max(new_board2) == 0:
        return []
    p = []
    p.append(new_board)
    i = board.shape[0]-1
    while i >= 0 :
        zero_board = np.zeros(board.shape)
        sum_board = np.sum(new_board[i])
        if sum_board == 0:
            up = np.array(new_board[0:i:1])
            up_check = np.sum(up,axis=1)
            if len(up) == 0:
                break
            up_count = np.max(up_check)
            if up_count==0:
                break
            bottom = np.array(new_board[i+1::1])
            bottom_check = np.sum(bottom,axis=1)
            bottom_out = np.array(bottom)[bottom_check != 0]
            zero_board[board.shape[0]-len(bottom_out):board.shape[0]:1] = bottom_out
            zero_board[board.shape[0]-len(bottom_out)-len(up):board.shape[0]-len(bottom_out):1] = up
            copy_board = np.array(zero_board,int)
            p.append(np.array(copy_board))
        i -= 1
    return p

xxx041xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 684, 'const': 338, 'code+const': 1022}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('For', 12)]]
import numpy as np
def get_score(board):
    minr = np.min(board,axis=1)
    get = board[minr>0]
    return len(get)*40
def get_time_cap(board, time_caps):
    maxr = np.max(board,axis=1)
    before = len(maxr[maxr==0])
    if np.max(maxr) == 0:
        return time_caps[-1]
    else: c = before//2
    return time_caps[c]
def rotate_right(shape):
    re = shape[::-1]
    shapet = re.T
    return shapet
def rotate_left(shape):
    shapet = shape.T
    return shapet[::-1]
def animate_drop(board, shape, c):
    nb = np.array(board)
    ns = np.array(shape)
    blank = len(nb[nb==0])
    num = len(ns[ns!=0])
    drop = []
    for i in range(board.shape[0]-(shape.shape[0]-1)):
        nb[i:i+shape.shape[0],c:c+shape.shape[1]] += ns
        zib = len(nb[nb==0])
        if (blank-num) == zib:
            drop.append(np.array(nb))
        nb = np.array(board)
    return drop
def animate_clear(board):
    nb = np.array(board)
    c = board.shape[1]
    na = np.sum(board!=0,axis=1)
    clear = []
    fline = np.arange(0,board.shape[0],1)[na==c]
    if len(fline) == 0:
        return []
    nb[fline,:] = 0
    clear.append(np.array(nb))
    r = board.shape[0]-1
    for i in range(board.shape[0]):
        if np.sum(nb[r]) == 0 and np.sum(nb[:r]) != 0:
            nb[1:r+1] = nb[:r]
            nb[0] = 0
            clear.append(np.array(nb))
        else: r-=1
    return clear

xxx200xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0IndexError('arrays used as indices must be of integer (or boolean) type')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1570, 'const': 590, 'code+const': 2160}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 13)], [('For', 15)]]
import numpy as np
def create_diagonal(listd):
    s = len(listd)
    z = np.zeros((s,s), int)
    a = list(np.arange(0,s,1))
    z[a,a] = [np.array(listd)]
    return z
def index_where(listd,v):
    s = len(listd)
    ar = list(np.arange(1,s+1,1))
    diag = create_diagonal(listd)
    diag = diag - create_diagonal([v] * s)
    diag = (diag ** 2) * (s+1) + 1
    diag = diag * create_diagonal(ar)
    yes_index = set(np.sum(diag, axis = 0)).intersection(set(ar))
    findex = np.array(list(yes_index)) - 1
    return findex
def npsign(nparray):
    row,col = nparray.shape
    tfarray = nparray > 0
    tflist = list(tfarray.reshape(row*col))
    index_f = np.array(index_where(tflist,False))
    biarray = np.ones((1,row*col),int)[0]
    biarray[index_f] = 0
    return biarray.reshape(row,col)
def npsign2(nparray):
    col = nparray.shape[0]
    tfarray = nparray > 0
    tflist = list(tfarray.reshape(col))
    index_f = np.array(index_where(tflist,False))
    biarray = np.ones((1,col),int)[0]
    if list(index_f) != []:
        biarray[index_f] = 0
    return biarray.reshape(col)
def get_score(board):
    row,col = board.shape
    binary_board = npsign(board)
    sum_board = list(np.sum(binary_board, axis = 1))
    points = sum_board.count(col) * 40
    return points
def get_time_cap(board, time_caps):
    row,col = board.shape
    binary_board = npsign(board)
    sum_board = list(npsign2(np.sum(binary_board, axis = 1)))
    if np.sum(np.array(sum_board)) == 0:
      return time_caps[-1]
    frow = sum_board.index(1)
    rpsect = row // len(time_caps)
    a_board = list(np.arange(rpsect,row+rpsect,rpsect))
    d_board = list(np.array(a_board) - frow > 0)
    i = d_board.index(True)
    return time_caps[i]
def rotate_right(shape):
    shape_copy = np.array(shape)
    shape_copy = shape_copy.T[:,::-1]
    return shape_copy
def rotate_left(shape):
    shape_copy = np.array(shape)
    shape_copy = shape_copy.T[::-1,:]
    return shape_copy
def animate_drop(board, shape, c):
    board_copy = np.array(board)
    shape_copy = np.array(shape)
    s_shape = shape_copy.shape
    b_shape = board_copy.shape
    shape_val = list(set(list(np.array(shape_copy).reshape(s_shape[0]*s_shape[1]))) - {0})[0]
    n_val = list(np.array(shape_copy).reshape(s_shape[0]*s_shape[1])).count(shape_val)
    rs = np.arange(0,b_shape[0],1)
    final_boards = np.array([board_copy] * len(rs))
    original_boards = np.array(final_boards)
    final_boards_list = []
    for i in range(0,b_shape[0]):
      cp_board = np.array(board_copy)
      if cp_board[i:i+s_shape[0],c:c+s_shape[1]].shape == np.array(shape_copy).shape:
        cp_board[i:i+s_shape[0],c:c+s_shape[1]] += np.array(shape_copy) * 99999
      else:
        break
      if list(cp_board[i:i+s_shape[0],c:c+s_shape[1]].reshape(s_shape[0]*s_shape[1])).count(shape_val*99999) != n_val:
        break
      cp_board[i:i+s_shape[0],c:c+s_shape[1]] -= np.array(shape_copy) * 99998
      final_boards_list.append(cp_board)
    return final_boards_list
def animate_clear(board):
    row,col = board.shape
    board_copy = np.array(board)
    binary_board = npsign(board)
    sum_board = np.sum(binary_board, axis = 1)
    full_index = np.array(index_where(sum_board,int(col)))
    if len(full_index) == 0:
      return []
    board_copy[full_index] = 0
    sum2_board = np.sum(board_copy, axis = 1)
    full_index2 = np.array(index_where(sum2_board,0))[::-1]
    board_list = [board_copy]
    windex = full_index2 + np.arange(0,len(full_index2),1)
    for i in list(windex):
      board_copy = [board_copy[i]] + list(board_copy[:i]) + list(board_copy[i+1:])
      board_copy = np.array(board_copy)
      if False in (list((board_copy == board_list[-1]).reshape(1,row*col)[0])):
        board_list.append(board_copy)
    return board_list

xxx019xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0Time-out: 5s
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1062, 'const': 444, 'code+const': 1506}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 5)], [('While', 12)]]
import numpy as np
def get_score(board):
    return np.sum(np.array(np.mean((0!=board),axis = 1),int) *40 )
def get_time_cap(board, time_caps):
    new_board = np.array(board)
    if np.sum(0!=np.sum( 0!= new_board.reshape( len(time_caps) , board.shape[1]*(board.shape[0]//len(time_caps)) ),axis = 1)) !=0:
      return np.array(time_caps)[0!=np.sum( 0!= new_board.reshape( len(time_caps) , board.shape[1]*(board.shape[0]//len(time_caps)) ),axis = 1)][0]
    return time_caps[-1]
def rotate_right(shape):
    return shape.T[::,::-1]
def rotate_left(shape):
    return shape.T[::-1,::]
def animate_drop(board, shape, c):
    list_board= []
    i,a_range = 0,board.shape[0]-shape.shape[0]+1
    while i != (a_range):
      frame = np.zeros_like(board)
      frame[i:i+shape.shape[0],c:c+shape.shape[1]] = np.array(shape)
      if np.sum(0==(board[i:i+shape.shape[0],::])) - np.sum(shape!=0)  == np.sum(0==(board[i:i+shape.shape[0],::] + frame[i:i+shape.shape[0],::])) :
        list_board.append((board + frame))
      else:break
      i+=1
    return list_board
def animate_clear(board):
    newboard = np.array(board)
    newboard = newboard + newboard*(-1*np.reshape(np.array(np.mean((0!=newboard),axis = 1),int),(board.shape[0],1)))
    play_board = np.array((~ np.array(np.array(np.mean((0==newboard),axis = 1),int),bool)),int)
    not_zero = newboard[np.array(play_board,bool),::]
    count_zero = np.sum(play_board == 0)
    list_board=[]
    i,j,remember_me,do = -1,-2,7,False
    if False in (newboard == board) :
      list_board.append(newboard)
      while sum(play_board[0:count_zero]) != sum(np.zeros_like(play_board[0:count_zero])):
        do = True
        if play_board[j] == 1 and play_board[i] == 0:
          play_board[i],play_board[j] = play_board[j],play_board[i]
        if i == -len(play_board)+1  and sum(play_board[0:count_zero]) != sum(np.zeros_like(play_board[0:count_zero])):
          i,j = -1,-2
          body = np.zeros_like(board)
          body[np.array(play_board,bool),::] = np.array(not_zero)
          list_board.append(body)
        i-=1
        j-=1
      if do:
          body = np.zeros_like(board)
          body[np.array(play_board,bool),::] = np.array(not_zero)
          list_board.append(body)
    return list_board

xxx044xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 832, 'const': 404, 'code+const': 1236}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 8)], [('While', 15)]]
import numpy as np
def get_score(board):
    z = np.zeros(board.shape[0],int)
    m = np.min(board,axis=1)
    x = z!=m
    return 40*sum(x)
def get_time_cap(board, time_caps):
    x = board.reshape((len(time_caps),int(board.shape[1]*board.shape[0]/len(time_caps)))) 
    m = np.max(x,axis=1)
    a = np.arange(len(time_caps))
    b = m!=0
    if True not in b:
        return time_caps[-1]
    return time_caps[a[b][0]]
def rotate_right(shape):
    return shape.T[::,::-1]
def rotate_left(shape):
    return shape[::,::-1].T
def animate_drop(board, shape, c):
    U = []
    A = board.shape[0] ; B = board.shape[1] ; a = shape.shape[0] ; b = shape.shape[1] 
    if board[0,c] == 0 and A >= a:
        M = (board == 0) ; N = (shape != 0)
        O = M==False ; P = N==True
        k = 0
        while ([True] not in O[k:k+a:,c:c+b:]&P):
            new_board = np.array(board)
            new_board[k:k+a:,c:c+b:] += shape
            k += 1
            U.append(new_board)
            if k > A-a:
                break
    return U
def animate_clear(board):
    U = [] ; c = board.shape[0]
    m = np.min(board,axis=1) 
    z = np.zeros(c,int) 
    a = np.arange(board.shape[0]) 
    x = m!=z 
    if True not in x:
        return []
    new_board = np.array(board)
    new_board[a[x]] = np.zeros(board.shape[1],int)
    Saipan = np.array(new_board)
    U.append(Saipan)
    w = np.max(new_board,axis=1)==0
    r = a[w]
    while True:
        new_board[1:r[-1]+1:] = new_board[:r[-1]:]
        new_board[0] = np.zeros(board.shape[1],int)
        eiei = np.array(new_board)
        if False in (Saipan == eiei):
            U.append(eiei)
        w = np.max(new_board,axis=1)==0 
        r = a[w] ; t = a[~w] 
        if True not in w[t[0]::]:
            break
    return U

xxx039xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 804, 'const': 324, 'code+const': 1128}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [], [('size', 24)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('While', 17)]]
import numpy as np
def get_score(board):
    c = 0
    a = board == 0
    b = np.sum(a,axis=1)
    c = b == 0
    return np.sum(c)*40
def get_time_cap(board, time_caps):
    if np.sum(board) == 0:
       return time_caps[-1]
    a = board != 0
    b = np.sum(a,axis=1)
    c = b > 0 
    d = np.arange(c.shape[0]) 
    e = d[c][0] 
    f = board.shape[0]//len(time_caps) 
    return time_caps[e//f]
def rotate_right(shape):
    return shape[-1::-1,:].T
def rotate_left(shape):
    return shape.T[-1::-1,:]
def animate_drop(board, shape, c):
    x,y = shape.shape
    l = []
    for i in range(len(board)-len(shape)+1):
      nb = np.array(board)
      a = shape == 0
      b = nb[i:x+i , c:y+c] == 0
      s = nb[i:x+i , c:y+c]
      if np.sum(b | a) == x*y:
        s += shape
        l.append(nb)
      else:
        return l
    return l
def animate_clear(board):
    l = []
    r,r1 = board.shape
    x = board != 0
    x = np.sum(x,axis=1)
    k = np.array(board)
    if np.sum(x == r1) == 0 : 
      return l
    b = np.arange(x.shape[0])
    c = b[x == r1]
    k[c] = np.zeros((1,r1),int)
    l.append(k)
    q = np.sum(k,axis=1) == 0
    n = 0
    i=len(q)-1
    while i>=0:
        s = k
        if q[i]:
            s = np.zeros_like(k,int)
            s[0] = k[i+n]
            s[1:i+n+1] = k[0:i+n]
            s[i+n+1:] = k[i+n+1:]
        if np.sum(s == k) != np.size(board):
            k = s
            l.append(k)
            n += 1
        i-=1
    return l

xxx033xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0ValueError('min() arg is an empty sequence')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 838, 'const': 324, 'code+const': 1162}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [('transpose', 3)], [('transpose', 3)], [], []]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('For', 24)]]
import numpy as np
def get_score(board):
  min_board = board.min(axis=1)
  not_zero = min_board>0
  out = int(np.sum(40*not_zero))
  return out
def get_time_cap(board, time_caps):
  n_time = len(time_caps)
  c = len(board[0])
  r = len(board)
  reshape_board = board.reshape(n_time,int((r/n_time)*c))
  total = reshape_board.sum(axis=1)
  eq_zero = total > 0
  nptc = np.array(time_caps)
  out = nptc[eq_zero]
  if len(out) == 0  :
    return time_caps[-1]
  else :
    a = out[0]
    return a
def rotate_right(shape):
  a = shape[-1::-1,:]
  out = a.transpose()
  return out
def rotate_left(shape):
  a = shape[:,-1::-1]
  out = a.transpose()
  return out
def animate_drop(board, shape, c):
  c_shape = len(shape[0])
  r_shape = len(shape)
  new_shape = np.array(shape)
  out = []
  for i in range (len(board)) :
    new_board = np.array(board)
    if i+r_shape <= len(board) and c+c_shape <= len(board[0]) :
      a = new_board[i:i+r_shape , c:c+c_shape] + new_shape
      if np.sum(a) == np.sum(new_shape) :
        new_board[i:i+r_shape , c:c+c_shape] = new_shape
        out += [np.array(new_board)]
  return out
def animate_clear(board):
  new_board = np.array(board)
  a = np.min(new_board,axis=1)
  b = a>0
  k = np.arange(0, len(new_board),1)
  l = k[b]
  if len(l) == 0 : 
    return []
  else : 
    out = []
    new_board[l] = (new_board[b])*0
    out += [np.array(new_board)]
    sumrow = np.sum(new_board,axis=1)
    RZ = sumrow>0
    REZ = sumrow == 0
    k = np.arange(0,len(new_board),1)
    s = list(k[REZ])[-1::-1]
    t = list(k[RZ])[-1::-1]
    tmin = min(t)
    clear_board = list(new_board)
    copy = clear_board
    zero = []
    for e in s :
      if e <= tmin :
        break
      else :
        add = []
        zerorow = clear_board[e]
        copy.pop(e)
        zero += [zerorow]
        add += zero
        add += copy
        out += [np.array(add)]
    return out

xxx041xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 980, 'const': 338, 'code+const': 1318}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('For', 13)]]
import numpy as np
def get_score(board):
    a=board>0
    a=a.reshape(board.shape)
    b=np.sum(a,axis=1)
    c=np.ones_like(b,int)
    return np.sum(c[b==board.shape[1]])*40
def get_time_cap(board, time_caps):
    if np.sum(board)==0: return time_caps[-1]
    a=np.arange(board.shape[0])
    b=np.sum(board,axis=1)
    a=a[b>0][0]
    n=board.shape[0]//len(time_caps)
    return time_caps[a//n]
def rotate_right(shape):
    return shape[-1::-1,:].T
def rotate_left(shape):
    return shape.T[-1::-1,:]
def animate_drop(board, shape, c):
    z=[]
    for i in range(board.shape[0]-len(shape)+1):
        new=np.array(board)
        new1=new==0
        a=np.zeros_like(new,int)
        a[i:i+shape.shape[0],c:c+shape.shape[1]]=shape
        a1=a!=0
        if np.sum(new1&a1) == np.sum(a1):
            new[i:i+shape.shape[0],c:c+shape.shape[1]]+=shape
            z.append(new)
        else: return z
    return z
def animate_clear(board):
    zz=[]
    ss=np.array(board)
    a=board!=0
    a=np.sum(a,axis=1)
    if np.sum(a==board.shape[1])==0 : return zz
    b=np.arange(a.shape[0])
    c=b[a==board.shape[1]]
    ss[c]=np.zeros((1,board.shape[1]),int)
    zz.append(ss)
    dd=board.shape
    for i in range(len(board)):
        d1=ss==0
        d=np.sum(d1,axis=1)
        d=b[d==dd[1]]
        s1=ss.reshape(1,dd[0]*dd[1])
        n=d[-1]+1
        s2=np.arange(dd[0]*dd[1])
        cc=s2<(dd[1]*(n-1))
        c1=s2>=(dd[1]*n)
        z=c1|cc
        z=z.reshape(1,dd[0]*dd[1])
        sss=np.zeros((dd[0],dd[1]),int)
        s1=s1[z].reshape(dd[0]-1,dd[1])
        sss[1:]=s1
        if np.sum(ss[:len(d)])==0:return zz
        ss=sss
        zz.append(ss)
        if np.sum(ss[:len(d)])==0:return zz
    return zz

xxx210xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score0.0
[None0, None120]
test_get_time_cap0.0
[None56, None56, None56, None56, None45, None45, None45]
test_rotate_right0.0
[Nonearray([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, None0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left0.0
[Nonearray([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, None4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 84, 'const': 68, 'code+const': 152}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
import numpy as np
def get_score(board):
    pass
def get_time_cap(board, time_caps):
    pass
def rotate_right(shape):
    pass
def rotate_left(shape):
    pass
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
    pass

xxx216xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[]]
bytecount: {'code': 1168, 'const': 424, 'code+const': 1592}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 15)], [('For', 21)]]
import numpy as np
def get_score(board):
    col=len(board[0])
    check=np.zeros((1,col),int)
    a=np.sum(board==check,axis=1)
    b=np.zeros_like(a,int)
    return np.sum((a==b))*40
def get_time_cap(board, time_caps):
    a=np.sum(board,axis=1)
    r=np.arange(len(a))
    check=np.zeros_like(a)
    b= a!=check
    if len(r[b])==0:
        return time_caps[-1]
    else:
        index=r[b][0]
        wide=len(board)/len(time_caps)
        zone=int(index//wide)
        return time_caps[zone]
def rotate_right(shape):
    return shape[::-1,:].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    new_board = np.array(board)
    row=len(board)
    y=len(shape)
    x=len(shape[0])
    stop=[False]*x
    piece=np.max(shape)
    boardlist=[]
    check=np.zeros((y,x),int)
    mustzero=~((shape==check) | (new_board[0:y,c:c+x]==check))
    if np.sum(mustzero)!=0:
        return []
    conti=True
    for i in range(row-y+1):
        if i==0:
            temp=np.array(new_board)
            temp[temp!=0]=10000
            lowergap=np.argmax(shape[::-1,:],axis=0)
            uppergap=np.argmax(temp[i:i+y,c:c+x],axis=0)
            uppergap[uppergap==0]=y
            minn=np.min(lowergap+uppergap)
            if minn>=y:
                newer=np.array(new_board)
                newer[0:0+y,c:c+x]=shape+new_board[i:i+y,c:c+x]
                boardlist.append(newer)
            else:
                return []
        else:
            if conti==True:
                mustzero= ~((shape==check) | (new_board[i:i+y,c:c+x]==check))
                if np.sum(mustzero)==0:
                    newer=np.array(new_board)
                    newer[i:i+y,c:c+x]=shape+new_board[i:i+y,c:c+x]
                    newer[i-1,c:c+x]=0
                    boardlist.append(newer)
                else:
                    conti=False
            else:
                return boardlist
    return boardlist
def animate_clear(board):
    new_board = np.array(board)
    z=np.zeros_like(new_board,int)
    check=np.sum(new_board==z,axis=1)
    new_board[check==0]=0
    s=np.sum(new_board,axis=1)
    r=np.arange(len(s))[s==0]
    if len(r)==0:
        return []
    start=np.arange(len(new_board))[np.sum(new_board,axis=1)!=0][0]
    c=0
    boardlist=[]
    firstboard=np.array(new_board)
    boardlist.append(firstboard)
    for e in r[::-1]:
        if e >= start:
            new_board[1:e+c+1]=new_board[0:e+c]
            new_board[0]=0
            newer=np.array(new_board)
            boardlist.append(newer)
            c+=1
    return boardlist

xxx041xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]]),
  array([[1, 1, 0, 0],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 0, 0]])],
 [], [], []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 924, 'const': 456, 'code+const': 1380}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('While', 19)]]
import numpy as np
def get_score(board):
    b = board == 0
    c = np.sum(b,axis=1)
    d = c ==0
    return  40*sum(d)
def get_time_cap(board, time_caps):
    f = board != 0
    if np.sum(board) == 0:
        return time_caps[-1]
    else:
        position = np.arange(board.shape[0])
        a = board != 0
        b = np.sum(a,axis=1)
        c = b!= 0
        d = c.T
        all_pos = position[d]
        first = int(np.min(all_pos))
        n = board.shape[0] / len(time_caps)
        nn = first//n
        return time_caps[int(nn)]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    ans = []
    if 0<=c <= board.shape[1] - shape.shape[1]: 
        for n in range(board.shape[1]): 
            boards = np.array(board)
            if np.sum(boards[n:n+shape.shape[0],c:c+shape.shape[1]]) !=0:
                return ans
            else:
              boards[n:n+shape.shape[0],c:c+shape.shape[1]] = shape
              ans.append(boards)
        return ans            
    else:
        return ans
def stop(board): 
    a1 = board != 0
    x = np.sum(a1,axis = 1)
    dd = x != 0
    sum1 = np.sum(dd)
    sum2 = np.sum(dd[-sum1::])
    return sum1,sum2
def findmax_0(board):    
    a = board != 0
    b = np.sum(a,axis = 1)
    c = b == 0
    c = c.T 
    all_n = np.arange(board.shape[0])
    below_0 = np.max(all_n[c])
    return below_0
def animate_clear(board):
    board_copy = np.array(board)
    ncol = board.shape[1]
    nrow = board.shape[0]
    boardboo = board == 0
    a = np.sum(boardboo,axis = 1)
    b = a == 0
    b = b.T
    num = np.arange(nrow) 
    what_row = num[b]  
    board_copy[what_row] = 0
    answer = [board_copy] 
    board_use = np.array(board_copy)
    alls,bels = stop(board_use)
    if alls == bels:
        return []
    else:
        while alls != bels:
            row0 = findmax_0(board_use)
            move = board_use[0:row0,:]
            board_use[1:move.shape[0]+1,:] = move
            board_use[0,:] = 0
            sub_answer = np.copy(board_use)
            answer.append(sub_answer)
            alls,bels = stop(board_use)
        return answer

xxx204xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[56, 56, 56, 56, 456, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [10, 0, 0, 2, 40],
       [01, 0, 02, 04],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [10, 0, 0, 2, 40],
       [01, 0, 02, 04],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 660, 'const': 336, 'code+const': 996}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('For', 14)]]
import numpy as np
def get_score(board):
    x = np.min(board , axis = 1)
    x = x[x > 0]
    return len(x) * 40
def get_time_cap(board, time_caps):
    time = board.shape[0] // len(time_caps)
    a = np.max(board ,axis = 1)
    inde = int(round(len(a[a == 0]) / time , 0))
    if inde >= len(time_caps):
        return time_caps[-1]
    else:
        return time_caps[inde]
def rotate_right(shape):
    a = shape.T
    return a[0: , ::-1]
def rotate_left(shape):
    a = shape.T
    return a[::-1]
def animate_drop(board, shape, c):
    ansx = []
    for i in range(board.shape[0]):
        newb = np.array(board) ; news = np.array(shape)
        if np.sum(board[i : i + shape.shape[0] , c : c + shape.shape[1]]) == 0:
            if i + shape.shape[0] <=  board.shape[0]:
                newb[i : i + shape.shape[0] , c : c + shape.shape[1]] += shape
                ansx.append(np.array(newb))
        else:
            return ansx
            break
def animate_clear(board):
    newb = np.array(board) ; ans = []
    mincol  = np.min(board, axis=1)
    newb[mincol > 0] = 0
    maxcol = np.max(newb ,axis = 1) 
    max_col = np.arange(maxcol.shape[0])
    max_col = max_col[maxcol <= 0 ]
    max_col = max_col[max_col > 0 ]     
    if np.sum(mincol) == 0:
        return ans
    else:
        ans.append(np.array(newb))
        for i in max_col:
            newb[1 : i + 1 ] = newb[0 : i]
            newb[0] = np.zeros_like(newb[0])
            ans.append(np.array(newb))
        return ans

xxx024xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 686, 'const': 310, 'code+const': 996}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 7)], [('While', 10)]]
import numpy as np
def get_score(board):
    non_zero_row = board[np.min(board, axis=1)!=0]
    return non_zero_row.shape[0]*40
def get_time_cap(board, time_caps):
    zero_row_count = board[np.sum(board,axis=1) == 0,:].shape[0]
    po = (int)(zero_row_count//(board.shape[0]/len(time_caps))) 
    if po == len(time_caps) :
      po-=1
    return time_caps[po]
def rotate_right(shape):
    new_shape = np.array(shape)
    new_shape = new_shape.T
    return new_shape[:,::-1]
def rotate_left(shape):
    new_shape = np.array(shape)
    new_shape = shape.T
    return new_shape[::-1,:]
def animate_drop(board, shape, c):
    res = []
    row = 0
    shape_value = np.sum(shape != 0)
    total_start = np.sum(board != 0)
    while(True) :
      if row+shape.shape[0] < board.shape[0] :
        new_board = np.array(board)
        new_board[row:row+shape.shape[0], c:c+shape.shape[1]] += shape
        if np.sum(new_board != 0) == total_start+shape_value : 
          res.append(new_board)
        else :
          break
      else : break
      row+=1
    return res
def animate_clear(board):
    res = []
    new_board = np.array(board)
    new_board[np.min(new_board, axis=1)!=0] = [0]
    res.append(np.array(new_board))
    if(np.sum(new_board)==np.sum(board)): return []
    bottom = board.shape[0]-1
    top = 0
    while(bottom>top):
      if np.sum(new_board[bottom,:]) != 0 : 
        bottom-=1
        continue
      new_board[1:bottom+1,:] = new_board[0:bottom]
      new_board[0,:] = [0]
      res.append(np.array(new_board))
      top+=1
    return res

xxx200xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 1360, 'const': 366, 'code+const': 1726}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 12)]]
import numpy as np
def get_score(board):
    min_arr = np.min(board, axis=1)
    ans = min_arr[min_arr > 0]
    x = len(list(ans))
    pts = 40 * x
    return pts
def get_time_cap(board, time_caps):
    s = np.sum(board, axis=1)
    idx = np.argmax(s > 0)
    if(np.sum(s) == 0):
        idx = board.shape[0] - 1
    return time_caps[int(idx / int(board.shape[0]/len(time_caps)))]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[::,::-1].T
def animate_drop(board, shape, c):
    size = shape.shape[1]
    height = shape.shape[0]
    ans = []
    idx_row = 0
    idx_height = 0
    for x in board:
        temp = np.array(board)
        if np.sum(x[c:c+size]) > 0:
            if np.sum(x[c:c+size][shape[-1] > 0]) == 0:
                temp[idx_row-idx_height:idx_row+1, c:c +
                     size] += shape[height-idx_height-1:height, :]
                if(height > 1):
                    if np.sum(np.array(board[idx_row][c:c+size])[shape[-2] > 0]) > 0:
                        if(idx_height == height - 1):
                            ans.append(np.array(temp))
                        break
                temp[idx_row-idx_height:idx_row+1, c:c +
                     size] -= shape[height-idx_height-1:height, :]
            else:
                break
        if height == 3:
            if idx_row-1 >= 0 and np.sum(np.array(board[idx_row-1][c:c+size])[shape[0] > 0]) > 0:
                if(idx_height == height - 1):
                    temp[idx_row-idx_height:idx_row+1, c:c +
                         size] += shape[height-idx_height-1:height, :]
                    ans.append(np.array(temp))
                break
        temp[idx_row-idx_height:idx_row+1, c:c +
             size] += shape[height-idx_height-1:height, :]
        idx_row += 1
        if(idx_height == height - 1):
            ans.append(np.array(temp))
        if(idx_height < height-1):
            idx_height += 1
    return ans
def animate_clear(board):
    temp = np.array(board)
    zero_idx = 1
    non_zero_idx = 0
    zeros = np.zeros((board.shape[1],), int)
    ans = []
    curr_idx = 0
    max_idx = board.shape[0]
    summ = np.sum(board, axis=1)
    temp_idx = max_idx-1
    last_board = []
    while True:
        if curr_idx < max_idx:
            if np.min(temp[curr_idx]) > 0:
                temp[curr_idx] = zeros
            curr_idx += 1
            if(curr_idx == max_idx):
                last_board = np.array(temp)
                summ = np.sum(last_board, axis=1)
                if np.min(summ) > 0:
                    break
                non_zero_idx = np.argmax(summ > 0)
                zero_idx = len(summ) - np.argmin(summ[::-1]) - 1
                ans.append(temp)
                if np.sum(summ) == 0:
                    break
                if non_zero_idx > zero_idx:
                    break
        else:
            next_i = temp_idx + 1
            if next_i < max_idx and np.sum(last_board[next_i]) == 0:
                last_board[next_i] = last_board[next_i-1]
                last_board[next_i-1] = zeros
            temp_idx -= 1
            if temp_idx < 0:
                summ = np.sum(last_board, axis=1)
                non_zero_idx = np.argmax(summ > 0)
                zero_idx = len(summ) - np.argmin(summ[::-1]) - 1
                ans.append(np.array(last_board))
                if non_zero_idx > zero_idx:
                    break
                temp_idx = max_idx-1
    return ans

xxx037xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 924, 'const': 352, 'code+const': 1276}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 11)]]
import numpy as np
def get_score(board):
    return np.sum(np.sum(board != 0, axis = 1) == board.shape[1]) *40
def get_time_cap(board, time_caps):
    if np.sum(board) != 0:
        return time_caps[(np.arange(board.shape[0])[np.sum(board,axis=1)>0][0] // (board.shape[0]//len(time_caps)) )]
    else:
        return time_caps[-1]
def rotate_right(shape):
    return np.array(shape)[::-1].T
def rotate_left(shape):
    return np.array(shape)[:,::-1].T
def animate_drop(board, shape, c):
    quell = []
    nboard = np.array(board)
    nshape = np.array(shape)
    for e in range (nboard.shape[0]):
        if e < nshape.shape[0]:
            tocheck = nboard[:e+1,c:c+nshape.shape[1]]
        else:
            tocheck = nboard[e+1-nshape.shape[0]:e+1,c:c+nshape.shape[1]]
        if not (np.sum(tocheck*nshape[-1:-(e+2):-1][::-1,:]) == 0):
            if e < nshape.shape[0]:
                return []
            else:
                break
        if tocheck.shape == nshape.shape:
            legal = np.array(nboard)
            shapemod = nshape[-1:-(e+2):-1][::-1,:]+tocheck
            legal[e+1-nshape.shape[0]:e+1,c:c+nshape.shape[1]] = shapemod
            quell.append(legal)
    return quell
def animate_clear(board):
    display = []
    a = np.arange(board.shape[0])[np.sum(board == 0, axis = 1) == 0]
    if len(a) == 0:
      return []
    Current = np.array(board)
    Current[a] = 0
    toAdd = np.array(Current)
    display.append(toAdd)
    while np.sum(toAdd[:np.sum(np.sum(toAdd == 0,axis = 1) == toAdd.shape[1])]) != 0:
        maxzero = np.max(np.arange(Current.shape[0])[np.sum(Current == 0, axis = 1) == Current.shape[1]])
        q = np.arange(maxzero+1)[np.sum(Current[:maxzero+1] != 0, axis = 1)> 0]
        f = Current[q-Current.shape[0]]
        Current[q] = 0
        Current[q+1] = f
        toAdd = np.array(Current)
        display.append(toAdd)
    return display

xxx216xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1184, 'const': 404, 'code+const': 1588}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 25)], [('For', 33)]]
import numpy as np
def get_score(board):
    y=(board!=0) 
    x=np.sum(y,axis=1) 
    w=np.sum(x==board.shape[1]) 
    score=w*40 
    return score
def get_time_cap(board, time_caps):
    x=(board>0)
    y=np.sum(x,axis=1) 
    index=np.arange(len(y))[y>0]  
    index+=1                      
    if(list(index)==[]) :           
        return time_caps[-1]      
    position=index[0]             
    divide=board.shape[0]//len(time_caps) 
    position_in_section=position//divide   
    if(position%divide!=0) :      
        position_in_section+=1
    return time_caps[position_in_section-1] 
def rotate_right(shape):
    shape2=np.array(shape).T
    result=shape2[:,::-1]
    return result
def rotate_left(shape):
    shape2=np.array(shape).T
    result=shape2[::-1,:]
    return result
def animate_drop(board, shape, c):
    result=[]
    number_of_chip_before=np.sum(board!=0)                                   
    number_of_chip_of_shape=np.sum(shape!=0)                                 
    total_number_of_chip=number_of_chip_before+number_of_chip_of_shape       
    copy_of_board=np.array(board) 
    row_length_of_input_chip=shape.shape[0]         
    column_length_of_input_chip=shape.shape[1]      
    adding_copy_of_board=np.array(board) 
    adding_board=np.zeros((row_length_of_input_chip,copy_of_board.shape[1]),int) 
    list_of_adding=list(adding_board)+list(adding_copy_of_board)
    np_of_adding=np.array(list_of_adding) 
    i=0
    while(True) :  
        copy_of_board2=np.array( copy_of_board)   
        copy_of_board[i:i+row_length_of_input_chip,c:c+column_length_of_input_chip]+=shape   
        if(np.sum(copy_of_board!=0) != total_number_of_chip) : 
            break
        result.append(copy_of_board) 
        copy_of_board=copy_of_board2 
        if(i+row_length_of_input_chip==board.shape[0]) : 
            break
        i+=1
        np_of_adding2=np.array(np_of_adding)
        np_of_adding[i:i+row_length_of_input_chip,c:c+column_length_of_input_chip]+=shape
        if(np.sum(np_of_adding!=0) != total_number_of_chip) : 
            break
        np_of_adding=np_of_adding2
    check=np_of_adding[:row_length_of_input_chip,:]
    sum_check=np.sum(check)
    if(sum_check!=0) :
        return []
    return result
def change_board(board) :
    copy_of_board=np.array(board)         
    check_board=copy_of_board!=0
    check_board=check_board*1             
    sum_check_board=np.sum(check_board,axis=1)  
    check_full_row=sum_check_board==copy_of_board.shape[1]
    check_full_row=check_full_row*1       
    reverse=check_full_row==0
    reverse=reverse*1                     
    multiple_for_check=reverse.reshape(reverse.shape[0],1)    
    result=copy_of_board*multiple_for_check
    return result
def animate_clear(board):
    copy_board=np.array(board)                     
    copy_board=change_board(copy_board)
    board_check=copy_board==0                           
    board_check=board_check*1                      
    sum_line=np.sum(board_check,axis=1)            
    check_line=sum_line!=copy_board.shape[1] 
    check_line=check_line*1                        
    index=np.arange(len(check_line))[check_line==0] 
    index=index[::-1] 
    result=[]
    if(np.sum(copy_board)==np.sum(board)) : 
        return []
    result2=[]
    result2.append(change_board(copy_board))
    count=0
    for i in index :
        i=i+count
        above_board=np.array(copy_board[:i])
        below_board=np.array(copy_board[i+1:])
        y=[[0]*copy_board.shape[1]]
        if(list(below_board)!=[]) :
            update_board=y+list(above_board)+list(below_board)
        else :
            update_board=y+list(above_board)
        result=np.array(update_board)
        copy_board=np.array(result)
        count+=1
        if(np.sum(above_board)==0) :
            break
        result2.append(result)
    return result2

xxx044xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 582, 'const': 334, 'code+const': 916}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 4)], []]
import numpy as np
def get_score(board):
  b = (board != 0)
  k = np.sum(b,axis = 1) == board.shape[1]
  n = np.arange(b.shape[0]) 
  a = n[k]
  z = board[a, : ]
  return z.shape[0]*40
def get_time_cap(board, time_caps):
    k = board
    j = list(board)
    b = list( np.sum(board, axis = 1) != 0)
    z = True
    r = (len(j))/(len(time_caps))
    if z in b:
      m = b.index(z)  
      if m %r != 0:
        n = (m-1)//r
      else:
        n = m//r
      if n >= len(time_caps):
        return time_caps[-1]
      else:
        return time_caps[int(n)]
    else:
          return time_caps[-1]
def rotate_right(shape):
  r = shape
  q = r[::-1,::]
  return  q.T
def rotate_left(shape):
  r = shape
  q = r[::,::-1]
  return  q.T
def animate_drop(board, shape, c):
  e= []
  i= 0
  while True:
    y = (shape != 0.5)
    x  = (board == 0)
    if False in    x[i:i+len(shape) , c:len(shape[0])+c] &y or ( i + len(shape) == len(board)+1):
      break;
    nb = np.array(board)
    nb[i:i+len(shape), c :c + len(shape[0])] += shape
    e.append(nb)
    i +=1
  return e
def animate_clear(board):
     x = (board == 0)
     if True  in x :
       return []
     else:
       pass

xxx030xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 842, 'const': 338, 'code+const': 1180}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 16)]]
import numpy as np
def get_score(board):
    return 40*np.sum(np.sum(board != 0 , axis = 1) == board.shape[1])
def get_time_cap(board, time_caps):
    height , width = board.shape
    rang = height//len( time_caps)
    i = np.argmax(np.sum(board != 0 , axis = 1) != 0)
    if np.sum(np.sum(board != 0 , axis = 1) != 0) == 0:
      return time_caps[-1]
    return time_caps[i//rang]
def rotate_right(shape):
    return shape.T[: , ::-1]
def rotate_left(shape):
     return shape.T[ ::-1 ]
def animate_drop(board, shape, c):
    new_board = np.array(board) ; new_shape = np.array(shape)
    hb , wb = new_board.shape ; hs , ws =  new_shape.shape
    li_ans = []
    for i in range (hb - hs + 1):
      if sum(new_board[i:i+hs , c:c+ws] [new_shape != 0]) == 0 :
        new_board[i:i+hs , c:c+ws][new_shape != 0] = new_shape[new_shape != 0]
        li_ans.append(new_board)
        new_board = np.array(board) 
      else:
        return li_ans
    return li_ans
def animate_clear(board):
    new_board = np.array(board) 
    height , width = board.shape
    li_ans = []
    ran = np.array(np.arange(height))
    pos = ran[np.sum(new_board != 0 , axis = 1) == width]
    if len(pos) == 0:
      return li_ans
    new_board[pos] = [0]
    first = np.array(new_board)
    li_ans.append(first)
    row_not_0 = ran[np.sum(new_board != 0 , axis = 1) != 0][::-1]
    no_row_not_0 = np.sum(np.sum(new_board != 0 , axis = 1) != 0)
    goal = np.array(np.arange(height-1 , height-1-no_row_not_0 ,-1))
    while list(row_not_0) != list(goal):
        blank = row_not_0[row_not_0 != goal]
        fill = row_not_0[row_not_0 != goal]+1
        check_fill = np.array(list(fill[1:]) + [-1])
        new_board[row_not_0[row_not_0 != goal]+1] = new_board[row_not_0[row_not_0 != goal]]
        new_board[blank[blank != check_fill]] = [0]
        ans = np.array(new_board)
        li_ans.append(ans)
        row_not_0 = ran[np.sum(new_board != 0 , axis = 1) != 0][::-1]
    return li_ans

xxx036xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 892, 'const': 338, 'code+const': 1230}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 6)], [('While', 12)]]
import numpy as np
def get_score(board):
    r,c = board.shape
    m = np.array(board)
    n = np.sum((m!=0),axis=1)
    score = np.sum(n == c)*40
    return score
def get_time_cap(board, time_caps):
    r,c = board.shape
    rowgap = r//len(time_caps)
    m = np.array(board)
    n = m.reshape((r//rowgap,c*rowgap))
    o = np.sum(n,axis=1)
    p = (o == 0)
    tc_index = np.sum(p)
    if tc_index >= len(time_caps):
        time = time_caps[-1]
    else:
        time = time_caps[tc_index]
    return time
def rotate_right(shape):
    shape_rotright = shape[::-1,:].T
    return shape_rotright
def rotate_left(shape):
    shape_rotleft = shape[:,::-1].T
    return shape_rotleft
def animate_drop(board, shape, c):
    anime = []
    i = 0
    sr,sc = shape.shape
    while True:
        if i+sr > board.shape[0]+sr:
            break
        old = np.array(board)
        m = np.zeros((board.shape[0]+sr,board.shape[1]), int)
        m[sr:,:] = old[:,:]
        n = m[i:i+sr,c:c+sc]
        place_area = (n == 0)
        shape_area = (shape != 0)
        shape_size = np.sum(shape_area)
        size_after_placed = np.sum(place_area & shape_area)
        if size_after_placed != shape_size:
            break
        m[i:i+sr,c:c+sc] = m[i:i+sr,c:c+sc]+shape
        anime.append(m[sr:,:])
        i += 1
    return anime[sr:]
def animate_clear(board):
    anime = []
    check_board = np.sum(np.array(board) != 0,axis=1)
    check_board[check_board == board.shape[1]] = 0
    check_board = (check_board != 0).reshape((len(check_board),1))
    if np.sum((check_board)) == board.shape[0]:
        return anime
    clear_board = check_board*np.array(board)
    anime.append(clear_board)
    checkrow = board.shape[0]-1
    while True:
        next_board = np.array(anime[-1])
        if np.sum(next_board[checkrow]) == 0:
            next_board[1:checkrow+1,:] = next_board[0:checkrow,:]
            next_board[0,:] = 0
            anime.append(next_board)
        else: 
            checkrow -= 1
        if np.sum(next_board[0:checkrow]) == 0:
            break
    return anime

xxx033xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError("non-broadcastable output operand with shape (1,3) doesn't match the broadcast shape (2,3)")
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (2,3) (3,3) (2,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 898, 'const': 324, 'code+const': 1222}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 8)], [('While', 15)]]
import numpy as np
def get_score(board):
    p=np.array(board)
    k= p==0
    l=np.sum(k,axis=1)
    l= l==0
    dude=l*40
    dude=np.sum(dude)
    return dude
def get_time_cap(board, time_caps):
    p=board != 0
    p1=np.sum(p,axis=1)
    cat=p1>0
    a=np.arange(0,board.shape[0])
    b=a[cat]
    if np.sum(cat)==0:
      return time_caps[-1]
    else:
      first_row=b[0]
    intervalz=board.shape[0]//len(time_caps)
    numbertosuccess=first_row//intervalz
    return time_caps[numbertosuccess]
def rotate_right(shape):
    b=np.array(shape)
    c=b.T
    d=c[:,::-1]
    return d
def rotate_left(shape):
    b=np.array(shape)
    c=b.T
    d=c[::-1,:]
    return d
def animate_drop(board, shape, c):
    ans=[]
    new_board= np.zeros((shape.shape[0]-1+board.shape[0],board.shape[1]),int)
    new_board[shape.shape[0]-1:,:]=np.array(board)
    zeroBefore=np.sum(new_board == 0)
    r=0
    while True:
      new_board2=np.array(new_board)
      new_board2[r:r+shape.shape[0],c:c+shape.shape[1]] += np.array(shape)
      zeroAfter=np.sum(new_board2 == 0)
      if zeroBefore - zeroAfter == np.sum(shape != 0):
        ans.append(np.array(new_board2)[shape.shape[0]-1:,:])
        r += 1
      else:
        break
    return ans[shape.shape[0]-1:]
def animate_clear(board):
    ans=[]
    new_board=np.array(board)
    k= new_board==0
    c=np.sum(k,axis=1)
    c= c != 0
    n=c.shape[0]
    if np.sum(c) == n:
      return []
    c=c.reshape(n,1)
    new_board=new_board*c
    ans.append(np.array(new_board))
    r=n-1
    while True:
      if np.sum(new_board[0:r,:]) == 0:
        break
      if np.sum(new_board[r,:]) == 0 :
        new_board[1:r+1,:] = new_board[0:r,:]
        new_board[0,:] = 0
        ans.append(np.array(new_board))
      else:
        r -= 1
    return ans

xxx017xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 736, 'const': 338, 'code+const': 1074}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('For', 11)]]
import numpy as np
def get_score(board):
    each_row = board != 0
    no_zero = np.sum(each_row, axis=1) == board.shape[1]
    return np.sum(no_zero) * 40
def get_time_cap(board, time_caps):
    group = board.shape[0] // len(time_caps)
    group_of_row = board.reshape((len(time_caps), board.shape[1] * group))
    no_zero = np.sum(group_of_row, axis=1) != 0
    c = np.arange(len(time_caps))
    check = c[no_zero]
    if len(check) != 0:
        return time_caps[check[0]]
    return time_caps[-1]
def rotate_right(shape):
    new = shape[::-1]
    return new.T
def rotate_left(shape):
    new = shape[:, ::-1]
    return new.T
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    out = []
    len_row, len_col = new_shape.shape
    status = new_shape != 0
    for i in range(new_board.shape[0]):
        a = np.zeros_like(new_board)
        if i + len_row <= new_board.shape[0] and c + len_col <= new_board.shape[1] and np.sum(new_board[i:i + len_row, c:c + len_col][status]) == 0:
            a[i:i + len_row, c:c + len_col] = new_shape
            check = new_board + a
            out.append(check)
        else:
            break
    return out
def animate_clear(board):
    new_board = np.array(board)
    condition = new_board == 0
    start = np.sum(condition, axis=1) == 0
    if np.sum(start) == 0:
        return []
    new_board[start] = 0
    out = [new_board]
    row_num = np.arange(new_board.shape[0])
    for i in range(new_board.shape[0]):
        add = np.zeros_like(new_board)
        check = np.sum(new_board, axis=1) == 0
        remove_index = row_num[check][-1]
        add[remove_index+1:] = new_board[remove_index+1:]
        add[1:remove_index+1] = new_board[:remove_index]
        if np.sum(add != new_board) != 0:
            out.append(add)
        else:
            break
        new_board = add
    return out

xxx211xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 990, 'const': 376, 'code+const': 1366}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 10)], [('While', 11)]]
import numpy as np
def get_score(board):
    return sum(np.min(board, axis=1) != 0) * 40
def get_time_cap(board, time_caps):
    if np.sum(board) == 0: return time_caps[-1]
    else: return time_caps[np.argmax(np.max(board, axis=1) != 0) // (board.shape[0]//len(time_caps))]
def rotate_right(shape):
    return shape.T[:, ::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    output = []
    new_board = np.array(board)
    new_shape = np.array(shape)
    s = np.array(new_board[:new_shape.shape[0], c:c+new_shape.shape[1]])
    p = np.array(new_board[:new_shape.shape[0], c:c+new_shape.shape[1]] != 0)
    q = np.array(new_board[:new_shape.shape[0], c:c+new_shape.shape[1]] + new_shape)
    i = 0
    while True:
      a = False
      if True in p:
        if False in (s[p] == q[p]):
          break
        else:
          a = True
      else:
        a = True
      if a:
        new_board[i:i+new_shape.shape[0], c:c+new_shape.shape[1]] = new_shape + s
        output.append(np.array(new_board))
        new_board[i:i+new_shape.shape[0], c:c+new_shape.shape[1]] = s
        i += 1
        if i + new_shape.shape[0] > new_board.shape[0]:
          break
        s = np.array(new_board[i:i+new_shape.shape[0], c:c+new_shape.shape[1]])
        p = np.array(new_board[i:i+new_shape.shape[0], c:c+new_shape.shape[1]] != 0)
        q = np.array(new_board[i:i+new_shape.shape[0], c:c+new_shape.shape[1]] + new_shape)
    return output
def animate_clear(board):
    output = []
    new_board = np.array(board)
    c = np.array(new_board)
    new_board[np.sum(new_board != 0, axis=1) == new_board.shape[1]] = 0
    if False not in ((c - new_board) == 0):
      return []
    output.append(np.array(new_board))
    i = 0
    while True:
      a = np.sum(new_board, axis=1) == 0
      pos = np.arange(new_board.shape[0])
      posa = pos[a][pos[a] > 0]
      posb = (posa-1)[np.sum((new_board[posa-1]) , axis=1) != 0]
      if len(posb) == 0:
        break
      posc = np.max(posb)
      new_board[1:posc+2] = new_board[:posc+1]
      new_board[0] = 0
      output.append(np.array(new_board))
    return output

xxx217xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 842, 'const': 324, 'code+const': 1166}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 14)]]
import numpy as np
def get_score(board):
  v = np.min(board, axis=1)
  t = v[v>0]
  a = len(t)
  return a*40
def get_time_cap(board, time_caps):
  v = np.max(board, axis=1)
  t = v>0
  l = np.arange(t.shape[0])
  ll = l[t]
  if len(ll) == 0:
      return time_caps[-1]
  f = ll[0]//(len(board)//len(time_caps))
  return time_caps[f]
def rotate_right(shape):
  a = np.array(shape).T
  a = a[:,::-1]
  return a
def rotate_left(shape):
  a = np.array(shape).T
  a = a[::-1]
  return a
def animate_drop(board, shape, c):
  nb = np.array(board)
  ns = np.array(shape)
  l = []
  for i in range(len(board)):
      if i < len(ns)-1:
          nn = nb[:i+1,c:len(ns[0])+c]
          if np.sum((nn != 0) & (ns[len(ns)-(i+1),:])) != 0:
              break
      else:
          nn = nb[i+1-len(ns):1+i,c:len(ns[0])+c]
          if np.sum((nn != 0) & (ns!=0)) == 0:
              new = np.array(board)
              new[i+1-len(ns):1+i,c:len(ns[0])+c] = ns+nn
              l.append(new)
          else : break
  return l
def animate_clear(board):
  nb = np.array(board)
  l = []
  v = np.min(nb, axis=1)
  t = v[v>0]
  a = len(t)
  if a == 0:
      return []
  tde = np.arange(len(nb))[v>0]
  nb[tde] = 0
  ta = np.array(nb)
  l.append(ta)
  while True:
      vv = np.max(nb, axis=1)
      tdee = np.max(np.arange(len(nb))[vv==0])
      if np.max(nb[:tdee+1]) == 0: break
      nb[1:tdee+1] = nb[:tdee]
      nb[0] = 0
      ta = np.array(nb)
      l.append(ta)
  return l

xxx028xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 844, 'const': 376, 'code+const': 1220}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 15)], [('While', 12)]]
import numpy as np
def get_score(board):
    score = np.min(board, axis=1)
    full = score > 0
    return len(score[full])*40
def get_time_cap(board, time_caps):
    jumNuanTao = len(board)//len(time_caps)
    board2 = board.reshape((len(board)//jumNuanTao,len(board[0])*jumNuanTao))
    board2_sum = np.sum(board2,axis=1)
    x = board2_sum > 0
    index = np.arange(len(board2))
    ans = index[x]
    if len(ans) > 0:
        return time_caps[ans[0]]
    else:
        return time_caps[-1]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    isStuck = False
    shapenumber = np.max(shape)
    board_copy = np.array(board)
    shape_copy = np.array(shape)
    shape_bool = (shape == shapenumber)
    shape_toCheck = shape[shape_bool]
    if len(board_copy[0][c::]) < len(shape_copy[0]):
        return []
    else: 
        animation = []
        board_copy_canPlace = board_copy[0::, c:c+len(shape[0]):]
        for i in range(len(board)-len(shape_copy)+1):
            new_frame = board_copy
            if isStuck == False:
                board2 = board_copy_canPlace[i:i+len(shape_copy):, 0::]
                b2ws = board2+shape 
                b2ws_bool = b2ws[shape_bool]
                shape_ans = (b2ws_bool == shape_toCheck)
                if False in shape_ans:
                    isStuck = True
                    break
                else:
                    x = np.array(new_frame)
                    x[i:i+len(shape_copy), c:c+len(shape[0]):] += shape_copy
                    animation.append(x)
            else:
                break
    return animation
def animate_clear(board):
    board_copy = np.array(board)
    board_tf = (np.array(board) != 0)
    fullRows = (board_tf.sum(axis=1) == len(board[0]))
    board_copy[fullRows] = 0
    animation = [] 
    isDifferent = (True in (board != board_copy))
    if isDifferent: 
        animation.append(board_copy)
    i = len(board_copy)-1
    while i >= 0:
        checkIfZero = (board_copy[i] == np.zeros_like(board_copy[0]))
        if False not in checkIfZero:
            new_board = np.zeros_like(board_copy)
            new_board[i+1::] = board_copy[i+1::]
            new_board[1:i+1:] = board_copy[0:i:]
            if (True in (board_copy != new_board)): 
                board_copy = np.array(new_board)
                animation.append(board_copy)
            else: 
                break
        else:
            i -= 1
    return animation

xxx021xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0., 1.],
       [0., 2.],
       [5., 3.],
       [0., 4.]]),
 array([[1., 0.],
       [2., 0.],
       [3., 5.],
       [4., 0.]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1058, 'const': 466, 'code+const': 1524}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 24)]]
import numpy as np
def get_score(board):
    maisun = np.sum(board==0,axis=1)==0
    return np.sum(maisun * 40)
def get_time_cap(board, time_caps):
    pos = np.arange(0,board.shape[0])
    b = np.sum(board==0,axis = 1)
    if np.sum(b != board.shape[1]) == 0:
        return time_caps[-1]
    else:
        locate = pos[b[pos]<board.shape[1]][0] 
        locate = locate//(board.shape[0]/len(time_caps))
        return time_caps[int(locate)]
def rotate_right(shape):
    new = np.ndarray((shape.shape[1],shape.shape[0]))
    new[:,::-1] = shape.T
    return new
def rotate_left(shape):
    new = np.ndarray((shape.shape[1],shape.shape[0]))
    new = shape.T[::-1]
    return new
def animate_drop(board, shape, c):
    res = []
    for i in range(board.shape[0] - shape.shape[0]+1):
        cop_board = np.array(board)
        section = board[i:i+shape.shape[0], c:c+shape.shape[1]]
        if np.sum(section[(shape != 0) == True]) == 0:
            cop_board[i:i+shape.shape[0], c:c+shape.shape[1]] += shape
            res.append(cop_board)
        else:
          break
    return res
def animate_clear(board):
    res = []
    check_filled = np.zeros_like(board.shape[1])
    size_board = np.arange(board.shape[0])
    check = board == check_filled
    b = False
    if np.sum(np.sum(check, axis=1) == 0) == 0:
      b = True
    board[np.sum(check, axis=1) == 0, :] = check_filled
    check2 = board == check_filled
    nofilled = size_board[np.sum(check2, axis=1) != board.shape[1]]
    new_nofilled = np.ndarray((nofilled.shape[0]+1))
    new_nofilled[nofilled.shape[0]] = board.shape[0]
    new_nofilled[:nofilled.shape[0]] = nofilled[::]
    x = new_nofilled[1:] - new_nofilled[:-1] - 1
    filled_size = np.sum(x)
    if not b:
        cop_board = np.array(board)
        res.append(cop_board)
        b = np.ndarray((1, 4), bool) + [True]
        row = board.shape[0]-1
        c = False
        while filled_size > 0:
            if row == 0:
                c = False
                filled_size -= 1
                board[row, :] = check_filled
                row = board.shape[0]-1
                cop_board = np.array(board)
                res.append(cop_board)
            if c:
                board[row, :] = board[row-1, :]
            if np.sum(board[row, :]) == 0 and not c:
                c = True
                board[row, :] = board[row-1, :]
            row -= 1
    return res

xxx201xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1006, 'const': 338, 'code+const': 1344}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 9)], [('While', 17)]]
import numpy as np
def get_score(board):
    b = board != 0
    return sum(np.sum(b, axis =1) == board.shape[1]) *40
def get_time_cap(board, time_caps):
    n = board.shape[0]//len(time_caps)
    if np.sum(board) == 0 :
        return time_caps[-1]
    else :
        b = board != 0
        nn = np.sum(b, axis =1)
        p = np.arange(nn.shape[0])
        pos = p[nn != 0]
        return time_caps[pos[0]//n]
def rotate_right(shape):
    s = shape[::-1]
    rr = s.T
    return rr
def rotate_left(shape):
    s = shape.T
    rl = s[::-1]
    return rl
def animate_drop(board, shape, c):
    ad = []
    n = 0
    b = board[n:n+shape.shape[0],c:c+shape.shape[1]]
    s = (shape != 0)
    bb = b[s] == 0
    if np.sum(b[0]) == 0 :
        while np.sum(bb) == np.sum(s):
            nb = np.array(board)
            nb[n:n+shape.shape[0],c:c+shape.shape[1]] += shape
            ad += [nb]
            n += 1
            if n == board.shape[0]-shape.shape[0]+1 : break
            b = board[n:n+shape.shape[0],c:c+shape.shape[1]]
            bb = b[s] == 0
    return ad
def animate_clear(board):
    ac = []
    b = board != 0
    n = np.sum(b, axis = 1)
    nn = np.arange(n.shape[0])
    if np.sum(n == board.shape[1]) == 0:
        return ac
    pos = nn[n == board.shape[1]]
    new_board = np.array(board)
    new_board[pos,:] = 0
    ac += [new_board]
    b1 = new_board == 0
    n1 = np.sum(b1, axis = 1)
    nn1 = np.arange(n1.shape[0])
    pos1 = nn1[n1 == board.shape[1]]
    while np.sum(new_board[0:pos1[-1],:]) != 0 :
        nb = np.array(new_board)
        nb[1:pos1[-1]+1,:] = new_board[:pos1[-1],:]
        nb[0,:] = 0
        ac += [nb]
        new_board = nb
        b = nb != 0
        n = np.sum(b, axis = 1)
        nn = np.arange(n.shape[0])
        pos = nn[n == nb.shape[1]]
        new_board = np.array(nb)
        new_board[pos,:] = 0
        b1 = new_board == 0
        n1 = np.sum(b1, axis = 1)
        nn1 = np.arange(n1.shape[0])
        pos1 = nn1[n1 == board.shape[1]]
    return ac

xxx200xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[array([[0, 0, 0, 0],
       [1, 0, 1, 1]])], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [ array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 02, 8, 8, 0],
       [1, 1, 02, 0, 8, 0]])],
 [array([[0, 02, 02, 02, 0, 0],
       [0, 0, 0, 02, 0, 0],
       [0, 0, 0, 02, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('zero-size array to reduction operation maximum which has no identity')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 5, 5, 4],
       [2, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [2, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [0, 0, 0, 0],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 1, 2, 4],
       [2, 2, 2, 4]]),
  array([ ... (more)
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [10, 0, 0, 2, 40],
       [1, 10, 2, 4],
       [20, 20, 20, 40],
       [0, 0, 1, 1]]),
  array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [2, 2, 2, 4],
       [0, 0, 1, 1]]),
  array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 880, 'const': 324, 'code+const': 1204}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 10)], [('While', 7)]]
import numpy as np
def get_score(board):
    new=board.T
    count=np.min(new,axis=0)
    check1=count!=0
    res=count[check1]
    ans=len(res)
    return int(ans*40)
def get_time_cap(board, time_caps):
    b=board
    t=time_caps
    c=int(len(b)/len(t))
    B=b.reshape((int(len(t)),b.shape[1]*c))
    d=np.max(B,axis=1)
    C=d!=0
    ans=list(C)
    if True in ans:
      serch=ans.index(True)
    if True not in ans:
      serch=-1
    return t[serch]
def rotate_right(shape):
    new=shape[::-1]
    return new.T
def rotate_left(shape):
    new=shape.T
    return new[::-1]
def animate_drop(board, shape, c):
    i=0
    newb=np.array(board)
    news=np.array(shape)
    check1=np.min(newb,axis=0)
    if check1[c]!=0:
      return []
    else:
      ans=[]
      while i>=0:
        newb2=np.array(newb)
        s1=news.shape
        c1=newb2[i:i+s1[0]:1,c:c+s1[1]:1]
        if c1.shape == news.shape:
          if np.sum(abs(c1-news))==np.sum(c1+news):
            newb2[i:i+s1[0]:1,c:c+s1[1]:1]=c1+news
        ans.append(newb2)
        i+=1
        if np.max(newb2[i:i+s1[0]:1,c:c+s1[1]:1])!=0:
          break
      return ans
def animate_clear(board):
    newb=np.array(board)
    s1=newb.shape
    i=0
    count=0
    ans=[]
    while i>=0:
      c=newb[i,::]
      ln=c.shape
      if 0 not in c:
        w=newb[i,::]
        newb[i,::]=[0]*ln[0]
        ans.append(newb)
        count+=1
        if i>0 and i<s1[0]:
            newb2=np.array(newb)
            newb2[i,::]=newb2[i-1,::]
            newb2[i-1,::]=[0]*ln[0]
            ans.append(newb2)
      if i==s1[0]-1:
        break
      i+=1
    if count==0:
      return []
    else:
      return ans

xxx019xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1068, 'const': 404, 'code+const': 1472}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 10)], [('While', 14)]]
import numpy as np
def get_score(board):
    n = len(board[0])
    a = np.sum(board > 0,axis=1)
    count = np.sum(a==n)
    return count * 40
def get_time_cap(board, time_caps):
    n = board.shape[0] / len(time_caps)
    aa = np.sum(board > 0, axis = 1)
    a = aa > 0
    if True not in a:
        return time_caps[-1]
    b = np.arange(0,len(aa))
    ans1 = b[a]
    ans2 = ans1[0]
    ans3 = ans2 // n
    return time_caps[int(ans3)]
def rotate_right(shape):
    x = shape.T
    return x[::,::-1]
def rotate_left(shape):
    x = shape.T
    return x[::-1]
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    tf_board = new_board == 0
    shape_tf = shape == 0
    width = shape_tf.shape[1]
    height = shape_tf.shape[0]
    ans_list = []
    n = 0
    for i in range (len(tf_board)-height+1) :
        if n == 0:
            result = tf_board[i:i+height , c:c+width] | shape_tf
            if False in result:
                n = 1
                return []
            else:
                n = 1
                new_board[i:i+height , c:c+width] = new_board[i:i+height , c:c+width] + new_shape
                ans_list.append(new_board)
                new_board = np.array(board)
        else:
            result = tf_board[i:i+height , c:c+width] | shape_tf
            if False in result:
                return ans_list
            else:
                new_board[i:i+height , c:c+width] = new_board[i:i+height , c:c+width] + new_shape
                ans_list.append(new_board)
                new_board = np.array(board)
    return ans_list
def animate_clear(board):
    ans = []
    new_board = np.array(board)
    tf_board = new_board == 0
    n = len(new_board[0])
    a = np.sum(new_board != 0,axis=1) 
    b = a == n
    if True not in b:
        return []
    new_board[b] = 0
    mark = False
    forans = np.array(new_board)
    ans.append(forans)
    while mark == False:
        index = np.arange(0,new_board.shape[0])
        check1 = np.sum(new_board == 0, axis = 1)
        check_block1 = check1 != n
        check_em1 = check1 == n
        check_block = index[check_block1]
        check_em = index[check_em1]
        x = check_block < check_em[-1]
        y = check_em > check_block[0]
        check_block = check_block[x]
        check_em = check_em[y]
        if len(check_em) != 0:
            if len(check_block) > 1:
                add = np.array(new_board[check_block[0]:check_block[-1]+1])
            else:
                add = np.array(new_board[check_block[0]])
            new_board[check_block[0]:check_block[-1]+1] = 0
            new_board[check_block[0]+1:check_block[-1]+2] = new_board[check_block[0]+1:check_block[-1]+2] + add
            forans2 = np.array(new_board)
            ans.append(forans2)
        else:
            mark = True
    return ans

xxx042xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1094, 'const': 370, 'code+const': 1464}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 11)]]
import numpy as np
def get_score(board):
    b = board!=0
    size = board.shape[1]
    t = (np.sum(b,axis=1))/size
    t2 = t==1
    return np.sum(t2)*40
def get_time_cap(board, time_caps):
    if np.sum(board)==0:
        return time_caps[-1]
    n=len(board)//len(time_caps)
    total=board>0
    t = np.sum(total,axis=1)
    t=t>0
    pos=np.argmax(t)
    tpos=pos//n
    return time_caps[tpos]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    total=[]
    for i in range(0,len(board)-shape.shape[0]+1):
        nb = np.array(board)
        ns = np.array(shape)
        a=nb[i:len(shape)+i,c:len(shape[0])+c]
        a1=a==0
        ns1=ns>0
        bo1=np.sum(a1,axis=0)>=np.sum(ns1,axis=0)
        bo2=np.sum(a1,axis=1)>=np.sum(ns1,axis=1)
        if  len(bo1)==sum(bo1) and len(bo2)==sum(bo2) and np.sum((a==0)&(ns>0))==np.sum(ns>0):
            cp=ns+a
            nb[i:len(shape)+i,c:len(shape[0])+c]=cp
            total.append(nb)
        elif i==0:
            return []
        elif len(total)>0:
            break
    return total
def animate_clear(board):
    nb = np.array(board)
    tnb = np.array(board)
    tnb=tnb!=0
    tnb=np.sum(tnb,axis=1)
    if board.shape[1] not in tnb:
      return []
    total=[]
    n=0
    while True:
        if len(total)==0 and sum(nb[n]!=0)==nb.shape[1]:
            nb[n]=np.zeros((1,nb.shape[1]),int)
        if (n+1)>nb.shape[0] :
            arg_floor=nb.shape[0]-(np.argmin(np.sum(nb[::-1].T,axis=0)))-1
            b1=nb[0:arg_floor,:]
            b2=nb[arg_floor+1:,:]
            nh=b1.shape[0]+b2.shape[0]
            nbzero = np.zeros_like (nb, int)
            nbzero[nb.shape[0]-nh:nh-b2.shape[0]+1,:]=b1
            nbzero[nh-b2.shape[0]+1:,:]=b2
            if np.sum(nbzero == total[-1]) == (nb.shape[0]*nb.shape[1]):
                break
            total.append(nbzero)
            nb = np.array(nbzero)
        if (n+1)%nb.shape[0]==0 and len(total)==0 :
            total.append(nb)
        n+=1
    return total

xxx041xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 812, 'const': 338, 'code+const': 1150}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 3)], [('While', 13)]]
import numpy as np
def get_score(board):
  a = np.min(board,axis = 1)
  b = np.sum(a != 0)
  return b*40
def get_time_cap(board, time_caps):
  a = np.max(board,axis = 1)
  b = np.sum(a == 0)
  if int(b) == board.shape[0]:
      return time_caps[-1]
  n = b + 1
  n = int(n)
  n = n / (board.shape[0]/len(time_caps) )
  if n % 1 == 0:
      n -= 1
  else:
      n = n//1
  return time_caps[int(n)]
def rotate_right(shape):
  a = shape.T[: , ::-1]
  return a
def rotate_left(shape):
  a = shape.T[::-1 , :]
  return a
def animate_drop(board, shape, c):
  a = []
  for i in range(board.shape[0]-shape.shape[0]):
      new_board = np.array(board)
      if np.sum(board[i:i+int(shape.shape[0]) , c:c+ int(shape.shape[1])]) == 0:
          new_board[i:i+int(shape.shape[0]) , c:c+(shape.shape[1])] += shape
          a.append(new_board)
      else: return a
  return a
def animate_clear(board):
  ans = []
  new_board = np.array(board) 
  a = np.min(board,axis = 1)
  new_board[a != 0 ,::] = 0
  if np.sum(new_board) == np.sum(board):
    return ans
  ans.append(new_board)
  n1 = np.max(new_board,axis = 1)
  n2 = np.arange(len(board))[n1 == 0]
  x = np.arange(len(board))[n1 != 0]
  n = n2[n2 > x[0]]
  while True :
          if len(n) == 0:
              return ans
          new_board = np.array(new_board)
          new_board[1:n[-1]+1,::] = new_board[0:n[-1],::]
          new_board[0] = 0
          ans.append(new_board)
          n1 = np.max(new_board,axis = 1)
          n2 = np.arange(len(board))[n1 == 0]
          x = np.arange(len(board))[n1 != 0]
          n = n2[n2 > x[0]]

xxx019xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('index 1 is out of bounds for axis 0 with size 1')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[array([[0, 2, 0, 0],
       [2, 2, 2, 0],
       [1, 1, 0, 0]])],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 636, 'const': 214, 'code+const': 850}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('For', 9)]]
import numpy as np
def get_score(board):
    a = (board == 0)
    b = np.sum(a,1)
    c = b[(b == 0)].shape[0]
    return c * 40
def get_time_cap(board, time_caps):
    a = (board != 0)
    b = np.sum(a,1)
    c = np.arange(len(b))
    if len(b) != 0:
        if np.sum(b) != 0:
            d = c[b != 0][1]
        else:
            d = len(b)
    e = (d+1) // (len(board) // len(time_caps)) -1
    return time_caps[e]
def rotate_right(shape):
    a = shape.T
    return a[:,::-1]
def rotate_left(shape):
    a = shape.T
    return a[::-1,:]
def animate_drop(board, shape, c):
    a = []
    b = np.sum(board != 0) + np.sum(shape != 0)
    for i in range(len(board)-shape.shape[0]+1):
        new_board = np.array(board)
        new_board[i:shape.shape[0]+i,c:shape.shape[1]+c] += shape
        if np.sum(new_board != 0) != b: break
        a.append(np.array(new_board))
    return a
def animate_clear(board):
    A = []
    z = np.zeros((1,board.shape[1]),int)
    new_board = np.array(board)
    a = (board == 0)
    b = np.sum(a,1)
    c = np.arange(len(b))
    for i in range(b[(b == 0)].shape[0]):
        new_board[c[b==0][i]:c[b==0][i]+1,:] = z
    A.append(np.array(new_board))
    return A

xxx020xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, None2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 None[],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 442, 'const': 292, 'code+const': 734}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 7)], []]
import numpy as np
def get_score(board):
  Minn=np.min(board,axis=1)
  num=np.sum(Minn!=0)
  return num*40
def get_time_cap(board, time_caps):
  M = np.max(board,axis=1) 
  x=len(board)//len(time_caps) 
  A = (M!=0 ) 
  A=list(A) 
  if True in A: 
    num=A.index(True) 
    num+=x
    num=(num//x)-1 
    return time_caps[num] 
  else : return time_caps[-1]
def rotate_right(shape):
  x=shape.T 
  return x[: , ::-1]
def rotate_left(shape):
  x=shape.T 
  return x[::-1]
def animate_drop(board, shape, c):
  end=[]
  i=0
  row=shape.shape[0]
  colum=shape.shape[1]
  while True:
    new_board=np.array(board)
    a= new_board[i:i+row:,c:c+colum:] == 0 
    b= shape==0
    d=a+b
    if (False in d ) or (i+row==board.shape[0]) :
      break
    new_board[i:i+row:,c:c+colum:]+=shape
    end.append(new_board)
    i+=1
    return end
def animate_clear(board):
    pass

xxx202xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1288, 'const': 268, 'code+const': 1556}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 13)], [('For', 17)]]
import numpy as np
import numpy as np
def get_score(board):
    x = np.min(board,1)
    a = x[::][x[::] != 0]
    ans = len(a)*40
    return ans
def get_time_cap(board, time_caps):
    x = np.max(board,1)
    position = np.arange(0,x.shape[0])
    row = position[:][x[:]!= 0]
    if len(row)==0:
        return time_caps[-1]
    y = row[0] 
    devide = int(board.shape[0]/len(time_caps))
    ans = y//devide
    xx = time_caps[ans]
    return xx
def rotate_right(shape):
    x = shape[::-1,::]
    a = x.T
    return a
def rotate_left(shape):
    x = shape[::,::-1]
    a = x.T
    return a
def animate_drop(board, shape, c):
    w = shape.shape[1]
    h = shape.shape[0]
    wb = board.shape[1]
    hb = board.shape[0]
    ntime = 1
    ntime2 = 1
    nshape = shape.shape[0]
    ans = []
    new_shape = shape[::-1,::]
    swit = 0
    for i in range(hb):
        new_board = np.array(board)
        if swit == 0 and (np.sum(new_board[0:ntime:1,c:c+w]*shape[nshape-1::,:]) != 0):
            return []
        if swit == 1 and (np.sum(new_board[ntime2:ntime2+h,c:c+w]*shape[::1,:])!= 0):
            return ans
        if i < h: 
            new_board[0:ntime:1,c:c+w] += shape[nshape-1::,:] 
            if shape[nshape-1::,:].shape[0] == h:
                ans.append(new_board)
                swit = 1 
            nshape -= 1
            ntime += 1
        elif i >= h:
            new_board[ntime2:ntime2+h,c:c+w] += shape[::1,:]
            ntime2 += 1
            ans.append(new_board)
    return ans
def animate_clear(board):
    wb = board.shape[1]
    hb = board.shape[0]
    new_board = np.array(board)
    ans = []
    n = 2
    posi = np.arange(0,hb)
    xx = np.zeros((hb,wb), int)
    if len(posi[:][np.min(new_board,1)!= 0])==0:
        return []
    new_board[:][np.min(new_board,1)!= 0] = xx[0:1,:]
    new_board2 = np.array(new_board)
    ans.append(new_board2)
    for i in range(hb):
        new_board2 = np.array(new_board)
        x = np.max(posi[:][np.sum(new_board2,1)==0])
        if len(posi[:][np.sum(new_board2,1)==0])>0 and i<x:
            x = np.max(posi[:][np.sum(new_board2,1)==0])
            new_board2[i+1:x+1:,:] = new_board2[i:x:,:]
            new_board2[0:i+1,:] = xx[0:i+1,:]
            if False not in (new_board==new_board2):
                return ans
            new_board = np.array(new_board2)
            ans.append(new_board2)
        else:
            if len(ans) >0 :
                return ans
            else:
                return []
    return ans

xxx037xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 25, 25, 4]])],
  [array([[0, 0, 0, 0],
    ... (more)
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 862, 'const': 338, 'code+const': 1200}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 9)], [('For', 13)]]
import numpy as np
def get_score(board):
    truefalse_b = board != 0
    t = np.sum(truefalse_b, axis = 1)
    new_board = board[t == board.shape[1]]
    return int(len(new_board) * 40)
def get_time_cap(board, time_caps):
    truefalse_b = board != 0
    t = np.sum(truefalse_b, axis = 1)
    sum_t = np.sum(t)
    if sum_t == 0:
        return time_caps[-1]
    else:
        use = board[t != 0][0]
        sum_use = np.sum(use)
        new_t = np.sum(board, axis = 1)
        pos = np.arange(board.shape[0])
        use_pos = pos[new_t == sum_use][0]
        n = len(board) // len(time_caps)
        m = use_pos // n
    return time_caps[m]
def rotate_right(shape):
    new_shape = shape[::-1].T
    array_new_shape = np.array(new_shape)
    return array_new_shape
def rotate_left(shape):
    new_shape = shape.T[::-1]
    array_new_shape = np.array(new_shape)
    return array_new_shape
def animate_drop(board, shape, c):
    List = []
    new_board = np.array(board)
    new_shape = np.array(shape)
    truefalse_b = new_board != 0
    truefalse_s = new_shape != 0
    before = np.sum(truefalse_b) + np.sum(truefalse_s)
    for i in range(board.shape[0]-shape.shape[0]+1):
        copy_board = np.array(board)
        copy_board[i:i+new_shape.shape[0], c:c+new_shape.shape[1]] += new_shape
        truefalse_copy_board = copy_board != 0
        after = np.sum(truefalse_copy_board)
        if before != after:
            break
        List.append(np.array(copy_board))
    return List
def animate_clear(board):
    min_board = np.min(board, axis = 1)
    new_board = np.array(board)
    pos_board = np.arange(board.shape[0])
    pos = pos_board[min_board != 0]
    new_board[pos] = 0
    new_pos = pos_board[np.sum(new_board, axis = 1) == 0]
    List = [np.array(new_board)]
    if np.sum(np.sum(new_board, axis = 1) == 0) == 0:
        return []
    z = np.sum(np.sum(new_board, axis = 1) != 0)
    for i in range(len(new_pos)):
        index = pos_board[np.sum(new_board, axis = 1) == 0][-1]
        if index != board.shape[0]:
            new_board[1:index+1] = new_board[0:index]
            new_board[0] = 0
            List.append(np.array(new_board))
        if np.sum(np.sum(board[-z:], axis = 1) != 0) == z:
            break
    return List

xxx044xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [10, 0, 5, 4],
       [1, 0, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_20.0
[[array([[0, 2, 0, 0],
       [2, 2, 2, 0],
       [1, 1, 0, 0]])],
 [array([[01, 02, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [01, 02, 0, 0],
       [10, 20, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [10, 0, 0, 2, 40],
       [01, 0, 02, 04],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 754, 'const': 338, 'code+const': 1092}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('For', 13)]]
import numpy as np
def get_score(board):
    A=np.min(board,axis=1)
    B=A!=0
    C=np.sum(B==True)
    D=C*40
    return D
def get_time_cap(board, time_caps):
    T=np.array(time_caps)
    A=np.max(board,axis=1)
    A0=np.sum(A)
    if A0!=0:
        A1,A2=board.shape
        A3=len(time_caps)
        B=A.reshape(A3,A1//A3)
        C=np.sum(B,axis=1)
        D=C>0
        E=T[D]
        F=E[0]
        return F
    else:
        return time_caps[-1]
def rotate_right(shape):
    A=shape[::-1,::]
    B=A.T
    return B
def rotate_left(shape):
    A=shape[::,::-1]
    B=A.T
    return B
def animate_drop(board, shape, c):
    list_board=[]
    S1,S2=shape.shape
    for i in range(len(board)):
        P=board[i:i+S1:,c:c+S2:]
        new_board = np.array(board)
        P1,P2=P.shape
        if P1==S1 and P2==S2:
            A=P>0
            B=shape>0
            C=A&B
            if np.max(C)==0:
                D=P+shape
                new_board[i:i+S1:,c:c+S2:]=D
                list_board.append(new_board)
            else: break
    return list_board
def animate_clear(board):
    list_board=[]
    b1,b2=board.shape
    b3=np.zeros((1,b2),int)
    new_board = np.array(board)
    A=np.min(board,axis=1)
    A0=A>0
    new_board[A0,:]=b3
    new_board2 = np.array(new_board)
    list_board.append(new_board)
    new_board=new_board[::-1,::]
    for i in range(b1):
        B=new_board[i]
        B1=np.sum(B)
        if B1==0:
            new_board[i:-1:,:]=new_board[i+1:,:]
            new_board[-1]=b3
            list_board.append(new_board[::-1,::])
    return list_board

xxx209xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('index -1 is out of bounds for axis 0 with size 0')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 858, 'const': 324, 'code+const': 1182}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], [('While', 13)]]
import numpy as np
def get_score(board):
    a=np.min(board,axis=1)
    b=a[a!=0]
    c=b.shape[0]*40
    return c
def get_time_cap(board, time_caps):
    add=np.sum(board,axis=1)
    position=np.arange(add.shape[0])
    correct=position[add==0]
    small=correct[-1]
    if (small+1)==board.shape[0]:
      return time_caps[-1]
    gap=time_caps[(small+1)//(board.shape[0]//len(time_caps))]
    return gap
def rotate_right(shape):
    cat=shape.T[:,::-1]
    return cat
def rotate_left(shape):
    dog=shape.T[::-1,:]
    return dog
def animate_drop(board, shape, c):
    van=board.shape[0]
    run=shape.shape[0]
    four=board.shape[1]
    eat=shape.shape[1]
    bell=[]
    for i in range(van-run+1):
      new_board = np.array(board)
      pboard=np.array(board)
      new_board[i:i+run,c:c+eat]+=shape
      a=pboard.reshape(van*four)
      b=new_board.reshape(van*four)
      z=a[a==0].shape[0]
      d=b[b==0].shape[0]
      f=shape.reshape(run*eat)
      g=f[f!=0].shape[0]
      if z!=d+g:
        break
      bell.append(new_board)
    return bell
def animate_clear(board):
    a=np.min(board,axis=1)
    position=np.arange(board.shape[0])
    b=position[a!=0]
    hat=[]
    if b.shape[0]==0:
      return []
    new=np.array(board)
    new[b]-=new[b]
    copy=np.array(new)
    hat.append(new)
    line=board.shape[0]-1
    while True:
      ok=np.sum(copy[line])
      if ok==0:
        new=np.zeros_like(board,int)
        if line+1!=board.shape[0]:
          new[line+1::]=copy[line+1::]
        new[1:line+1]=copy[0:line]
        if np.sum(new!=copy) == 0:
          break
        hat.append(new)
        copy=np.array(new)
        if np.sum(new[:line])==0:
          break
      else:
        line-=1
    return hat

xxx212xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 776, 'const': 336, 'code+const': 1112}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 6)], [('While', 11)]]
import numpy as np
def get_score(board):
    minPo = board.min(axis=1)
    score = len(minPo[minPo!=0])*40
    return score
def get_time_cap(board, time_caps):
    zero = board.max(axis=1)
    zero = len(zero[zero==0])
    if not all(board[-1]==0):
        zero += 1
    x = len(board)//len(time_caps)
    y = (zero/x)-1
    if y%1!=0:
        y+=1
    return time_caps[int(y)]
def rotate_right(shape):
    x = shape[::-1].T
    return x
def rotate_left(shape):
    x = shape.T[::-1]
    return x
def animate_drop(board, shape, c):
    i=0
    ans = []
    x = ((board[i:i+shape.shape[0],c:c+shape.shape[1]] == 0)|(shape == 0))
    while i+shape.shape[0] <= board.shape[0] and len(x[:][x==False])==0:
        new_board = np.array(board)
        new_shape = np.array(shape)
        new_board[i:i+new_shape.shape[0],c:c+new_shape.shape[1]] += new_shape
        ans.append(new_board)
        i+=1
        if i+shape.shape[0] <= board.shape[0]:
            x = ((board[i:i+shape.shape[0],c:c+shape.shape[1]] == 0)|(shape == 0))
    return ans
def animate_clear(board):
    new_board = np.array(board)
    ans = []
    clearPo = new_board.min(axis=1)!=0
    if any(clearPo):
        new_board[clearPo] = np.zeros((new_board.shape[1])) 
        n = np.array(new_board)
        ans.append(n)
    i = board.shape[0]-1
    while i>1:
        if all(new_board[i] == np.zeros((new_board.shape[1]))) and new_board[:i].sum()!=0:
                new_board[1:i+1] = new_board[:i]
                new_board[0] = np.zeros((new_board.shape[1]))
                n = np.array(new_board)
                ans.append(n)
        else:
            i -= 1
    return ans

xxx019xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 24],
       [0, 0, 0, 0],
       [0, 0, 1, 1]])],
 [ array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 898, 'const': 370, 'code+const': 1268}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 7)], [('While', 8)]]
import numpy as np
def get_score(board):
    b = np.min(board,axis=1)
    c=b[b>0]
    return len(c)*40
def get_time_cap(board, time_caps):
    b=board.reshape(len(time_caps),int(len(board)/len(time_caps))*len(board[0]))
    b=np.sum(b,axis=1)
    c=b[b>0]
    d=len(b)-len(c)
    if len(c)==0:
        return time_caps[-1]
    return time_caps[d]
def rotate_right(shape):
    return shape[-1:-len(shape)-1000000:-1].T
def rotate_left(shape):
    return shape.T[-1:-len(shape)-3000000:-1]
def animate_drop(board, shape, c):
    new_board = np.array(board)
    p=[]
    a1=0
    a2=0
    m1=0
    while a1<=len(board)-len(shape[0])+1 and a2<=len(shape):
        a3=a2+a1
        c1=np.array(board)
        o=np.zeros_like(new_board)
        a=np.array(new_board[a1]==0)
        b=new_board[a3][c:c+len(shape[a2])]
        b=b[b==0]
        h=np.arange(len(a))
        if a3==len(board):
            return p
        if new_board[a3][c] !=0  :
            return p
        if len(b) != len(shape[a2]):
            return p
        if new_board[a3][c] ==0:
            new_board[a3][c:c+len(shape[a2]):]=shape[a2]
        a2+=1    
        m1+=1
        if a2==len(shape):
            a1+=1
            a2=0
            p.append(new_board)
            new_board=c1
        else:
            new_board= new_board
    return p
def animate_clear(board):
    new_board = np.array(board)
    b = np.max(new_board == 0, axis=1)
    g = np.zeros_like(board)
    g[b] = new_board[b]
    o1 = []
    v = 0
    while v < len(g):
        o = np.zeros_like(board)
        f1 = g[::-1]
        m = np.argmax(np.sum(f1, axis=1) == 0)
        o[1 : len(g) - m, :] = g[0:len(g) - m - 1, :]
        o[len(g) - m:, :] = g[len(g) - m :, :]
        o1.append(o)
        o = o1
        g = o
        v += 1
    return o1

xxx205xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[456, 456, 456, 456, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (3,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (3,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (2,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 784, 'const': 398, 'code+const': 1182}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 10)], [('While', 18)]]
import numpy as np
def get_score(board):
    compare = board==0
    find = np.sum(compare,axis = 1)
    ans = np.sum(find==0)
    return ans*40
def get_time_cap(board, time_caps):
    r = board.shape[0]
    gr = r/len(time_caps)
    compare = board==0
    find = np.sum(compare,axis = 1)
    first = np.arange(len(find))
    want = first[find != 5]
    if len(want) == 0:
      return time_caps[-1]
    return time_caps[want[0]//int(gr)]
def rotate_right(shape):
    ans = shape.T
    return ans[:,::-1]
def rotate_left(shape):
    ans = shape.T
    return ans[::-1,:]
def animate_drop(board, shape, c):
    a = shape.shape[1]
    b = board[:,c:c+a]
    compare = b==0
    find = np.sum(compare,axis = 1)
    ans = find==a
    realAns = []
    for i in range(len(ans)):
        if ans[i] == True:
            new_board = np.array(board)
            new_board[i,c:c+a] = shape
            realAns.append(np.array(new_board))
        else:
            break
    return realAns
def animate_clear(board):
    compare = board==0
    find = np.sum(compare,axis = 1)
    ans = find==0
    new_board = np.array(board)
    sum_ans = np.sum(ans)
    new_board[ans] = np.zeros(board.shape[1])*sum_ans
    realAns = []
    realAns.append(np.array(new_board))
    compare = new_board==0
    find = np.sum(compare,axis = 1)
    ans = find==board.shape[1]
    cnt = board.shape[0] - np.sum(ans)
    i = board.shape[0]-1
    while i!=-1:
        if ans[i]:
            new_board[1:i+1] = new_board[:i]
            new_board[0] = np.zeros(new_board.shape[1])
            realAns.append(np.array(new_board))
            compare = new_board==0
            find = np.sum(compare,axis = 1)
            ans = find==board.shape[1]
        else:
            i -= 1
        if i==board.shape[0]-cnt-1:
            break
    if len(realAns) == 1:
        return []
    return realAns

xxx035xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('operands could not be broadcast together with shapes (4,) (2,3) ')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (6,) (3,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('operands could not be broadcast together with shapes (4,) (3,3) ')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 440, 'const': 252, 'code+const': 692}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [('transpose', 2)], [('transpose', 2)], [], []]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], []]
import numpy as np
def get_score(board):
    b = board != 0
    e = b.sum(axis=1)==len(b[0])
    return e.sum()*40
def get_time_cap(board, time_caps):
    b = board != 0
    e = b.sum(axis=1)!=0
    j = int(len(e)/len(time_caps))
    e = e.reshape((len(time_caps),j))
    e2 = e.sum(axis=1) > 0
    e3 = e.sum() > 0
    if(e3 == 0):
        return time_caps[-1]
    c = np.array(time_caps)
    return c[e2][0]
def rotate_right(shape):
    return shape.transpose()[:,::-1]
def rotate_left(shape):
    return shape.transpose()[::-1]
def animate_drop(board, shape, c):
    re = []
    ns = np.zeros((len(shape),(len(shape[0])+c)),int)
    if c!=0:ns[:,c:] = shape
    else: ns = shape
    for i in range(len(board)):
        nb = np.array(board)
        if board[i][c] != 0:
            return re
        else:
            nb[i] = nb[i] + ns
            re.append(nb)
    return re
def animate_clear(board):
    pass

xxx214xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[56, 56, 56, 56, 45, 456, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 558, 'const': 268, 'code+const': 826}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 6)], []]
import numpy as np
def get_score(board):
    board = board.T
    low = board.min(axis=0)
    return low[low>0].shape[0]*40
def get_time_cap(board, time_caps):
  m = np.max(board, axis=1)
  m[m>0] = 1
  u = (np.argmax(m)+1)/(board.shape[0]/len(time_caps))
  if np.sum(m) == 0: return time_caps[-1]
  if int(u)==0:
    if u>0.5: return time_caps[1]
    else: return time_caps[0]
  if u/int(u) != 1: return time_caps[int(u)]
  else: return time_caps[int(u)-1]
def rotate_right(shape):
     return shape[::-1,:].T
def rotate_left(shape):
     return shape[:,::-1].T
def animate_drop(board, shape, c):
    process = []; i=0
    col = shape.shape[1]; row = shape.shape[0]
    area = board[0:0+row,c:c+col]
    while area.shape[0]>row or np.sum(area[shape>0]) == 0:
      area = board[i:i+row,c:c+col]
      if area.shape[0]>=row:
        if np.sum(area[shape>0]) == 0:
          newboard = np.array(board)
          newboard[i:i+row,c:c+col]+=shape
          process.append(newboard); i+=1
      else: break
    return process
def animate_clear(board):
    pass

xxx214xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0IndexError('index 2 is out of bounds for axis 0 with size 2')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 954, 'const': 388, 'code+const': 1342}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 10)], [('While', 11)]]
import numpy as np
def get_score(board):
    score = np.sum(np.array(np.sum(board,axis=1)*np.min(board,axis=1)!=0)*40)
    return score
def get_time_cap(board, time_caps):
    isz = np.array(np.sum(board,axis=1)!=0)
    if(np.sum(board)==0): return time_caps[-1]
    return time_caps[np.argmax(isz)//(board.shape[0]//len(time_caps))]
def rotate_right(shape):
    shape = shape.T
    shape = shape[:,::-1]
    return shape
def rotate_left(shape):
    shape = shape.T
    shape = shape[::-1,:]
    return shape
def animate_drop(board, shape, c):
    cb = []
    ss=shape.shape
    cr=0
    if ((np.dot(board[cr+ss[0],c:c+ss[1]],shape[ss[0]-1,]) != 0 
                            and np.sum(np.argmax(board[cr:cr+ss[0],c:c+ss[1]],axis=0)-np.argmax(shape,axis=0)<0)!=ss[1])): return cb
    nb = np.array(board)
    while(cr+ss[0] < board.shape[0] and (np.sum(board[cr:cr+ss[0],c:c+ss[1]])==0)):
        nb[cr:cr+ss[0],c:c+ss[1]]=shape
        cb.append(nb)
        nb = np.array(board)
        cr+=1
    if(np.dot(board[cr+ss[0]-1,c:c+ss[1]],shape[ss[0]-1,]) == 0 ):
        nb[cr:cr+ss[0],c:c+ss[1]]+=shape
        cb.append(nb)
    return cb
def animate_clear(board):
    ans=[]
    check = np.array(np.sum(board,axis=1)*np.min(board,axis=1)==0)
    nc = np.array([check]).T
    nb= nc*board
    if(np.sum(nb)==np.sum(board)):return []
    ans.append(np.array(nb))
    cr=nb.shape[0]-1
    while(cr>=0):
        if(np.sum(nb[0:cr,:])==0):
            break
        if(np.sum(nb[cr,:])==0):
            nb[1:cr+1]=nb[0:cr]
            nb[0,]=0
            ans.append(nb)
            nb=np.array(nb)
        else:
            cr-=1
    return ans

xxx213xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 816, 'const': 338, 'code+const': 1154}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('For', 17)]]
import numpy as np
def get_score(board):
    sumrow = np.sum((board>0),axis=1)
    score = len(sumrow[sumrow==board.shape[1]])*40
    return score
def get_time_cap(board, time_caps):
    time = 0
    sumboard = np.sum((board>0),axis=1)
    n = board.shape[0]/len(time_caps)
    pos = np.arange(sumboard.shape[0])
    sub = (sumboard!=0)
    if np.sum(sub)==0:
        time = time_caps[-1]
    else:
        row = pos[sumboard>0]
        time = time_caps[int(row[0]//n)]
    return time
def rotate_right(shape):
    shape = shape.T[::,::-1]
    return shape
def rotate_left(shape):
    shape = shape.T[::-1,::]
    return shape
def animate_drop(board, shape, c):
    ani = []
    num = np.sum(board!=0) + np.sum(shape!=0)
    for i in range(len(board)-shape.shape[0]+1):
        nboard = np.array(board)
        nshape = np.array(shape)
        nboard[i:i+nshape.shape[0]:1,c:c+nshape.shape[1]:1] += nshape
        if np.sum(nboard!=0)!=num:
            break
        ani.append(np.array(nboard))
    return ani
def animate_clear(board):
    ani = []
    nboard = np.array(board)
    sumrow = np.sum(nboard!=0,axis=1)
    row = np.arange(sumrow.shape[0])
    pos = row[(sumrow==0)|(sumrow==nboard.shape[1])]
    if pos.shape[0]==0:
        return ani
    nboard[pos,::] = np.array([0]*nboard.shape[1])
    ani.append(nboard)
    pos = pos[::-1]
    n = 0
    for i in range(pos.shape[0]):
        nboard = np.array(nboard)
        if np.sum(nboard[0:pos[i]+n:1,::])==0:
            break
        nboard[1:pos[i]+n+1:1,::] = nboard[0:pos[i]+n:1,::]
        nboard[0] = [0]*(nboard.shape[1])
        n = n+1
        ani.append(nboard)
    return ani

xxx217xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 678, 'const': 338, 'code+const': 1016}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 7)], [('For', 19)]]
import numpy as np
def get_score(board):
    is_score = np.min(board, axis=1)
    return (is_score > 0).sum() * 40
def get_time_cap(board, time_caps):
    cap_count = len(time_caps)
    max_val = np.max(board, axis=1)
    if max_val.sum() == 0:
      return time_caps[-1]
    else:
      pos = np.arange(max_val.shape[0])
      pos = pos[max_val > 0]
      return time_caps[int(pos[0] / int(board.shape[0] / cap_count))]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    result = []
    shape_h, shape_w = shape.shape
    board_h = board.shape[0]
    row, col = 0, c
    while row + shape_h <= board_h and (board[row:(row + shape_h), col:(col + shape_w)] * shape).sum() == 0:
        new_board = np.array(board)
        new_board[row:(row + shape_h), col:(col + shape_w)] += shape
        row += 1
        result.append(new_board)
    return result
def animate_clear(board):
    fill_row = np.min(board, axis=1)
    result = []
    if fill_row.sum() <= 0:
        return result
    else:
        new_board = np.array(board)
        new_board[fill_row > 0] = 0 
        result.append(np.array(new_board)) 
        max_val = np.max(new_board, axis=1) 
        non_zero_row = np.arange(max_val.shape[0]) 
        non_zero_row = non_zero_row[max_val > 0][0] 
        zero_row = np.arange(max_val.shape[0]) 
        zero_row = zero_row[max_val <= 0]  
        zero_row = zero_row[zero_row >= non_zero_row] 
        zero_row = zero_row[::-1] 
        correction = 0 
        for i in zero_row: 
            i += correction
            new_board[1:i + 1] = new_board[0:i] 
            new_board[0] = np.zeros_like(new_board[0]) 
            result.append(np.array(new_board))
            correction += 1
        return result

xxx043xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 806, 'const': 352, 'code+const': 1158}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 9)]]
import numpy as np
def get_score(board):
    mb = np.min(board,axis=1)!=0
    count = len(mb[mb==True])
    score = count * 40
    return score
def get_time_cap(board, time_caps):
    if np.sum(board)==0:
        time = time_caps[-1]
    else:
        raw_index = np.argmax(np.max(board,axis=1)!=0)
        k = len(board)//len(time_caps)
        index = raw_index//k
        time = time_caps[index]
    return time
def rotate_right(shape):
    return shape[::-1,:].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    ad = []
    for i in range(1-len(shape),len(board)-len(shape)+1):
        mb = np.array(board)
        s = np.array(shape)
        row,col = s.shape
        if i>=0:
            slice_mb = mb[i:i+row,c:c+col]
            slice_mb_sum = np.sum(slice_mb)
            slice_mb[s!=0] = s[s!=0]
            s_sum = np.sum(s)
            if slice_mb_sum + s_sum == np.sum(slice_mb):
                ad.append(mb)
            else:
                break
            continue
        slice_s = s[-i:,:]
        slice_s_sum = np.sum(slice_s)
        slice_mb = mb[:row+i,c:c+col]
        slice_mb_sum = np.sum(slice_mb)
        slice_mb[slice_s!=0] = slice_s[slice_s!=0]
        if slice_mb_sum + slice_s_sum != np.sum(slice_mb):
            break
    return ad
def animate_clear(board):
    ac = []
    mb = np.array(board)
    r = np.min(mb,axis=1)!=0
    mb[r] = 0
    if np.sum(r)!=0:
        ac.append(mb)
    while 1:
        mb = np.array(mb)
        b = np.array(mb)
        m = np.max(mb,axis=1)
        if np.sum(m==0)==0:
            break 
        i = len(mb)-np.argmin(m[::-1])-1
        mb[1:i+1,:] = mb[0:i,:]
        mb[0,:] = 0
        if np.min(mb==b)!=0:
            break
        ac.append(mb)
    return ac

xxx041xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 748, 'const': 338, 'code+const': 1086}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 4)], [('For', 10)]]
import numpy as np
def get_score(board):
  return 40*np.sum(np.sum(board == 0, axis = 1) == 0)
def get_time_cap(board, time_caps):
  if np.sum(board) == 0:return time_caps[-1]
  return time_caps[np.arange(board.shape[0])[np.sum(board, axis = 1) != 0][0]//(board.shape[0]//len(time_caps))]
def rotate_right(shape):
  return shape[::-1,::].T
def rotate_left(shape):
  return shape[::,::-1].T
def animate_drop(board, shape, c):
  king = [] ; i = 0 ; t,u = shape.shape
  new_board = np.array(board)
  while i <= board.shape[0]-t and np.sum(board[np.arange(t) + i, c:c+u]*shape) == 0 and np.sum(board[:t-1,c:c+u]*shape[1-t:]) == 0:
    new_board[np.arange(t) + i, c:c+u] += shape
    king.append(new_board)
    new_board = np.array(board)
    i += 1
  return king
def animate_clear(board):
  new_board = np.array(board)
  ku = []
  if np.sum(np.sum(board == 0, axis = 1) == 0) == 0:return []
  pos = np.arange(board.shape[0])
  pos = pos[np.min(board, axis = 1) != 0]
  new_board[pos,:] *= 0
  ku.append(new_board)
  me = np.array(new_board)
  for i in range(1+board.shape[0]):
    pos = np.arange(board.shape[0])
    j = pos[np.max(me, axis = 1) == 0][-1]
    k = np.arange(j)
    x = k+1
    if np.sum(me[k]) != 0:
      me[x] = me[k]
      me[0] = 0
      fern = np.array(me)
      ku.append(fern)
    else:return ku

xxx042xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1026, 'const': 338, 'code+const': 1364}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 7)], []]
import numpy as np
def get_score(board):
  check = np.array(board != 0)
  x = np.sum(np.sum(check, axis = 1) == board.shape[1])
  return x*40
def get_time_cap(board, time_caps):
  x = board.shape[0] // len(time_caps)
  if np.sum(board) != 0:
    check = np.sum(board, axis = 1)
    god = np.arange(len(board))
    check_range = god[np.array(check != 0)]
    index = check_range[0]
    check_board = np.arange(board.shape[0]).reshape(len(time_caps),x)
    k = np.array(check_board == index)
    plus = np.sum(k, axis = 1)
    goddess = np.arange(len(time_caps))
    result = goddess[plus == 1]
    return time_caps[int(result)]
  else:
    return time_caps[-1]
def rotate_right(shape):
  x = shape[::-1,::]
  rotate_right = x.T
  return rotate_right
def rotate_left(shape):
  x = shape[::,::-1]
  rotate_left = x.T
  return rotate_left
def animate_drop(board, shape, c):
  new_board = np.array(board)
  new_shape = np.array(shape)
  animate_drop = []
  x = []
  for i in range(len(new_board)):
    new_board = np.array(board)
    if np.sum(np.array(new_board[i:i+shape.shape[0]:,c:shape.shape[1]+c:] != 0)) == 0:
      if np.array(new_board[i:i+shape.shape[0]:,c:shape.shape[1]+c:]).shape[0] == shape.shape[0] and np.array(new_board[i:i+shape.shape[0]:,c:shape.shape[1]+c:]).shape[1] == shape.shape[1]:
        new_board[i:i+shape.shape[0]:,c:shape.shape[1]+c:] = new_shape
        animate_drop.append(new_board)
      else:
        if i == 0:
          return []
        else:
          x = np.array(new_board[i:i+shape.shape[0]:,c:shape.shape[1]+c:][0] == 0)
          y = np.array(shape[-1,::] == 0)
          z = x & y
          if np.sum(z) == shape.shape[1]:
            new_board[i:i+shape.shape[0]:,c:shape.shape[1]+c:] = new_shape
            new_board[i+1] = new_board[i+1] + board[i+1]
            animate_drop.append(new_board)
          else:
            break
  return animate_drop
def animate_clear(board):
  new_board = np.array(board)
  animate_clear = []
  x = np.array(new_board == 0)
  y = np.sum(x, axis = 1)
  index = np.arange(new_board.shape[0])
  check_zero = np.array(y == 0)
  if np.sum(check_zero == 0):
    return animate_clear
  else:
    total = index[check_zero]
    new_board[total] = 0
    new_board1 = np.array(new_board)
    return new_board1

xxx216xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [], []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1302, 'const': 400, 'code+const': 1702}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 14)], [('For', 18)]]
import numpy as np
def get_score(board):
    new_board = np.abs(np.array(board))
    x = board[new_board.min(axis=1)!=0]
    return len(x)*40
def get_time_cap(board, time_caps):
    id1 = np.arange(len(board))
    id2 = id1[board.sum(axis=1)!=0]
    if len(id2) == 0:
        return time_caps[-1]
    else:
        id3 = ((id2[0]+0.9)//(board.shape[0]//len(time_caps)))
        return time_caps[int(id3)]
def rotate_right(shape):
    x = shape.T
    y = x[:,-1::-1]
    return y
def rotate_left(shape):
    x = shape.T
    y = x[-1::-1,:]
    return y
def animate_drop(board, shape, c):
    k=0 ; l = []
    a = np.arange(shape.shape[0])
    new_shape = np.abs(np.array(shape))
    b = a[new_shape.min(axis=1)!=0]
    if (shape.shape[0]==2) & (np.sum(board[0,c:c+shape.shape[1]])!=0):
        return l
    if len(b) > 0:
        if np.sum(board[:b[0],c:c+shape.shape[1]])!=0:
            return l
    y = np.sum(board[k:k+shape.shape[0],c:c+shape.shape[1]]+shape!=0)
    z = np.sum(board[k:k+shape.shape[0],c:c+shape.shape[1]]!=0)+np.sum(shape!=0)
    while y == z:
        new_board = np.array(board)
        new_board[k:k+shape.shape[0],c:c+shape.shape[1]] = board[k:k+shape.shape[0],c:c+shape.shape[1]]+shape
        l.append(np.array(new_board))
        k += 1
        if k > board.shape[0]-shape.shape[0]:
            break
        y = np.sum(board[k:k+shape.shape[0],c:c+shape.shape[1]]+shape!=0)
        z = np.sum(board[k:k+shape.shape[0],c:c+shape.shape[1]]!=0)+np.sum(shape!=0)
    return l
def animate_clear(board):
    l = []
    id1 = np.arange(board.shape[0])
    id2 = id1[board.min(axis=1)!=0]
    if len(id2) == 0:
        return l
    else:
        new_board = np.array(board)
        new_board[id2,:] = 0
        l.append(new_board)
        id3 = id1[new_board.sum(axis=1)==0]
        id4 = id1[new_board.sum(axis=1)!=0]
        if len(id4)==0:
            return l
        id5 = id3[id3>id4[0]]
        board2 = np.array(new_board)
        for i in range(len(id3[id3>id4[0]])):
            empty = np.ndarray(board.shape,int)
            empty[0,:] = board2[id5[-1],:]
            empty[1:id5[-1]+1,:] = board2[:id5[-1],:]
            empty[id5[-1]+1:,:] = board2[id5[-1]+1:,:]
            l.append(empty)
            board2 = np.array(empty)
            id3 = id1[empty.sum(axis=1)==0]
            id4 = id1[empty.sum(axis=1)!=0]
            id5 = id3[id3>id4[0]]
        return l

xxx204xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('operands could not be broadcast together with shapes (3,3) (2,3) ')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0Time-out: 5s
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  Nonearray([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 652, 'const': 324, 'code+const': 976}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 13)], []]
import numpy as np
def get_score(board):
    t=np.sum(board!=0,axis=1)
    h=np.sum(t==len(board[0]))
    return h*40
def get_time_cap(board, time_caps):
    d=len(board)/len(time_caps)
    l=np.sum(board!=0,axis=1)
    l=l.reshape(len(time_caps),int(d))
    p=np.sum(l,axis=1)
    point=np.sum(p!=0,axis=0)
    point2=len(time_caps)-point
    L=np.array(time_caps).dot(p)
    if L==0 :
      return time_caps[-1]
    return time_caps[point2]
def rotate_right(shape):
    return (shape[::-1]).T
def rotate_left(shape):
    return (shape).T[::-1]
def animate_drop(board, shape, c):
    n=shape.shape[0]
    m=shape.shape[1]
    x=np.array(board)
    y=np.array(shape)
    i=0
    if np.sum(y*x[i:n,c:c+m]) !=0 :
      return []
    x[i:n,c:c+m]=y+x[i:n+i,c:c+m]
    l=[]
    l.append(x)
    while True :
      i+=1
      x=np.array(board)
      if np.sum(y*x[i:n+i,c:c+m]) !=0 :
        return l
      x[i:n+i,c:c+m]=y+x[i:n+i,c:c+m]
      l.append(x)
def animate_clear(board):
    x=np.array(board)
    t=np.sum(board!=0,axis=1)
    h=np.sum(t==len(board[0]))
    if h==0 :
      return []
    pass

xxx215xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 1804, 'const': 920, 'code+const': 2724}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 75)], [('For', 18)]]
import numpy as np
def get_score(board):
  newboard = np.array(board)
  znewboard = newboard == 0
  notzeros = np.sum(znewboard,axis = 1) == 0
  sumall = np.sum(notzeros)*40
  return sumall
def get_time_cap(board, time_caps):
  perrows = int(len(board) / len(time_caps))
  newrows = int(len(board) / perrows)
  colsb = board.shape[1]
  boardcap = board.reshape(newrows,colsb*perrows)
  newcap = boardcap != 0
  check = (np.sum(newcap,axis = 1) != 0)
  stepone = (np.sum(newcap,axis = 1) != 0) * (np.arange(newrows))
  if check[0] != True :
    stepone = stepone[stepone != 0]
  else :
    stepone = stepone
  if len(stepone) != 0 :
    return time_caps[stepone[0]]
  else :
    return time_caps[-1]
def rotate_right(shape):
  ans = np.array(shape[::-1,::1].T)
  return ans
def rotate_left(shape):
  ans = np.array(shape[::1,::-1].T)
  return ans
def animate_drop(board, shape, c):
  ans = []
  newboard = np.array(board)
  newshape = np.array(shape)
  rowsb = newboard.shape[0]
  colsb = newboard.shape[1]
  rowss = newshape.shape[0]
  colss = newshape.shape[1]
  checkshape = newshape != 0
  checkboard = newboard[0:0+rowss,c:c+colss] != 0
  if checkshape.shape == (3,2) :
    if checkshape[-1,-1] != 0 :
      if (checkshape[-1,-1]) == checkboard[1,-1] :
        return ans
      if (checkshape[-1,-1]) == checkboard[0,-1] :
        return ans
    if checkshape[-1,0] != 0 :
      if (checkshape[-1,0]) == checkboard[1,0] :
        return ans
      if (checkshape[-1,0]) == checkboard[0,0] :
        return ans
    if checkshape[1,0] != 0 :
      if (checkshape[1,0]) == checkboard[0,0] :
        return ans
    if checkshape[1,-1] != 0 :
      if (checkshape[1,-1]) == checkboard[0,-1] :
        return ans
  if checkshape.shape == (2,3) :
    if checkshape[-1,-1] != 0 :
      if (checkshape[-1,-1]) == checkboard[0,-1] :
        return ans
    if checkshape[-1,0] != 0 :
      if (checkshape[-1,0]) == checkboard[0,0] :
        return ans
    if checkshape[-1,1] != 0 :
      if (checkshape[-1,1]) == checkboard[0,1] :
        return ans
  if checkshape.shape == (2,2) :
    if checkshape[-1,-1] != 0 :
      if (checkshape[-1,-1]) == checkboard[0,-1] :
        return ans
    if checkshape[-1,0] != 0 :
      if (checkshape[-1,0]) == checkboard[0,0] :
        return ans
  if checkshape.shape == (4,2) :
    if checkshape[-1,-1] != 0 :
      if (checkshape[-1,-1]) == checkboard[1,-1] :
        return ans
      if (checkshape[-1,-1]) == checkboard[0,-1] :
        return ans
    if checkshape[-1,0] != 0 :
      if (checkshape[-1,0]) == checkboard[1,0] :
        return ans
      if (checkshape[-1,0]) == checkboard[0,0] :
        return ans
    if checkshape[1,0] != 0 :
      if (checkshape[1,0]) == checkboard[0,0] :
        return ans
    if checkshape[1,-1] != 0 :
      if (checkshape[1,-1]) == checkboard[0,-1] :
        return ans
    if checkshape[2,0] != 0 :
      if (checkshape[2,0]) == checkboard[0,0] :
        return ans
    if checkshape[2,-1] != 0 :
      if (checkshape[2,-1]) == checkboard[0,-1] :
        return ans
  if checkshape.shape == (2,4) :
    if checkshape[-1,-1] != 0 :
      if (checkshape[-1,-1]) == checkboard[0,-1] :
        return ans
    if checkshape[-1,0] != 0 :
      if (checkshape[-1,0]) == checkboard[0,0] :
        return ans
  for i in range(rowsb) :
    newboard = np.array(board)
    if newshape.shape > newboard[i:i+rowss,c:c+colss].shape:
      break
    newboard[i:i+rowss,c:c+colss] += newshape
    if np.sum(newboard[i:i+rowss,c:c+colss][newshape != 0] != newshape[newshape != 0]) > 0 :
      break
    ans.append(newboard)
  return ans
def animate_clear(board):
  ans = []
  newboard = np.array(board)
  rowsb = newboard.shape[0]
  colsb = newboard.shape[1]
  boardzeros = np.sum((newboard==0),axis = 1)
  if np.sum(boardzeros == 0) == 0 and np.sum(boardzeros == colsb) == 0 :
    return ans
  newboard[boardzeros == 0] = 0
  ans.append(np.array(newboard))
  startpos = (np.sum(newboard,axis = 1) != 0) * (np.arange(rowsb)+1)
  startpos = startpos[startpos!=0]
  if len(startpos) == 0 :
    return ans
  zerospos = (np.sum(newboard,axis = 1) == 0) * (np.arange(rowsb)+1)
  zerospos = zerospos[zerospos!=0][startpos[0]-1:]
  startround = len(zerospos)
  for i in range(startround) :
    newboard[1:zerospos[-1]] = newboard[:zerospos[-1]-1]
    newboard[0] = np.zeros((1,colsb))
    zerospos = (np.sum(newboard,axis = 1) == 0) * (np.arange(rowsb)+1)
    zerospos = zerospos[zerospos!=0]
    ans.append(np.array(newboard))
  return ans

xxx042xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 852, 'const': 350, 'code+const': 1202}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('While', 12)]]
import numpy as np
def get_score(board):
    x = board > 0 
    y = np.sum(x, axis = 1)
    return np.sum(y == board.shape[1])*40
def get_time_cap(board, time_caps):
    n = int(board.shape[0]/len(time_caps))
    x = board != 0 
    y = np.sum(x, axis = 1)
    z = np.arange(board.shape[0])[y!=0]
    if np.sum(board) == 0 :
        re = time_caps[-1]
    else :
        re = time_caps[z[0]//n]
    return re
def rotate_right(shape):
    x = shape.T
    return x[:,::-1]
def rotate_left(shape):
    x = shape.T
    return x[::-1]
def animate_drop(board, shape, c):
    re = []
    new_board = np.array(board)
    new_shape = np.array(shape)
    for i in range(board.shape[0]):
        if np.sum(((board[i:shape.shape[0]+i,c:shape.shape[1]+c]) != 0) & (shape != 0)) == 0 :
            new_board[i:shape.shape[0]+i,c:shape.shape[1]+c] += shape
            re.append(new_board)
            new_board = np.array(board)
        else :
            break
        if i == board.shape[0] - shape.shape[0] :
            break
    return re
def animate_clear(board):
    new_board = np.array(board)
    re = []
    x = board > 0 
    y = np.sum(x, axis = 1)
    new_board[y == board.shape[1]] = np.zeros((1,board.shape[1]),int)
    boo = False
    c = board.shape[0]-1
    while boo == False :
        if c == -1 :
            break
        if str(new_board[c]) == str(np.zeros((1,board.shape[1]),int)[0]) :
            if str(new_board[:c]) == str(np.zeros((new_board[:c].shape[0],new_board[:c].shape[1]),int)) :
                break
            if re == [] :
                re.append(new_board)
            new_board = np.array(new_board)
            new_board[1:c+1] = new_board[0:c]
            new_board[:1] = np.zeros((1,board.shape[1]),int)
            re.append(new_board)
            new_board = np.array(new_board)
            c = board.shape[0]-1
        else :
            c -= 1
    return re

xxx045xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 822, 'const': 384, 'code+const': 1206}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 9)], [('For', 12)]]
import numpy as np
def get_score(board):
    x = np.min(board,axis=1)
    return sum(x!=0)*40
def get_time_cap(board, time_caps):
    if np.max(board) == 0:
      return time_caps[-1]
    x = np.max(board,axis=1)
    y = np.arange(x.shape[0])
    z = y[x!=0]
    the_position = min(z) 
    A = (the_position/np.shape(board)[0])*len(time_caps)
    B = time_caps[int(A-(A%1))]
    return B
def rotate_right(shape):
    X = shape[::-1]
    return X.T
def rotate_left(shape):
    X = shape.T
    return X[::-1]
def animate_drop(board, shape, c):
    output_list = []
    drop=0
    the_board,the_shape = np.array(board),np.array(shape)
    empty_board = np.zeros(the_board.shape,int)
    dimension_of_shape = the_shape.shape
    OK_to_place=True
    while drop<=the_board.shape[0]-dimension_of_shape[0] :     
      new_empty_board = np.array(empty_board)
      new_empty_board[drop:drop+dimension_of_shape[0],c:c+dimension_of_shape[1]] = the_shape
      new_board_by_plus = the_board + new_empty_board
      new_board_by_plus_check=np.array(new_board_by_plus)
      new_board_by_plus_check[drop:drop+dimension_of_shape[0],c:c+dimension_of_shape[1]] = new_board_by_plus[drop:drop+dimension_of_shape[0],c:c+dimension_of_shape[1]]*(the_shape/(np.max(the_shape)))
      OK_to_place= np.min(the_shape==new_board_by_plus_check[drop:drop+dimension_of_shape[0],c:c+dimension_of_shape[1]])
      if OK_to_place:
        output_list.append(new_board_by_plus)
      else:
        break
      drop+=1
    return output_list
def animate_clear(board):
    output_list=[]
    the_board = np.array(board)
    dimension_of_board = the_board.shape
    positions = np.arange(dimension_of_board[0])
    position_to_clear = positions[((np.min(board,axis=1))!=0)]
    if position_to_clear.shape == (0,):
      return []
    the_board[position_to_clear] = 0
    output_list.append(np.array(the_board))
    for i in range(dimension_of_board[0]):
        position_to_drop = positions[((np.max(the_board,axis=1))==0)]
        if position_to_drop.shape == (0,):
          break
        now_clearing_pos = np.max(position_to_drop)
        the_board[1:now_clearing_pos+1]=np.array(the_board[0:now_clearing_pos]) 
        the_board[0]=0 
        same = np.min(np.array(the_board)==output_list[-1])
        if not same:
          output_list.append(np.array(the_board))
    return output_list

xxx217xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[56, 56, 56, 56, 45, 45, 45, 56]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 822, 'const': 338, 'code+const': 1160}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [('transpose', 2)], [('transpose', 2)], [], []]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 9)], [('While', 13)]]
import numpy as np
def get_score(board):
    m = np.min(board, axis = 1)
    return len(m[m != 0])*40
def get_time_cap(board, time_caps):
    mx = np.max(board, axis = 1)
    p = np.arange(len(mx))
    m0 = mx[mx == 0]
    if len(m0) == len(mx) :
        return(time_caps[-1])
    if len(mx) != 0 :
        pos_row = p[mx != 0][0] 
    idx = ((pos_row + 1)/(len(board)//len(time_caps))) - 1
    idx1 = round(idx) 
    return time_caps[idx1]
def rotate_right(shape):
    a = shape.transpose()
    return a[:,::-1]
def rotate_left(shape):
    a = shape.transpose()
    return a[::-1,:]
def animate_drop(board, shape, c):
    out_board = []
    width = shape.shape[0]
    length = shape.shape[1]
    not_zero = len(board[board != 0]) + len(shape[shape != 0])
    for i in range(0,((len(board) - len(shape)) + 1)) :
        new_board = np.array(board)
        if new_board[i:i+1: , c:c+1:] != [0] :
            return out_board
        new_board[i:i+width: , c:c+length:] += shape
        if len(new_board[new_board != 0]) != not_zero :
            break
        out_board.append(np.array(new_board))
    return out_board
def animate_clear(board):
    new_board = np.array(board) 
    new_board[np.min(board, axis = 1) != 0 ,:] *= 0 
    mx_board = np.max(new_board,axis = 1) 
    n_row = len(mx_board[mx_board != 0]) 
    p = np.arange(len(board))
    final_show = []
    final_show.append(np.array(new_board))
    idx_row = np.max(new_board,axis = 1) == 0
    if np.max(idx_row) == 0 :
        return []
    while True :
        idx_row = np.max(new_board,axis = 1) == 0
        p0 = p[idx_row][-1] 
        if p0 != len(board) :
            new_board[1:p0+1] = new_board[0:p0]
            new_board[0] = 0
            final_show.append(np.array(new_board))
        a = np.max(new_board[-n_row:],axis = 1)
        a_not_zero = len(a[a != 0])
        if a_not_zero == n_row :
            break
    return final_show

xxx203xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 800, 'const': 378, 'code+const': 1178}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 6)], [('While', 12)]]
import numpy as np
def get_score(board):
    check = board > 0
    d = check.shape
    s = np.sum(check,axis=1)
    count = sum(s == d[1])
    return 40*count
def get_time_cap(board, time_caps):
    check = board > 0
    d = check.shape
    s = np.sum(check,axis=1) > 0
    i = np.arange(0,len(board))
    if sum(s) == 0: return time_caps[-1]
    e = i[s][0]*len(time_caps)//len(board)
    return time_caps[e]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    animation = []
    d = shape.shape 
    csh = shape > 0
    i = 0 - d[0] +1
    while True:        
      new_board = np.array(board)
      check = new_board > 0
      if i < 0:
        a = csh[-i:] & check[:i+d[0],c:c+d[1]]
        if True in a: break
      else:
        s = csh & check[i:i+d[0],c:c+d[1]]      
        if True in s: break
        new_board[i:i+d[0],c:c+d[1]] += shape
        animation.append(new_board)
      i += 1
      if i == len(board)-d[0]+1: break
    return animation
def animate_clear(board):
    s = np.sum(board == 0,axis=1)
    clear = s > 0
    i = np.arange(0,len(board))
    c = i[clear] 
    sh = board.shape
    clear_board = np.zeros(sh,int)
    new_board = np.array(board)
    clear_board[c] = new_board[c]
    animation = []
    if False in clear: animation.append(np.array(clear_board))
    while True:    
      z = np.sum(clear_board > 0,axis=1) == 0
      if True not in z: break
      r = i[z][-1]
      if False not in z[0:r]:break
      clear_board[1:r+1] = clear_board[0:r]
      clear_board[0] = np.zeros((1,sh[1]),int)
      b = np.array(clear_board)
      animation.append(b)
    return animation

xxx214xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[ 0,  0,  0,  0],
       [ 0,  5,  5,  4],
       [ 1,  5, 10,  8],
       [ 1,  0,  2,  4]]),
  array([[ 0,  0,  0,  0],
       [ 0,  5,  5,  4],
       [ 1,  5, 10,  8],
       [ 1,  0,  2,  4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 50, 50, 40],
       [0, 50, 50, 40]]),
  array([[0, 0, 0, 0],
       [0, 50, 50, 40],
       [0, 5, 5, 4],
       [0, 50, 50, 40]]),
  array([[0, 0, 0, 0],
       [0, 50, 50, 40],
       [0, 50, 50, 40],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 1232, 'const': 374, 'code+const': 1606}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 11)], [('For', 17)]]
import numpy as np
def get_score(board):
    a=board
    i=0
    e=(a[::1,::1]!=0)
    f=np.sum(e,axis=1)
    g=f[f==a.shape[1]]
    score=g.shape[0]*40
    return score
def get_time_cap(board, time_caps):
    a=board
    b=(a.shape[0])//len(time_caps)
    i=0
    e=(a[::1,::1]!=0)
    f=np.sum(e,axis=1)
    g=f[f!=0]
    if g.shape[0]==0:
        return time_caps[-1]
    else:
        g=a.shape[0]-g.shape[0]
        h=g//b
        time=time_caps[h]
    return time
def rotate_right(shape):
    a=shape[::-1]
    return a.T
def rotate_left(shape):
    a=rotate_right(shape)
    b= a[::-1,::-1]
    return b
def animate_drop(board, shape, c):
    a=board.copy()
    round_board=a.shape[1]
    round_shape=shape.shape[1]
    col_shape=shape.shape[0]
    return_check=[]
    i=0
    for e in range(a.shape[0]-col_shape+1):
        if col_shape==1:
            cccc=a[e]
        elif col_shape>1:
            cccc=a[e+(col_shape-1)]
        b=cccc[c:c+round_shape]
        ch=b[b==0]
        if ch.shape[0]!=shape.shape[1]:
            break
        else:
            a[e:e+col_shape,c:c+round_shape]=shape
            return_check+=[a]
            a=board.copy()
    return return_check
def animate_clear(board):
    a=board
    i=0
    e=(a[::1,::1]!=0)
    f=np.sum(e,axis=1)
    g=f.copy()
    g[g==a.shape[1]]=0 
    h=g.reshape((g.shape[0],-1))
    i=h.reshape((h.shape[0],-1))
    i[i!=0]=1
    j=i*a 
    k=np.zeros((a.shape[0],a.shape[1]),int)
    bb=k.copy()
    re=[]
    numch=-1
    for i in range(j.shape[0]):
        if i==0:
            if g[g==0].shape[0]!=0:
                re+=[j]
                k[-1]=j[-1]
                if (j[-1][j[-1]==0].shape[0])!=j.shape[1]:
                    k[-1]=j[-1]
                    bb=k.copy()
            elif g[g==0].shape[0]==0:
                break
        else:
            ch=j[:-i]
            if k[numch][k[numch]!=0].shape[0]!=0:
                k[i:numch]+=ch[:numch]
                if k[k==bb].shape[0]!=bb.reshape((1,-1)).shape[1]:
                    re+=[k]
                if k[numch-1][k[numch-1]!=0].shape[0]!=0:
                    numch-=1
                    bb[numch]=k[numch]
                k=bb.copy()
            elif k[numch][k[numch]!=0].shape[0]==0:
                k[i:]+=ch
                if k[k==bb].shape[0]!=bb.reshape((1,-1)).shape[1]:
                    re+=[k]
                bb=k.copy()
    return(re)

xxx034xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0AttributeError("module 'numpy' has no attribute 'sim'")
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0TypeError('only integer scalar arrays can be converted to a scalar index')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0TypeError('only integer scalar arrays can be converted to a scalar index')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0IndexError('index 1 is out of bounds for axis 0 with size 1')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[None[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, None0, None0, None0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[None[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
 None      [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[None[]]
bytecount: {'code': 504, 'const': 266, 'code+const': 770}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], []]
import numpy as np
def get_score(board):
    m = board==0
    n = np.sum(m,axis=1)
    return(np.sum((n==0)*40))
def get_time_cap(board, time_caps):
    cap = len(time_caps)
    m = board==0
    n = np.argmin(np.sim(m,axis=1)==board.shape[1])
    nn = np.min(np.sum(m,axis=1)==board.shape[1])
    if n==0 and nn == 1:
        return(time_caps[-1])
    else :
        return(time_caps[n//(len(board)//cap)])
def rotate_right(shape):
    return (shape[::-1,::].T)
def rotate_left(shape):
    return (shape[::,::-1].T)
def animate_drop(board, shape, c):
    ans = []
    for i in range(board.shape[0]):
        new_board = np.array(board)
        if (new_board[i:i+shape.shape[0],c:c+shape[1]].shape)**(shape.shape):
            if not(np.max((new_board[i:i+shape.shape[0],c:c+shape.shape[1]] != 0) * (shape!=0))) :
                new_board[i:i+shape.shape[0],c:c+shape.shape[1]] +=shape
                ans.append(new_board)
            else :
                return ans
        else :
                return ans
def animate_clear(board):
    pass

xxx023xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 792, 'const': 370, 'code+const': 1162}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 9)], [('For', 8)]]
import numpy as np
def get_score(board):
    return 40*np.sum(board.min(axis=1) != 0)
def get_time_cap(board, time_caps):
    n = board.shape[0]//len(time_caps)
    nt = time_caps*n
    nt.sort() 
    t = np.array(nt)
    if np.sum(board.max(axis=1)) == 0 :
        return t[-1]
    return t[board.max(axis=1) != 0][0]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    l = []
    findi = np.array([np.arange(shape.shape[0])]).T*np.ones_like(shape)
    new_shape = shape//np.max(shape)
    lowest = np.max(findi*new_shape,axis=0)
    bl = findi<=lowest
    if np.sum(board[:shape.shape[0],c:c + shape.shape[1]][bl]) != 0 :
        return []
    for r in range(shape.shape[0] - 1,board.shape[0]) :
        if np.sum(board[r - shape.shape[0] + 1:r + 1,c:c + shape.shape[1]][shape != 0]) == 0 :
            new_board = np.array(board)
            new_board[r - shape.shape[0] + 1:r + 1,c:c + shape.shape[1]] += shape
            l.append(new_board)
        else : break
    return l
def animate_clear(board):
    board1 = np.array(board)
    if board1.min(axis=1).sum() == 0 :
        return []
    board1[board1.min(axis=1) != 0] = np.zeros((board1.shape[1]),int)
    l = [board1]
    r = board1.shape[0] - 1
    for b in (np.sum(board1,axis=1) == 0)[::-1] :
        if b :
            if np.sum(board1[:r]) != 0 :
                board1 = np.array(board1)
                board1[1:r + 1] = board1[:r]
                board1[0] = np.zeros((board1.shape[1]))
                l.append(board1)
        else :
            r -= 1
    return l

xxx213xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 662, 'const': 347, 'code+const': 1009}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [], [('pad', 10), ('nonzero', 18)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 14)]]
import numpy as np
def get_score(board):
    return (sum(sum((board!=0).T)==board.shape[1]))*40
def get_time_cap(board, time_caps):
    n=len(board)//len(time_caps)
    a=np.arange(board.shape[0])//n
    x=a[sum((board!=0).T)!=0]
    if len(x)>0:
        return time_caps[x[0]]
    else: return time_caps[-1]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    an=[]
    for i in range(len(board)-shape.shape[0]+1):
        e=np.zeros( (board.shape[0],board.shape[1]), int )
        e[i:shape.shape[0]+i,c:shape.shape[1]+c,]=shape
        if sum(sum((board!=0) & (e!=0)))==0:
            an.append(board+e)
    return an
def animate_clear(board):
    ans = []
    [h, w] = board.shape
    newboard = np.copy(board)
    if get_score(newboard) == 0:
        return ans
    mask = (sum(newboard.T!=0)!=w)
    mask = mask.reshape((-1, 1))
    mask = np.pad(mask, [(0, 0), (0, w-1)], mode='edge')
    cleared_board = newboard * mask
    newboard = cleared_board
    ans.append(newboard)
    while True:
        curboard = np.copy(newboard)
        newboard = np.zeros_like(curboard)
        zero_row = sum(curboard.T==0)==w
        zero_idx = np.nonzero(zero_row)
        if len(zero_idx) == 0:
            break
        lowest_zero = np.max(zero_idx)
        if lowest_zero == len(zero_idx[0]) - 1:
            break
        newboard[lowest_zero:] = curboard[lowest_zero:]
        newboard[1:lowest_zero+1] = curboard[:lowest_zero]
        ans.append(newboard)
    return ans

xxx219xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[56, 56, 56, 56, 45, 45, 456]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[None[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, None1, None5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[None[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, None0, None0, 2, None0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[None[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], None[], None[],
 None[]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [1, 5, 2, 4],
       [1, 5, 5, 4],
       [2, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 5, 5, 4],
       [2, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [2, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
        ... (more)
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [1, 1, 2, 4],
       [2, 2, 2, 4],
       [0, 0, 1, 1]]),
  array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [2, 2, 2, 4],
       [0, 0, 1, 1]]),
  array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 512, 'const': 302, 'code+const': 814}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [], [('For', 5)]]
import numpy as np
def get_score(board):
    a = board!=0
    b = np.sum(a,axis=1)
    c = b==board.shape[1]
    return np.sum(c)*40
def roundup(number):
    if number > int(number):
        return int(number)+1
    else:
        return int(number)
def get_time_cap(board, time_caps):
    n = int(board.shape[0]/len(time_caps))
    b = np.sum(board,axis=1)[::-1]
    r = np.argmin(b)
    i = board.shape[0] + 1 - r
    if r == 0:
        return time_caps[-1]
    return time_caps[roundup(i/n)-1]
def rotate_right(shape):
    rr = shape.T
    if rr.shape[1] > 1:
        return rr[::,::-1]
    return rr
def rotate_left(shape):
    rl = shape.T
    return rl[::-1,::]
def animate_drop(board, shape, c):
    pass
def animate_clear(board):
    boardlist = []
    nboard = np.array(board)
    for i in range(nboard.shape[0]):
        if 0 not in nboard[i]:
            nboard[i,:] = 0
            boardlist.append(nboard)
            nboard1 = np.array(nboard)
            nboard1[1:i+1,:] = nboard[:i,:]
            nboard1[0,:] = 0
            boardlist.append(nboard1)
    return boardlist

xxx039xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 890, 'const': 338, 'code+const': 1228}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 8)], [('While', 13)]]
import numpy as np
def get_score(board):
    c = board!=0
    return np.sum(np.sum(c,axis=1)==board.shape[1])*40
def get_time_cap(board, time_caps):
    a = board!=0
    if np.sum(a)==0: return time_caps[-1]
    rnum = np.argmax(np.sum(a,axis=1)>0)
    return time_caps[(rnum*len(time_caps))//board.shape[0]]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    results = []
    new_board = np.array(board)
    new_shape = np.array(shape)
    if new_board[0,c]!=0: return []
    i = 0
    while True:
      new_board = np.array(board)
      new2 = np.array(new_board[i:i+new_shape.shape[0],c:c+new_shape.shape[1]])
      row,col = new2.shape
      x = new2!=0
      y = new_shape!=0
      if np.sum(x&y)>0: break
      new_board[i:i+new_shape.shape[0],c:c+new_shape.shape[1]]+=new_shape
      results.append(new_board)
      if i+row>=new_board.shape[0]: break
      i+=1
    return results
def animate_clear(board):
    new_board = np.array(board)
    clears = []
    i = 0
    a = np.sum(new_board!=0,axis=1)==new_board.shape[1]
    if np.sum(a)==0:
      return []
    new_board[a]=np.zeros((1,new_board.shape[1]),int) 
    clears.append(new_board)
    limit_start = np.argmax(np.sum(new_board!=0,axis=1)>0)
    limit_times = np.sum(np.sum(new_board[limit_start:,:]==0,axis=1)==new_board.shape[1])
    while True:
      new_board = np.array(new_board)
      b = np.sum(new_board[limit_start:,:]==0,axis=1)==new_board.shape[1]
      if i >= limit_times:
        break
      deleted_row = new_board.shape[0]+(-1)*(np.argmax(b[::-1])+1)
      new_board[1:,:]=new_board[list(range(deleted_row))+list(range(deleted_row+1,new_board.shape[0])),:]
      new_board[0,:]= np.zeros((1,new_board.shape[1]),int)
      clears.append(new_board)
      i+=1
    return clears

xxx024xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0NameError("name 'listOfboard' is not defined")
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0NameError("name 'listOfboard' is not defined")
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0NameError("name 'listOfboard' is not defined")
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 780, 'const': 338, 'code+const': 1118}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('For', 13)]]
import numpy as np
def get_score(board):
    return np.sum(np.sum(board[:]!=[0],axis=1)==board.shape[1])*40
def get_time_cap(board, time_caps):
    positions=np.arange(board.shape[0]) 
    if np.sum(board)==0: 
        return time_caps[-1]
    else: 
        firstfound=np.array(positions)[np.sum(board[:]!=[0],axis=1)!=0][0]
        return time_caps[firstfound//(board.shape[0]//len(time_caps))]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,::]
def animate_drop(board, shape, c):
    check=shape[:,:]!=0
    for i in range(board.shape[0]-shape.shape[0]+1):
        new_board=np.array(board)
        if np.sum(board[i:shape.shape[0]+i,c:c+shape.shape[1]][check])==0:
            new_board[i:shape.shape[0]+i,c:c+shape.shape[1]][check]=shape[check]
            listOfboard.append(new_board)
        else:
            break
    return listOfboard
def animate_clear(board):
    new_board = np.array(board)
    listOfboard=[]
    rowtoclear=np.sum(new_board!=0,axis=1)==board.shape[1]
    if np.sum(rowtoclear)!=0:
        new_board[rowtoclear]=0
        listOfboard.append(new_board)
        row=np.arange(board.shape[0])
        firstfound=np.array(row)[np.sum(new_board==0,axis=1)!=board.shape[1]][0]
        numofdrop=np.sum((np.sum(new_board==0,axis=1)==board.shape[1])[firstfound:])
        clearboard=np.array(new_board)
        for i in range(numofdrop):
            poslastzero=np.array(row)[np.sum(clearboard==0,axis=1)==board.shape[1]][-1]
            clearboard[1:poslastzero+1]=clearboard[:poslastzero]
            clearboard[0]=0
            clear=np.array(clearboard)
            listOfboard.append(clear)
    return listOfboard

xxx027xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1376, 'const': 394, 'code+const': 1770}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 20)], [('For', 21)]]
import numpy as np
def get_score(board):
    check0 = np.min(board,axis=1)
    score = np.sum(check0!=0)*40
    return score
def get_time_cap(board, time_caps):
    r = board.shape[0]//len(time_caps)
    check0 = np.sum(board,axis=1)
    pos = np.arange(board.shape[0])
    if len(pos[check0!=0])!=0:
        realpos = np.min(pos[check0!=0])//r
    else:
        realpos = -1
    return time_caps[realpos]
def rotate_right(shape):
    after = shape[::-1].T
    return after
def rotate_left(shape):
    after = shape[:,::-1].T
    return after
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_board2 = np.array(board)
    new_shape = np.array(shape)
    shapeTF = new_shape == 0
    cutboard = new_board[::,c:c+new_shape.shape[1]:]
    cutboardTF = cutboard==0
    x=1
    allsum = np.sum(new_board[::,c:c+new_shape.shape[1]:],axis=1)
    checkTF = allsum==0
    ans = []
    p = np.arange(new_shape.shape[1]*new_shape.shape[0])
    pos = p.reshape((1,p.shape[0]))
    cutboard2TF=np.array(cutboardTF)
    if not False in checkTF[:new_shape.shape[0]]:
        new_board[:new_shape.shape[0],c:c+new_shape.shape[1]] = np.array(new_shape)
        a = np.array(new_board)
        ans.append(a)
        new_board = np.array(new_board2)
        for i in range(new_board.shape[0]):
            if (cutboard.shape[0]-x>=new_shape.shape[0]) :
                if (not False in(cutboardTF[x:x+new_shape.shape[0]:] | shapeTF)):
                    if False in cutboardTF[x:x+new_shape.shape[0]:]:
                        want = (cutboardTF[x:x+new_shape.shape[0]:]).reshape((1,p.shape[0]))==False
                        pw = pos[want]
                        rss = new_shape.reshape((1,shape.shape[0]*shape.shape[1]))
                        realshape = np.array(rss)
                        realshape[0,pw] = (cutboard[x:x+new_shape.shape[0]:]).reshape((1,p.shape[0]))[0,pw]
                        new_shapeforfalse = np.array(realshape).reshape((new_shape.shape[0],new_shape.shape[1]))
                        new_board[x:x+new_shape.shape[0],c:c+new_shape.shape[1]] = np.array(new_shapeforfalse)
                        cutboardTF = np.array(cutboard2TF)
                        new_shape = np.array(shape)
                    else:
                        new_board[x:x+new_shape.shape[0],c:c+new_shape.shape[1]] = np.array(new_shape)
                        cutboardTF = np.array(cutboard2TF)
                        new_shape = np.array(shape)
                    a = np.array(new_board)
                    new_board = np.array(new_board2)
                    ans.append(a)
                    x = x+1
                else:
                    break
    return ans
def animate_clear(board):
    new_board = np.array(board)
    cols = [0]*new_board.shape[1]
    allsum = new_board.min(axis=1)
    checkTF = allsum!=0
    pos = np.arange(new_board.shape[0])
    line = pos[checkTF]
    if line.shape[0]!=0:
        new_board[(line)]=0
    allsum = new_board.sum(axis=1)
    checkTF= allsum==0
    pos = np.arange(new_board.shape[0])
    line = pos[checkTF]
    ans = []
    new_board2 = np.array(new_board)
    if False in (board == new_board2):
        ans.append(new_board2)
    for i in range(len(line)):
        allsum = new_board.sum(axis=1)
        checkTF= allsum==0
        pos = np.arange(new_board.shape[0])
        line = pos[checkTF]
        r = line[-1]
        move = np.zeros((r+1,new_board.shape[1]),int)
        move[1::] = new_board[:r:]
        new_board[:r+1:] = move
        real_board = np.array(new_board)
        if False in (real_board == new_board2):
            ans.append(real_board)
        new_board2 = np.array(new_board)
    return ans

xxx037xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[56, 56, 56, 56, 45, 456, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       ... (more)
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 878, 'const': 358, 'code+const': 1236}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 4)], [('While', 11)]]
import numpy as np
def get_score(board):
  return board[np.min(board.T,axis=0)!=0].shape[0]*40
def get_time_cap(board, time_caps):
  m = np.max(board, axis=1); m[m>0] = -1
  a = np.argmin(m)+1
  b = board.shape[0]/len(time_caps)
  norm = a/b; p = 0
  if int(norm)==0:
    if norm<0.5: p = 0
    else: p = 1
  else: 
    if norm/int(norm) == 1: p = int(norm)-1
    else: p = int(norm)
  if np.sum(m) == 0: p = -1
  return time_caps[p]
def rotate_right(shape):
  shape = shape[::-1,:]
  return shape.T
def rotate_left(shape):
  return rotate_right(rotate_right(rotate_right(shape)))
def animate_drop(board, shape, c):
  act = []; place = board[0:shape.shape[0],c:c+shape.shape[1]]
  for i in range(board.shape[0]):
    place = board[i:i+shape.shape[0],c:c+shape.shape[1]]
    if place.shape[0]>=shape.shape[0]:
      if np.sum(place[shape>0]) == 0:
        created = np.array(board)
        created[i:i+shape.shape[0],c:c+shape.shape[1]]+=shape
        act.append(created)
  return act
def animate_clear(board):
  act = []; i=0
  board[np.min(board.T,axis=0)!=0] = 0
  act.append(board)
  sm = np.sum(board.T,axis=0)
  sm[sm!=0] = -1
  point = sm[np.argmin(sm):]
  point = point[point==0]
  if point.shape[0] != 0: 
    while i<point.shape[0]:
      mk = np.zeros(board.shape[0])
      mk[-np.argmin(np.mean(board,axis=1)[::-1])-1] = -1
      board = board[np.array(mk+1,dtype=bool)]
      st = np.ndarray((board.shape[0]+i+1, board.shape[1]),int)
      st[:i+1,:] = 0; st[i+1:,:] = board
      act.append(np.array(st)); i+=1
    return act
  else: return []

xxx211xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1314, 'const': 352, 'code+const': 1666}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [('all', 2)], [], [], [], []]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 9)], [('While', 14)]]
import numpy as np
def get_score(board):
    a = board.shape
    b = np.array([0]*a[1])
    c = board != b
    d = np.array([True]*(a[0])).reshape((a[0],1))
    e = np.sum(c,axis = 1)
    f = e[e == a[1]]
    return len(f)*40
def get_time_cap(board, time_caps):
    if (board == np.zeros(board.shape,int)).all():
        return time_caps[-1]
    else:
        a = np.sum(board,axis = 1)
        b = np.array([0]*(board.shape[0]))
        c = list(a > b)
        d = c.index(True)
        e = int(board.shape[0]/len(time_caps))
        f = (np.arange(e*int(len(time_caps)))).reshape((len(time_caps),e))
        g = [d] == f
        h = list(np.sum(g,axis = 1))
        i = h.index(1)
        return time_caps[i]
def rotate_right(shape):
    return shape.T[::,::-1]
def rotate_left(shape):
    return shape.T[::-1,::]
def animate_drop(board, shape, c):
    ans = []
    new_board = np.array(board)
    arange = np.arange(shape.shape[1])
    row_shape = []
    col_shape = []
    i = 0
    d = 0
    while True:
        if i < shape.shape[0]:
            a = arange[shape[i,::] != np.zeros(shape.shape[1],int)]
            col_shape += (list(a))
            row_shape += [i]*len(a)
        else:
            if np.sum(board[0, c: c+(shape.shape[1]) : ] != np.zeros(shape.shape[1],int)) != 0:
                return ans
            else:
                compare = new_board[d:d+shape.shape[0]:,c:c+(shape.shape[1])]
                if board.shape[0] - d < shape.shape[0]:
                    break
                if np.sum(compare[row_shape,col_shape] != 0) == 0 :
                    new_board[d:d+shape.shape[0]:,c:c+(shape.shape[1])] += shape
                    ans.append(new_board)
                    new_board = np.array(board)
                else: break
            d += 1
        i += 1
    return ans
def animate_clear(board):
    new_board = np.array(board)
    i = new_board.shape[0] - 1
    a = new_board != np.zeros(board.shape,int)
    b = np.sum(a,axis = 1)
    c = b[b == board.shape[1]]
    d = len(c)
    e = []
    ans = []
    f = 0
    if d == 0:
        return e
    while True:
        if f < board.shape[0]:
            if b[f] == board.shape[1]:
               e.append(f)
            if f == board.shape[0] - 1:
               e = tuple(e)
               new_board[e,::] = np.zeros(board.shape[1],int)
               ans.append(new_board)
        else:
            if np.sum(new_board[:i:,::] == np.zeros((i,board.shape[1]),int)) == (i)*board.shape[1]:
                break
            if np.sum(new_board[i,::] == np.zeros(board.shape[1],int)) == 1*board.shape[1]:
                zero = np.zeros_like(board,int)
                zero[1:i+1:,::] = new_board[:i:,::]
                zero[i+1::,::] = new_board[i+1::,::]
                ans.append(zero)
                new_board = np.array(zero)
            else:
                if i != 0:
                    i -= 1
                else:
                    break
        f += 1
    return ans

xxx200xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1136, 'const': 378, 'code+const': 1514}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('While', 16)]]
import numpy as np
def get_score(board):
  A = board>0
  B = np.sum(A,axis=1)
  C = B // board.shape[1]
  D = np.sum(C)
  return D*40
def get_time_cap(board, time_caps):
  A = board>0
  if True not in A:
      return int(time_caps[-1])
  B = np.sum(A,axis=1)
  C = B.reshape((board.shape[0]//(board.shape[0]//len(time_caps)),(board.shape[0]//len(time_caps))))
  D = np.sum(C,axis=1)
  E = D>0
  time_caps = np.array(time_caps)
  F = time_caps[E]
  return F[0]
def rotate_right(shape):
    shape = shape.T
    return shape[:,::-1]
def rotate_left(shape):
    shape = shape[:,::-1]
    return shape.T
def animate_drop(board, shape, c):
  long = shape.shape[1]
  high = shape.shape[0]
  final = []
  for i in range(len(board)):
      A = board[i:i+high:1,c:c+long:1]
      check = np.ones_like(A,int) 
      if ((high==A.shape[0])and(long==A.shape[1])) and (np.sum(A+shape == abs(A-shape)) == np.sum(check)):
          board_copy = board.copy()
          board_copy[i:i+high:1,c:c+long:1] = shape+A
          final.append(board_copy)
      else:
          break
  return final
def animate_clear(board):
  board_1 = board.copy()
  check_board = board_1 > 0
  check_board_1 = np.array([((np.sum(check_board,axis=1))==board.shape[1])])
  check_board_2 = (check_board_1==False)
  position = np.array([np.arange(0,check_board_1.shape[1])])
  issue_position = position[check_board_1]
  normal_position = position[check_board_2]
  board_1[issue_position] = board_1[issue_position]*0 
  final = []
  i = position.shape[1]-2
  base = i
  down = False
  final.append(board_1)
  while i!= 0:
      board_22 = board_1.copy()
      New_board = board_1.copy()
      if np.sum(board_22[i]) == 0:
          ramnant_board = board_1[0:i:1,:]
          working_board = board_1.copy()
          working_board[0:i:1,:] = working_board[0:i:1,:]*0
          working_board[1:i+1:1,:] = ramnant_board
          board_22 = working_board.copy()
          down = True
      elif np.sum(board_22[i+1]) == 0:
          ramnant_board = board_1[0:i+1:1,:]
          working_board = board_1.copy()
          working_board[0:i+1:1,:] = working_board[0:i+1:1,:]*0
          working_board[1:i+2:1,:] = ramnant_board
          board_22 = working_board.copy()
          down = True
      if (np.sum(abs(board_22-New_board))!=0):
          final.append(board_22)                         
      board_1 = board_22.copy()
      if (down==False):
          i -= 1
      if np.sum(board_22[0:i+1:1,:]) == 0:
          break
      down = False
  if len(final) == 1:
        return []
  return final

xxx034xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (4,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (6,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (3,)')
[[array([[1, 1, 02, 02],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 02, 02]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 592, 'const': 258, 'code+const': 850}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('all', 6)], [('concatenate', 8), ('all', 10)]]
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], []]
import numpy as np
def get_score(board):
    x=board>0
    a=sum([x==False][::])
    b=sum(a.T==1)
    s=sum(b==0)
    return(s*40)
def get_time_cap(board, time_caps):
    a=sum(board.T)
    b=a>0
    b=b[b==True]
    c=len(a)-len(b)
    x=int(len(board)/len(time_caps))
    if len(b)==0:
        c=c-1
    return(time_caps[(int(c))//x])
def rotate_right(shape):
    a=shape.T
    a=a[::,::-1]
    return(a)
def rotate_left(shape):
    a=shape.T
    a=a[::-1]
    return(a)
def animate_drop(board, shape, c):
    new_board = np.array(board)
    x=shape
    s=list()
    for i in range (board.shape[0]):
        if (new_board[i,c:]==0).all():
            new_board[i,c:]=x
            s.append(new_board)
            new_board[i,c:]=0
    return(s)
def animate_clear(board):
    new_board = np.array(board)
    s=list()
    a=sum((new_board[::,::]!=0).T)
    new_board[a==board.shape[1]]=0
    s.append(new_board)
    a=sum((new_board[::,::]==0).T)
    b=np.concatenate((new_board[a==board.shape[1]], new_board[a!=board.shape[1]]), axis=0)
    s.append(b)
    if (s[0]==s[1]).all():
        s=[]
    return(s)

xxx023xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0IndexError('boolean index did not match indexed array along dimension 1; dimension is 3 but corresponding boolean dimension is 4')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0IndexError('boolean index did not match indexed array along dimension 1; dimension is 4 but corresponding boolean dimension is 3')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0IndexError('boolean index did not match indexed array along dimension 1; dimension is 1 but corresponding boolean dimension is 2')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [0, 0, 0, 0],
       [1, 0, 2, 4]]),
  array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [1, 0, 5, 4],
       [1, 0, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 932, 'const': 356, 'code+const': 1288}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 9)]]
import numpy as np
def get_score(board):
    arr = list(np.min(board,axis=1))
    score = len(arr)-arr.count(0)
    return score*40
def get_time_cap(board, time_caps):
    if np.sum(board) == 0:
        return time_caps[-1]
    else:
        st = len(board)/len(time_caps)
        arr = np.max(board,axis=1)
        ind = list(arr).index(arr[arr != 0][0])
        return time_caps[int(ind//st)]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:, ::-1].T
def animate_drop(board, shape, c):
    r = len(shape)-1
    col = len(shape[0])
    ind = shape!=0
    ans = []
    v = np.max(shape)
    for i in range(len(board)):
        if i == len(board)-1:
            break
        sele = board[list(range(i,i+r+1)),:][:,list(range(c,c+col))]
        if np.sum(sele[ind]) == 0:
            co = np.array(list(board).copy())
            a = co[list(range(i,i+r+1)),c:col+1] 
            a[ind] = v
            co[list(range(i,i+r+1)),c:col+1] = a
            ans.append(np.array(list(co).copy()))
    return ans
def animate_clear(board):
    ind = np.arange(len(board))[np.min(board,axis=1)!=0]
    if len(ind) == 0:
        return []
    board[ind,:] = np.zeros(len(board[0]))
    ans = []
    ans.append(np.array(list(board).copy()))
    while 1:
        ind = np.arange(len(board))[np.max(board,axis=1)==0]
        ind = ind[ind != 0]
        a = np.sum(board[np.array(ind-np.ones(len(ind)), dtype=int),:],axis=1) != 0
        ind = ind[a]
        if len(ind) == 0 :
            break
        val = board[np.array(ind-np.ones(len(ind)), dtype=int),:]
        board[ind,:] = val
        board[np.array(ind-np.ones(len(ind)), dtype=int),:] = np.zeros((len(ind),len(board[0])))
        ans.append(np.array(list(board).copy()))
    return ans

xxx040xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 736, 'const': 324, 'code+const': 1060}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 8)], [('While', 12)]]
import numpy as np
def get_score(board):
    m=np.sum(board==0,axis=1)
    n=np.sum(m==0)
    return 40*n
def get_time_cap(board, time_caps):
    n=board.shape[0]//len(time_caps)
    m=np.sum(board,axis=1)
    m2=m.reshape((m.shape[0]//n,n))
    m3=np.sum(m2,axis=1)
    idx=np.argmin(m3==0)
    if idx==0 and np.sum(m3)==0:
      return time_caps[-1]
    else:
      return time_caps[idx]
def rotate_right(shape):
    return (shape.T)[:,::-1]
def rotate_left(shape):
    return (shape.T)[::-1]
def animate_drop(board, shape, c):
    l=[]
    i=shape.shape[0]
    j=shape.shape[1]
    new_board = np.array(board)
    n=np.sum(board==0)-np.sum(shape!=0)
    for k in range(board.shape[0]-i+1):
      new_board[k:k+i,c:c+j]+=shape
      if np.sum(new_board==0)!=n:break
      else:
        l.append(new_board)
        new_board = np.array(board)
    return l
def animate_clear(board):
    new_board = np.array(board)
    tf=(np.sum(board==0,axis=1))!=0
    clear_row_board=new_board*(tf.reshape((tf.shape[0],1)))
    if clear_row_board.shape!=board.shape or np.sum(clear_row_board!=board)!=0:
      new_clear_board=np.array(clear_row_board)
      l=[new_clear_board]
    else:
      return []
    r=board.shape[0]-1
    while r>0:
      if np.sum(clear_row_board[r])==0:
        clear_row_board[1:r+1]=clear_row_board[:r]
        clear_row_board[0]=np.zeros((1,board.shape[1]),int)
        if clear_row_board.shape!=new_clear_board.shape or             np.sum(clear_row_board!=new_clear_board)!=0:
          new_clear_board=np.array(clear_row_board)
          l.append(new_clear_board)
        else:break
      else:
        r-=1
    return l

xxx023xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_20.0
[[array([[0, 2, 0, 0],
       [2, 2, 2, 0],
       [1, 1, 0, 0]])],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 634, 'const': 386, 'code+const': 1020}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 10)], []]
import numpy as np
def get_score(board):
    a = np.min(board,axis=1)
    a = a[a>0]
    score = 40*len(a)
    return score
def get_time_cap(board, time_caps):
    a = np.max(board,axis=1)
    a = a[a==0]
    if len(a) == len(board): n = time_caps[-1]
    else:
        n = time_caps[int(((len(a)+0.5)//2))]
    return n
def rotate_right(shape):
    s = shape.shape
    rshape = shape.T
    rshape = rshape[:,::-1]
    return np.array(rshape)
def rotate_left(shape):
    s = shape.shape
    rshape = shape.T
    rshape = rshape[::-1]
    return np.array(rshape)
def animate_drop(board, shape, c):
    l = []
    new_board = np.array(board)
    size_board = board.shape
    size_shape = shape.shape
    new_shape = np.array(shape)
    num_shape = np.max(new_shape,axis=1)[0]
    if size_shape[1] <= size_board[1] - c:
      for i in range(size_board[0]-size_shape[0]+1):
        cut_board = new_board[i:i+size_shape[0], c:c+size_shape[1]]
        shape_plus_board = new_shape + cut_board
        shape_plus_board = shape_plus_board[(shape_plus_board == 0) | (new_shape == 0) |  (shape_plus_board == num_shape)]
        if len(shape_plus_board) == size_shape[0] * size_shape[1]:
          result_board = np.zeros_like(board,int)
          result_board[i:i+size_shape[0],c:c+size_shape[1]] = new_shape
          result_board += new_board
          l.append(np.array(result_board))
        else:
          break
    return l
def animate_clear(board):
    l = []
    new_board = np.array(board)
    min_board = np.min(new_board,axis=1)
    new_board[min_board > 0] = 0
    l.append(np.array(new_board))
    return l

xxx207xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1450, 'const': 338, 'code+const': 1788}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 5)], [('For', 17)]]
import numpy as np
def get_score(board):
    return np.sum(((board == 0).sum(axis=1)) == 0)*40
def get_time_cap(board, time_caps):
    n = int(board.shape[0] // len(time_caps))
    cata = np.arange(board.shape[0])
    x = cata[np.sum(board != 0, axis=1) > 0]
    if len(x) == 0: return time_caps[-1]
    return time_caps[x[0]//n]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1,:]
def animate_drop(board, shape, c):
    out = list()
    row = board.shape[0]; col = board.shape[1]
    for i in range(1,row+1):
        n_board = np.array(board); n_shape = np.array(shape)
        blank = n_board == 0  
        if i > n_shape.shape[0]:
            notzero = n_shape[:i,][n_shape[:i,] != 0]
            check = (n_shape == 0) | blank[i-n_shape.shape[0]:i , c:c+n_shape.shape[1]]
            L =  n_shape.shape[0] * n_shape.shape[1]
            if np.sum(check) != L: break
            blank_board = np.zeros_like(n_board,int)
            blank_board[i-n_shape.shape[0]:i , c:c+n_shape.shape[1]] = n_shape[:i,]
            onedimen = n_board.reshape(row*col)
            c_board = blank_board != 0
            c_board = c_board.reshape(row*col)
            index = np.arange(row*col)[c_board]
            onedimen[index] = notzero
            onedimen = onedimen.reshape((row,col))
        else:
            notzero = n_shape[-i:,][n_shape[-i:,] != 0]
            check = (n_shape[-i:,] == 0) | blank[:i,c: c + n_shape.shape[1]]
            L =  n_shape[-i:,].shape[0] * n_shape[-i:,].shape[1]
            if np.sum(check) != L: break
            blank_board = np.zeros_like(n_board,int)
            blank_board[:i,c:c+n_shape.shape[1]] = n_shape[-i:,]
            onedimen = n_board.reshape(row*col)
            c_board = blank_board != 0
            c_board = c_board.reshape(row*col)
            index = np.arange(row*col)[c_board]
            onedimen[index] = notzero
            onedimen = onedimen.reshape((row,col))
        if i >= n_shape.shape[0]: out.append(np.array(n_board))
    return out
def animate_clear(board):
    out = list()
    n_board = np.array(board)
    row = n_board.shape[0]; col = n_board.shape[1]
    b1 = np.sum(n_board == 0, axis=1) == 0
    if np.sum(b1) == 0: return []
    n_board[np.arange(row)[b1], :] = 0
    out.append(n_board)
    b2 = np.sum(n_board != 0, axis=1) == 0
    index = np.arange(row)[b2]
    n = index[-1]
    check = np.abs(index[1:]-index[:-1]) == 1
    check_zero = n_board[:min(index),:] != 0
    if np.sum(check) == index.shape[0]-1         and np.sum(check_zero) == 0:
        return out
    for i in range(len(index)):
        blank_board = np.zeros_like(n_board,int)
        blank_board[n+1:] = n_board[n+1:]
        blank_board[1:n+1] = n_board[:n]
        out.append(blank_board)
        n_board = np.array(blank_board)
        b2 = np.sum(n_board != 0, axis=1) == 0
        index = np.arange(row)[b2]
        n = index[-1]
        check = np.abs(index[1:]-index[:-1]) == 1
        check_zero = n_board[:min(index),:] != 0
        if np.sum(check) == index.shape[0]-1             and np.sum(check_zero) == 0:
            break
    return out

xxx211xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_30.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])]]
bytecount: {'code': 830, 'const': 338, 'code+const': 1168}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 10)], [('While', 10)]]
import numpy as np
def get_score(board):
    zero=np.zeros((board.shape[0],board.shape[1]),int)
    x=(board==zero)
    total=np.sum(x,axis=1)
    answer=len(board[total==0])*40
    return answer
def get_time_cap(board, time_caps):
    total=np.sum(board, axis=1)
    b=(total!=0)+0
    if np.max(b, axis=0)!=0:
        n=np.argmax(b, axis=0)
        n1=n//(len(board)//len(time_caps))
        answer=time_caps[n1]
    else:
        answer=time_caps[-1]
    return answer
def rotate_right(shape):
    x=shape.T
    y=x[::,::-1]
    return y
def rotate_left(shape):
    x=shape.T
    y=x[::-1]
    return y
def animate_drop(board, shape, c):
    can_put = c + len(shape[0])
    rng_element_board = np.sum(board > 0)
    rng_element_dis = np.sum(shape > 0)
    first_element = rng_element_board + rng_element_dis
    new = np.array(board)
    step = 0
    lst = []
    while True:
        copy_board = np.copy(new)
        if step+len(shape) <= copy_board.shape[0]:
          copy_board[step:step + len(shape), c:can_put] += shape
        else:
          break
        now_element = np.sum(copy_board > 0)
        if now_element == first_element:
            lst.append(copy_board.copy())
        else:
            break
        step += 1
    return lst
def animate_clear(board):
    clean_board = np.copy(board)
    clean_board[np.min(clean_board, axis=1) > 0, 0:] = np.zeros(len(board[0]))  
    cnt_lines_must_solve = len(clean_board[np.max(clean_board, axis=1) > 0])
    lst = [np.copy(clean_board)]
    first = 0
    if np.sum(np.max(clean_board,axis=1) > 0) == len(clean_board):
        return []
    while True:
        target = np.max(clean_board, axis=1)[::-1]
        if np.sum(target[:cnt_lines_must_solve] > 0) == cnt_lines_must_solve:
            break
        else:
            temp = np.max(clean_board, axis=1) == 0
            where_zero = np.arange(len(clean_board))
            current_zero = where_zero[temp][::-1][0]
            clean_board[first + 1:first + current_zero + 1] = clean_board[first:current_zero]
            zero_temp = np.zeros(len(clean_board[0]))
            clean_board[first] = zero_temp
            lst.append(np.copy(clean_board))
    return lst

xxx212xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0
[56, 56, 56, 56, 456, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 816, 'const': 350, 'code+const': 1166}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 6)], [('For', 15)]]
import numpy as np
def get_score(board):
    board_bool = 0 != board
    col = board.shape[1]
    x = np.sum(board_bool,axis=1)
    count = x == col
    return sum(count)*40
def get_time_cap(board, time_caps):
    if board.shape[0]/len(time_caps) == 1:
        new = board[::board.shape[0]//len(time_caps)]
    else:
        new = board[::board.shape[0]//len(time_caps)]+board[1::board.shape[0]//len(time_caps)]
    index = np.arange(0,len(time_caps)) 
    bool = np.sum(new,axis=1) != 0 
    if sum(bool) == 0:
        return time_caps[-1]
    return time_caps[np.min(index[bool])]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    show = []
    row,col = shape.shape
    if c + col > board.shape[1]: return show
    row_count = 0
    while row_count+(row-1) < board.shape[0]:
        new_board = np.array(board)
        block_check = new_board[row_count : row_count+row  , c:c+col] == 0
        shape_check = shape != 0
        drop_check = block_check & shape_check
        if np.sum(drop_check) == np.sum(shape_check):
            new_board[row_count : row_count+row  , c:c+col] += shape[:,:]
            show.append(new_board)
        else:
            break
        row_count += 1
    return show
def animate_clear(board):
    show = []
    new_board1 = np.array(board)
    check = np.sum(new_board1 == 0, axis=1) 
    x = check == 0 
    new_board1[x,:] = 0
    if sum(x) == 0: return []
    show.append(new_board1) 
    index = np.arange(0,board.shape[0],1) 
    check2 = np.sum(new_board1 != 0, axis=1)
    y_bool = check2 == 0
    start_order_for_move = index[y_bool == False][0]
    index0_move = index[y_bool][start_order_for_move::1][::-1]
    order_for_show = list(range(0,board.shape[0],1))
    for e in index0_move:
        order_for_show.remove(e)
        order_for_show.insert(0,e)
        new_show = new_board1[order_for_show]
        show.append(new_show)
    return show

xxx029xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_31.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 826, 'const': 338, 'code+const': 1164}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 9)], [('For', 11)]]
import numpy as np
def get_score(board):
  t = np.min(board,axis=1)
  t = t[t!=0]
  ans = np.ones(len(t))
  ans = np.sum(ans)*40
  return int(ans)
def get_time_cap(board, time_caps):
  t = np.max(board,axis=1)
  t = t[t==0]
  ans = np.ones(len(t))
  ans = int(np.sum(ans))
  ans = ans//(board.shape[0]//len(time_caps))
  if ans == len(time_caps):
      return time_caps[-1]
  return time_caps[ans]
def rotate_right(shape):
    return shape.T[::,::-1]
def rotate_left(shape):
    return shape.T[::-1,::]
def animate_drop(board, shape, c):
  board = np.array(board)
  rowboard, colboard = board.shape
  shape = np.array(shape)
  rowshape, colshape = shape.shape
  if np.sum(board[:rowshape,c:c+colshape]) == 0:
      r = []
      for i in range(rowboard):
          newboard = np.array(board)
          if i+rowshape-1 == rowboard:
              break
          keepboard = (newboard)[i:i+rowshape,c:c+colshape]
          before = np.sum(keepboard)
          keepboard[shape!=0] = shape[shape!=0]
          after = np.sum(keepboard)
          if before + np.sum(shape)!=after:  
              break
          else:
              r+=[np.array(newboard)]
      return r
  else:
      return []
def animate_clear(board):
  board = np.array(board)
  rowboard, colboard = board.shape
  t = np.min(board,axis=1)
  if np.sum(np.ones(len(t))[t!=0]) == 0:
      return []
  else:
      board[t!=0] = 0
      r = [np.array(board)]
      for i in range(rowboard):
          t = np.max(board,axis=1)
          t = t[::-1]
          next = np.argmin(t)
          next = rowboard-next
          boardmove = board
          boardmove[1:next] = boardmove[0:next-1]
          boardmove[0] = 0            
          r+=[np.array(boardmove)]
          t = np.max(boardmove,axis=1)
          t = t[::-1]
          nextnext = np.argmin(t)
          nextnext = rowboard-nextnext            
          if np.sum(np.max(boardmove,axis=1)==0) == nextnext:
              break
      return r

xxx035xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap0.0IndexError('list index out of range')
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_10.0ValueError('could not broadcast input array from shape (2,3) into shape (3,)')
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_20.0ValueError('could not broadcast input array from shape (3,3) into shape (3,)')
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0ValueError('could not broadcast input array from shape (3,2) into shape (2,)')
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])], [], [],
 []]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 654, 'const': 382, 'code+const': 1036}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 9)], [('While', 12)]]
import numpy as np
def get_score(board):
    return (sum(np.min(board,axis=1)!= 0))*40
def get_time_cap(board, time_caps):
    a = sum(np.max(board,axis=1)==0)
    if a%2 == 0:
        if a == board.shape[0]:
            return time_caps[-1]
        else:
            return time_caps[a//2]
    else:
        return time_caps[(a-1)//2]
def rotate_right(shape):
    return shape[::-1].T
def rotate_left(shape):
    return shape[:,::-1].T
def animate_drop(board, shape, c):
    flag = 0
    animate = []
    wide = shape.shape[1]
    new_board = np.array([])
    use_board = np.array(board[:,c:])
    mask = np.max(use_board,axis = 1)
    for i in range(board.shape[0]):
      if mask[i] != 0:
        flag = 1
      if mask[i] == 0 and flag != 1:
        new_board = np.array(board)
        new_board[i, c:c+wide] = np.array(shape)
        animate.append(new_board)
    return animate
def animate_clear(board):
    x = []
    copy_board = np.array(board)
    mask = np.min(copy_board,axis = 1)
    pos = np.arange(copy_board.shape[0])[mask != 0]
    if pos.shape[0] == 0:
      return x
    copy_board[pos] = [0]
    x.append(copy_board)
    row = copy_board.shape[0] - 1
    while True:
      mask_zero_row = np.max(copy_board, axis=1)
      is_zero_row = mask_zero_row == 0
      if False not in is_zero_row[:row]:
        return x
      if is_zero_row[row]:
        b = np.arange(copy_board.shape[0])
        b[0] = b[row]
        b[1:row+1] -= 1
        copy_board = copy_board[b]
        x.append(copy_board) 
      else:
        row -= 1

xxx030xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 836, 'const': 338, 'code+const': 1174}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('While', 8)], [('While', 12)]]
import numpy as np
def get_score(board):
    count = np.min(board, axis = 1)
    score = sum(count > 0) * 40
    return score
def get_time_cap(board, time_caps):
  check = np.max(board, axis = 1)
  get_ready = np.arange(0,len(board))
  ready_check = get_ready[check != 0]
  if len(ready_check) > 0:
      return time_caps[int(ready_check[0]*len(time_caps)/len(board))]
  else:
      return (time_caps[-1])
def rotate_right(shape):
    new_shape = shape.T
    return (new_shape[:,::-1])
def rotate_left(shape):
    new_shape = shape.T
    return (new_shape[::-1])
def animate_drop(board, shape, c):
    new_board = np.array(board);new_shape = np.array(shape)
    r,col = new_shape.shape
    out = []
    i = r - 1
    ch_shape = np.sum(new_shape != 0)
    while (i < board.shape[0]):
        x = i - r + 1
        ch_board = np.sum(board[x:x+r, c:c+col] != 0)
        ch_zero = np.sum(board[x:x+r, c:c+col] == 0)
        if x < board.shape[0] and (ch_zero >= ch_shape):
            new_board[x:x + r, c:c+col] += new_shape
            ch_new_board = np.sum(new_board[x:x+r, c:c+col] != 0)
            if ch_shape + ch_board == ch_new_board:
                out.append(new_board)
                new_board = np.array(board)
                i += 1
            else:
                break
        else:
            break         
    return out
def animate_clear(board):
    new_board = np.array(board)
    out = []
    check = np.min(new_board, axis = 1)
    new_board[check != 0] = 0
    if sum(check) > 0:
        out.append(new_board)
    i = 0
    check_new_b = np.max(new_board, axis = 1)
    check_loop = sum(check_new_b==0)
    while i < len(new_board)-check_loop:
        new_board = new_board[::-1]
        if sum(new_board[i]) == 0:
            new_board = np.array(list(new_board[0:i] ) + list(new_board[i + 1:])+ [np.zeros((new_board.shape[1]), int)])
            new_board = new_board[::-1]
            out.append(new_board)
        else:
            new_board = new_board[::-1]
            i += 1
    return out

xxx033xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0IndexError('index 0 is out of bounds for axis 0 with size 0')
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 974, 'const': 338, 'code+const': 1312}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 6)], [('For', 12)]]
import numpy as np
def get_score(board):
    return np.sum(np.sum(board==0,axis=1)==0)*40
def get_time_cap(board, time_caps):
    if np.sum(board)==0:
        return time_caps[-1]
    return time_caps[np.arange(board.shape[0])[np.sum(board!=0,axis=1)!=0][0]//(board.shape[0]//len(time_caps))]
def rotate_right(shape):
    return shape.T[:,::-1]
def rotate_left(shape):
    return shape.T[::-1]
def animate_drop(board, shape, c):
    a = np.array(board)
    b = np.array(shape)
    s = []
    for i in range(a.shape[0]):
        if i+b.shape[0]<=a.shape[0]:
            d = np.zeros_like(a,int)
            d[i:i+b.shape[0],c:c+b.shape[1]] = b   
        else:
            return s
        if a.shape[1]-b.shape[1]>=c and         np.sum(a+d!=0)-np.sum(a!=0)==np.sum(b!=0):
            s.append(a+d)
        else:
            return s
    return s
def animate_clear(board):
    s = []
    b = np.array(board)
    a = np.arange(b.shape[0])
    e = np.arange(board.shape[0])[np.sum(b!=0,axis=1)==b.shape[1]]
    if len(e)==0:
        return s
    b[e] = 0
    s.append(b)
    d = np.sum(b!=0,axis=1)
    for i in range(np.sum(np.sum(b==0,axis=1)==b.shape[1])-a[d!=0][0]):
        c = a[np.sum(b==0,axis=1)==b.shape[1]][-1]
        if c!=b.shape[0]-1:
            b = np.array(list(b[c])+list(b[:c].reshape(b[:c].shape[0]*b[:c].shape[1]))+                 list(b[c+1:].reshape(b[c+1:].shape[0]*b[c+1:].shape[1]))).reshape(b.shape[0],b.shape[1])
        else:
            b = np.array(list(b[c])+list(b[:c].reshape(b[:c].shape[0]*b[:c].shape[1]))).reshape(b.shape[0],b.shape[1])
        s.append(b)
    return s

xxx024xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_11.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 806, 'const': 338, 'code+const': 1144}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 10)], [('For', 11)]]
import numpy as np
def get_score(board):
    TF=np.sum((board[::]==[0]),axis=1)
    n=np.sum((TF==0))   
    return n*40
def get_time_cap(board, time_caps):
    position=np.arange(board.shape[0])
    summ=(np.sum(board,axis=1)>0)
    s_summ=np.sum(summ)
    ps=position[summ]
    if s_summ!=0:   
        n=board.shape[0]//len(time_caps)
        nn=(ps[0]//n)
        return(time_caps[nn])
    else:
        return(time_caps[-1])
def rotate_right(shape):
    c=shape.T
    return c[::,::-1]
def rotate_left(shape):
    c=shape.T
    return c[::-1]
def animate_drop(board, shape, c):
    new_board = np.array(board)
    new_shape = np.array(shape)
    n=new_board.shape[1]-new_shape.shape[1]
    if c>n:
        return []
    else:
        li=[]
        n_sh=new_shape>0
        for i in range(board.shape[0]):                        
            hole=new_board[i:i+new_shape.shape[0]:,c:c+new_shape.shape[1]:]
            if hole.shape==n_sh.shape:
                g=np.sum(hole[n_sh])
                if g==0:
                    new_board[i:i+new_shape.shape[0]:,c:c+new_shape.shape[1]:]+=new_shape
                    li.append(new_board)
                    new_board = np.array(board)
                else:break
        return li
def animate_clear(board):
    new_board = np.array(board)
    TF_board  = (np.array(board)==0)
    TF  =  (np.sum(TF_board,axis=1)==0)
    if np.sum(TF)==0:
        return []
    else:
        new_board[TF]=new_board[TF]*0
        num_0=np.sum(np.sum(new_board,axis=1)==0)
        li=[new_board]     
        for i in range(num_0):
            n_b=new_board
            new_board=new_board[::-1]
            p=np.sum(new_board,axis=1)
            posi_0=np.argmin(p)
            new_board=list(new_board)
            na=new_board[:posi_0:]
            nb=new_board[posi_0+1::]
            nc=[new_board[posi_0]]
            new_board=na+nb+nc
            new_board=np.array(new_board[::-1])
            if np.sum(new_board!=n_b) != 0:
                li.append(new_board)
        return li

xxx200xxxx: HW12
testfuncscerrstu_stdoutstu_kept
test_get_score1.0
[0, 120]
test_get_time_cap1.0
[56, 56, 56, 56, 45, 45, 45]
test_rotate_right1.0
[array([[0, 1],
       [0, 2],
       [5, 3],
       [0, 4]]),
 array([[1, 0],
       [2, 0],
       [3, 5],
       [4, 0]])]
test_rotate_left1.0
[array([[4, 0],
       [3, 5],
       [2, 0],
       [1, 0]]),
 array([[0, 4],
       [5, 3],
       [0, 2],
       [0, 1]])]
test_animate_drop_11.0
[[], [array([[0, 2, 2, 2],
       [1, 2, 1, 1]])],
 [array([[0, 1, 5, 5, 0, 0, 0, 0],
       [0, 1, 1, 5, 5, 0, 0, 0],
       [0, 2, 2, 2, 5, 2, 2, 2],
       [3, 3, 3, 3, 0, 4, 4, 4]])]]
test_animate_drop_21.0
[[array([[2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 0, 0],
       [0, 0, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 0, 0, 0],
       [2, 2, 2, 0, 8, 0],
       [1, 1, 2, 8, 8, 0],
       [1, 1, 2, 0, 8, 0]])],
 [array([[0, 2, 2, 2, 0, 0],
       [0, 0, 0, 2, 0, 0],
       [0, 0, 0, 2, 8, 0],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]])],
 [],
 [array([[0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 0, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 0],
       [1, 1, 0, 0, 8, 0]]),
  array([[0, 0, 0, 0, 0, 0],
       [0, 0, 0, 2, 2, 2],
       [0, 0, 0, 0, 8, 2],
       [1, 1, 0, 8, 8, 2],
       [1, 1, 0, 0, 8, 0]])]]
test_animate_drop_30.0
[[array([[1, 1, 2, 2],
       [1, 1, 0, 0]]), array([[1, 1, 0, 0],
       [1, 1, 2, 2]])],
 [array([[0, 2, 2, 0],
       [1, 1, 2, 0],
       [1, 2, 2, 0],
       [1, 1, 0, 1],
       [1, 1, 1, 0]])],
 [array([[0, 0, 2, 0],
       [1, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])],
 [array([[0, 1, 2, 0],
       [1, 0, 2, 0],
       [1, 0, 2, 0],
       [1, 2, 2, 1],
       [1, 1, 1, 0]])]]
test_animate_clear_10.0
[[array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]])],
 [array([[0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [1, 0, 5, 4],
       [1, 0, 2, 4]])],
 [array([[0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4],
       [0, 0, 0, 0]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 5, 5, 4]])],
 [array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 2, 2, 4]])]]
test_animate_clear_21.0
[[],
 [array([[1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 0, 0],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [0, 0, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]]),
  array([[0, 0, 0, 0],
       [0, 0, 0, 0],
       [0, 0, 0, 0],
       [1, 2, 0, 0],
       [1, 0, 2, 4],
       [0, 0, 1, 1]])]]
test_animate_clear_31.0
[[]]
bytecount: {'code': 1250, 'const': 298, 'code+const': 1548}
check_import({'allowable': ['numpy']}): none
check_fcall({'prohibited': ['map']}) deep: none
check_mcall({'prohibited': ['not-numpy-101...']}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: none
check_loop({'comprehension': True}) in [get_score, get_time_cap, rotate_right, rotate_left, animate_drop, animate_clear] deep: [[], [], [], [], [('For', 10)], [('While', 20)]]
import numpy as np
def get_score(board):
  r,c = board.shape
  a = board
  b = a > 0
  d = np.sum(b,axis=1)
  s = d == c
  ss = np.sum(s)
  return ss*40
def get_time_cap(board, time_caps):
  l = len(time_caps)
  m = np.arange(1,l+1)
  r,c = board.shape
  a = board.reshape((l,c*(int(r/l))))
  b = np.sum(a,axis=1)
  b = b >0
  b = np.array([b])
  b = np.sum(b,axis=0)
  m = np.array([m])
  k = b*m
  k = k[0<k]
  if len(k) == 0:
    return time_caps[-1]
  return time_caps[k[0]-1]
def rotate_right(shape):
  a = np.array(shape)
  return a.T[:,::-1]
def rotate_left(shape):
  a = np.array(shape)
  a = a[:,::-1]
  return a.T
def animate_drop(board, shape, c):
  ans = []
  col = c
  new_board = np.array(board)
  new_shape = np.array(shape)
  rb,cb = new_board.shape
  rs,cs = new_shape.shape
  ns = np.array(shape)
  for i in range(rb):
    nb = np.array(board)
    a = np.zeros((rb,cb))
    if rs+i > rb:
      return ans
    else:
      obc = new_board[i:rs+i,col:cs+col]
      a[i:rs+i,col:cs+col:] += ns
      nb += np.array(a,int)
      nbc = nb[i:rs+i,col:cs+col:]
      obnbc = obc == nbc
      nsnbc = ns == nbc
      check = obnbc | nsnbc
      ccheck = np.sum(check)
      if ccheck == int(rs)*int(cs):
        ans.append(np.array(nb,int))
      else:
        return ans
  return ans
def animate_clear(board):
  ans = []
  new_board = np.array(board)
  r,c = new_board.shape
  a = new_board > 0
  a = np.sum(a,axis = 1)
  b = np.arange(0,r)
  a = a == c
  aa = a*b
  aa = aa[a>0]
  if len(aa) != 0:
    nb = np.array(board)
    nb[aa,:] = 0
    onb = np.array(nb)
    f = np.array(nb)
    ans.append(f)
    i = 1
    counter = 1
    while True:
        if list(nb[-i]) == [0]*c and list(nb[:-i].reshape(nb[:-i].shape[0]*nb[:-i].shape[1])) != [0]*c*(nb[:-i].shape[0]):
          if i != 1:
            nb = np.array([nb[-i]]+list(nb[:-i])+list(nb[-i+1:]))
          else:
            nb = np.array([nb[-i]]+list(nb[:-i]))
          ans.append(nb)
          i -= 1
        elif list(nb[:-i].reshape(nb[:-i].shape[0]*nb[:-i].shape[1])) == [0]*c*(nb[:-i].shape[0]):
            break
        if c == r:
            break
        i += 1 
        counter += 1
  else:
      return []
  return ans