Code Signal: Intro=55/60
by 습관중독import numpy as np
def differentSquares(matrix):
temp = []
#for i in range(0,2):
for i in range(len(matrix)-1):
#for j in range(0,2):
for j in range(len(matrix[0])-1):
row1 = []
row2 = []
row = []
row1 = matrix[i][j:j+2]
row2 = matrix[i+1][j:j+2]
#print("row1, row2",row1, row2)
row.append(row1)
row.append(row2)
#print("row", row)
temp.append(row)
#print(row)
#print("temp",temp,len(temp))
def unique_by_first(a):
tmp = a.reshape(a.shape[0], -1)
b = np.ascontiguousarray(tmp).view(np.dtype((np.void, tmp.dtype.itemsize * tmp.shape[1])))
_, idx = np.unique(b, return_index=True)
return a[idx].reshape(-1, *a.shape[1:])
TEMP = unique_by_first(np.array(temp))
return len(TEMP)
2/7 sample tests passed. Execution error on test 3: Something went wrong when executing the solution - program stopped unexpectedly with an error.
Traceback (most recent call last): main.py3 in the pre-written template, in getUserOutputs userOutput = _runoisas(testInputs[i]) main.py3 in the pre-written template, in _runoisas return differentSquares(*_fArgs_hvdwzcoriwob) main.py3 on line 27, in differentSquares TEMP = unique_by_first(np.array(temp)) main.py3 on line 22, in unique_by_first tmp = a.reshape(a.shape[0], -1) ValueError: cannot reshape array of size 0 into shape (0,newaxis)
Sample tests: 2/7
'코드 파이트(Code Signal)' 카테고리의 다른 글
Code Signal: Intro=57/60 (0) | 2020.02.23 |
---|---|
Code Signal: Intro=56/60 (0) | 2020.02.23 |
Code Signal: Intro=54/60 (0) | 2020.02.23 |
Code Signal: Intro=53/60 (0) | 2020.02.23 |
Code Signal: Intro=52/60 (0) | 2020.02.23 |
블로그의 정보
습관을 애정한다
습관중독