너무 쉬워서 별도 언급 X
def solution(board, h, w):
board_h = len(board)
board2 = {}
for i,row in enumerate(board):
current_floor = i
tmp_dic = {}
for j,color in enumerate(row):
tmp_dic[j] = color
board2[i] = tmp_dic
search_candidate = [
[h,w-1]
,[h,w+1]
,[h-1,w]
,[h+1,w]
]
search_result = []
current_color = board2[h][w]
for i in range(4):
try:
search_result.append(
board2[search_candidate[i][0]][search_candidate[i][1]]
)
except:
pass
print(search_result)
same_color_list = [ x for x in search_result if x == current_color]
print(same_color_list,current_color)
return len(same_color_list)