[프로그래머스] - 블록게임 (파이썬)
# 블록게임 import copy dx = [[0, 0, 0, 1, 1, 1], [0, 0, 1, 1, 2, 2]] dy = [[0, 1, 2, 0, 1, 2], [0, 1, 0, 1, 0, 1]] answer = 0 def solution(board): N = len(board) global answer while True: if not drop_block(board): break return answer def drop_block(arr): N = len(arr) for j in range(N): for i in range(N): if arr[i][j] == -1: continue if arr[i][j] != 0: break arr[i][j] = -1 return check(arr) def check..
2022. 2. 15.
[프로그래머스] - 길 찾기 게임 (파이썬)
import sys sys.setrecursionlimit(10**3) class Node: def __init__(self, index, x, y): self.index = index self.x = x self.y = y self.left = None self.right = None class Tree: def __init__(self, index, x, y): self.head = Node(index, x, y) def insert(self, index, x, y): curr = self.head while True: if curr.x > x: if curr.left == None: curr.left = Node(index, x, y) break else: curr = curr.left else: ..
2022. 2. 15.