https://velog.io/@klaus/파이썬Python-백준-2615번-오목
https://spare8433.tistory.com/183
http://ech97.tistory.com/entry/블록-이동하기-Python-정리-및-구현-카카오-기출-프로그래머스
board_size = 15 # 15 15 범위 설정
def __init__(self, board): #self:클래스 내부 instance variable 참조.
self.board = board
def is_invalid(self, x, y):
return (x < 0 or x >= board_size or y < 0 or y >= board_size)
#판 위에 있는지 화인
def set_stone(self, x, y, stone):
self.board[y][x] = stone
def get_xy(self, direction):
#direction으로 인덱스 입력 받고, 각 리스트에서 x,y 좌표추출
list_dx = [-1, 1, -1, 1, 0, 0, 1, -1]
list_dy = [0, 0, -1, 1, -1, 1, -1, 1] #0~7
return list_dx[direction], list_dy[direction]
def get_stone_count(self, x, y, stone, direction):
x1, y1 = x, y # 시작 지점 저장
cnt = 1
for i in range(2):
dx, dy = self.get_xy(direction * 2 + i) #direction 추출
x, y = x1, y1 # 좌표 초기화
while True:
x, y = x + dx, y + dy
if self.is_invalid(x, y) or self.board[y][x] != stone:
break;
else:
cnt += 1
return cnt
def open_three(self, x, y, stone, direction):
for i in range(2):
coord = self.find_empty_point(x, y, stone, direction * 2 + i)
if coord:
dx, dy = coord
self.set_stone(dx, dy, stone)
if 1 == self.open_four(dx, dy, stone, direction):
if not self.forbidden_point(dx, dy, stone):
self.set_stone(dx, dy, empty)
return True
self.set_stone(dx, dy, empty)
return False
#GOAT
https://blog.naver.com/dnpc7848/221506783416
https://velog.io/@cldhfleks2/java오목-금수-알고리즘
"4가지방향으로 열린 삼이 존재한다."