분류 전체보기
![[프로그래머스] 점 찍기 [python]](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fw8VfC%2FbtsczKqsVpF%2FsiIr2WPrByXUGzScMpTERk%2Fimg.png)
[프로그래머스] 점 찍기 [python]
문제 처음에 감이 안잡혀서, 힌트를 보았다,,, 원 안에 있는 점을 구하는 건데, 점은 k의 배수 또는 0 이어야 한다는 제약 조건이 있다. x^2 + y^2
![[프로그래머스] 숫자 카드 나누기 [python]](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbFc3SV%2FbtsbUP0Pn5l%2Fuj48mf7NLFVtPKD1KXZw7k%2Fimg.png)
[프로그래머스] 숫자 카드 나누기 [python]
문제 최대공약수를 구해서, 서로의 배열을 나눌 수 있는지 여부를 구하고 나눌 수 없다면, answer를 나눌 수 있다면, 0을 return 하는 문제이다. 최대공약수를 구할 때 나는 유클리드 호제법을 사용했다. 코드 def solution(arrayA, arrayB): answer = 0 if len(arrayA) == 1: if arrayA[0] == arrayB[0]: return 0 else: return max(arrayA[0], arrayB[0]) else: m1 = 0 m2 = 0 gcd1 = gcd(arrayA[0], arrayA[1]) gcd2 = gcd(arrayB[0], arrayB[1]) answer = max(m1,m2) for i in range(2, len(arrayA)): gc..
![[프로그래머스] 무인도 여행 [python]](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FocINq%2Fbtr7iKwKySm%2FM3rNbxdC4a8kr0k4Ewpk00%2Fimg.png)
[프로그래머스] 무인도 여행 [python]
문제 간단한 BFS 문제였다. X가 아닌 지점에서 BFS를 돌리고, 방문 여부를 체크한 후, X가 아닌 곧 중에 방문하지 않은 곳에서 또 다시 BFS를 돌리면 된다. 코드 def solution(maps): answer = [] visited = [[False] * len(maps[i]) for i in range(len(maps))] for i in range(len(maps)): for j in range(len(maps[i])): if visited[i][j] == False and maps[i][j] != "X": answer.append(bfs(visited,i,j,maps)) if len(answer) == 0: answer.append(-1) answer.sort() return answer..
![[프로그래머스] 거리두기 확인하기 [python]](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fuqg9b%2Fbtr6GVsT4n9%2F4vpiDpLWI4fovw5f75GeTk%2Fimg.png)
[프로그래머스] 거리두기 확인하기 [python]
문제 BFS로 문제를 풀었다,,실수가 많아서 오래 걸렸다,, 금방 풀줄 알았는데,, 코드 def solution(places): answer = [] for place in places: q = [] for i,p in enumerate(place): for j in range(len(place)): if p[j] == "P": q.append([i,j]) if len(q) == 0: answer.append(1) continue if bfs(place, q): answer.append(1) continue answer.append(0) return answer def bfs(graph, q): mX = [0,0,1,-1] mY = [1,-1,0,0] for c in q: queue = [[c[0], c..
![[프로그래머스] 택배상자 [python]](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FckWIi4%2Fbtr5QioK28N%2FaBdjhSrcH57mqLz1FiwCm0%2Fimg.png)
[프로그래머스] 택배상자 [python]
문제 문제를 이해하는 게 좀 어려울 뿐이지, 문제자체는 쉽다 stack을 사용해서 풀면된다. 코드 def solution(order): answer = 0 st = [] done = False num = 1 st.append(num) for i in order: while True: if st and i < st[-1]: done = True break if st and i == st[-1]: answer += 1 st.pop() break num += 1 st.append(num) if done: break return answer """ 보조 컨테이너 벨트는 앞뒤로 이동 가능, 맨 앞의 상자만 뺄 수 있음(스택) 택배상자는 순서대로 들어오고, 택배는 input order에 들어있음 순서가 맞는 택배를..