diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..c2a1e55 Binary files /dev/null and b/.DS_Store differ diff --git a/Minseo-JO/.DS_Store b/Minseo-JO/.DS_Store new file mode 100644 index 0000000..611df84 Binary files /dev/null and b/Minseo-JO/.DS_Store differ diff --git a/Minseo-JO/Level1/.DS_Store b/Minseo-JO/Level1/.DS_Store new file mode 100644 index 0000000..4bd0446 Binary files /dev/null and b/Minseo-JO/Level1/.DS_Store differ diff --git "a/Minseo-JO/Level1/x\353\247\214\355\201\274 \352\260\204\352\262\251\354\235\264 \354\236\210\353\212\224 n\352\260\234\354\235\230\354\210\253\354\236\220.py" "b/Minseo-JO/Level1/x\353\247\214\355\201\274 \352\260\204\352\262\251\354\235\264 \354\236\210\353\212\224 n\352\260\234\354\235\230\354\210\253\354\236\220.py" new file mode 100644 index 0000000..095448e --- /dev/null +++ "b/Minseo-JO/Level1/x\353\247\214\355\201\274 \352\260\204\352\262\251\354\235\264 \354\236\210\353\212\224 n\352\260\234\354\235\230\354\210\253\354\236\220.py" @@ -0,0 +1,6 @@ +def solution(x, n): + answer = [] + for i in range (n): + num = x * (i+1) + answer.append(num) + return answer \ No newline at end of file diff --git "a/Minseo-JO/Level1/\353\202\230\353\250\270\354\247\200\352\260\200 1\354\235\264 \353\220\230\353\212\224 \354\210\230 \354\260\276\352\270\260.py" "b/Minseo-JO/Level1/\353\202\230\353\250\270\354\247\200\352\260\200 1\354\235\264 \353\220\230\353\212\224 \354\210\230 \354\260\276\352\270\260.py" new file mode 100644 index 0000000..64f5a15 --- /dev/null +++ "b/Minseo-JO/Level1/\353\202\230\353\250\270\354\247\200\352\260\200 1\354\235\264 \353\220\230\353\212\224 \354\210\230 \354\260\276\352\270\260.py" @@ -0,0 +1,9 @@ +def solution(n): + answer = 1 + n = float(n) + while True: + if n % answer == 1: + break + else: + answer += 1 + return answer \ No newline at end of file diff --git "a/Minseo-JO/Level1/\353\213\254\353\246\254\352\270\260 \352\262\275\354\243\274.py" "b/Minseo-JO/Level1/\353\213\254\353\246\254\352\270\260 \352\262\275\354\243\274.py" new file mode 100644 index 0000000..b5f5342 --- /dev/null +++ "b/Minseo-JO/Level1/\353\213\254\353\246\254\352\270\260 \352\262\275\354\243\274.py" @@ -0,0 +1,20 @@ +def solution(players, callings): + # {등수 : 선수} , {선수: 등수} 딕셔너리 생성 + idx = {i : player for i,player in enumerate(players)} + p = {player : i for i,player in enumerate(players)} + + for i in callings : + current_rank = p[i] + foward_rank = current_rank-1 + foward_player = idx[foward_rank] + + #player swap + idx[current_rank] = foward_player + idx[foward_rank] = i + + # rank swap + p[i] = foward_rank + p[foward_player] = current_rank + + + return list(idx.values()) \ No newline at end of file diff --git "a/Minseo-JO/Level1/\353\254\270\354\236\220\354\227\264 \353\202\264 p\354\231\200 y\354\235\230 \352\260\234\354\210\230.py" "b/Minseo-JO/Level1/\353\254\270\354\236\220\354\227\264 \353\202\264 p\354\231\200 y\354\235\230 \352\260\234\354\210\230.py" new file mode 100644 index 0000000..55edb73 --- /dev/null +++ "b/Minseo-JO/Level1/\353\254\270\354\236\220\354\227\264 \353\202\264 p\354\231\200 y\354\235\230 \352\260\234\354\210\230.py" @@ -0,0 +1,5 @@ +def solution(s): + s = s.lower() + if s.count("p") == s.count("y") : + return True + return False diff --git a/Minseo-JO/N-Queen.py b/Minseo-JO/N-Queen.py new file mode 100644 index 0000000..36a06ad --- /dev/null +++ b/Minseo-JO/N-Queen.py @@ -0,0 +1,37 @@ + +#n : queen개수, nxn 체스판 +n = int(input()) + +ans = 0 +row = [0] * n #체스판 초기화 +answer_10 = [] # 10번쨰 해를 출력하기 위한 리스트 +total_nodes = 0 # 총 노드의 수를 세기 위한 변수 + + +def n_queens(x) : + global ans, total_nodes, answer_10 # 해의 총 개수를 세기 위해 전역변수 + + if x == n : # 마지막 행(= 마지막 queen)까지 위치시켰다면 해답을 찾은 것 + ans += 1 + if ans == 10: # 10번째 해를 출력하기 위해 count가 10에 도달했을 때 row copy + answer_10 = row.copy() + return + + else : # 아직 queen을 다 위치시키지 못한 것이기 x번째 queen을 n개의 열에 한번씩 위치시키면서 유망성 검사 + for i in range (n) : + total_nodes += 1 # 하나의 열에 둘 때마다 node는 1씩 늘어남 + row[x] = i # x번째 queen을 i번째 열에 위치시키는 것 = (x, i)에 위치 시키는 것 + if promising(x) : # 유망하다면 다음 queen에 대해서 유망성 검사 + n_queens(x+1) + +def promising(x) : + for i in range(x) : # 0부터 x-1행(queen)까지 현재 queen(x)과 2가지 조건을 만족하는지 검사 + if (row[x] == row[i]) or (abs(row[x] - row[i]) == abs(x-i)): # 같은열, 같은 대각선에 위치한다면 false + return False + return True + + +n_queens(0) #0번째 queen부터 시작 +print('전체 해의 개수 :', ans) +print('10번째 해 :', answer_10) +print('상태 공간 트리의 모든 노드의 수 :', total_nodes) diff --git "a/Minseo-JO/\354\203\201\355\225\230\354\242\214\354\232\260.py" "b/Minseo-JO/\354\203\201\355\225\230\354\242\214\354\232\260.py" new file mode 100644 index 0000000..0382185 --- /dev/null +++ "b/Minseo-JO/\354\203\201\355\225\230\354\242\214\354\232\260.py" @@ -0,0 +1,22 @@ +n = int(input()) +x, y =1,1 + +plans = input().split() + +#상,하,좌,우 이동방향 +dx = [0,0,-1,1] +dy = [-1,1,0,0] +move_types = ['L', 'R', 'U', 'D'] + +for plan in plans: + # 이동 후 좌표 + for i in range(len(move_types)): + if plan == move_types[i] : + nx = x + dx[i] + ny = y + dy[i] + #범위를 벗어나는 경우 + if nx < 1 or ny < 1 or nx > n or ny > n : + continue + x, y =nx, ny + +print(x,y) diff --git "a/Minseo-JO/\354\235\214\353\243\214\354\210\230\354\226\274\353\240\244\353\250\271\352\270\260.py" "b/Minseo-JO/\354\235\214\353\243\214\354\210\230\354\226\274\353\240\244\353\250\271\352\270\260.py" new file mode 100644 index 0000000..941b488 --- /dev/null +++ "b/Minseo-JO/\354\235\214\353\243\214\354\210\230\354\226\274\353\240\244\353\250\271\352\270\260.py" @@ -0,0 +1,39 @@ +n, m = map(int,input().split()) + +graph = [] + +for i in range (n): + graph.append(list(map(int, input()))) + +def dfs(x,y): + # nxm graph의 범위를 넘어가면 false + # 인덱스는 0부터 시작하니까 x,y가 n,m인 경우에도 false + if x <= -1 or x >=n or y <= -1 or y >=m : + return False + + + # DFS로 방문한 노드와 연결된 모든 노드까지 한번에 방문하여 표시해주기 + if graph[x][y] == 0 : + # 방문 표시 + graph[x][y] = 1 + #현재 위치에서 상,하,좌,우 dfs 재귀 호출 + dfs(x-1, y) + dfs(x, y-1) + dfs(x+1, y) + dfs(x, y+1) + return True #자기 자신은 true return + return False # graph[x][y] == 1인 경우 이미 방문한 것이니까 False + + +result = 0 +for i in range (n): + for j in range (m): + if dfs(i,j): + result +=1 + +print(result) + + + + + diff --git "a/Minseo-JO/\355\201\254\353\240\210\354\235\270\354\235\270\355\230\225\353\275\221\352\270\260.py" "b/Minseo-JO/\355\201\254\353\240\210\354\235\270\354\235\270\355\230\225\353\275\221\352\270\260.py" new file mode 100644 index 0000000..3115681 --- /dev/null +++ "b/Minseo-JO/\355\201\254\353\240\210\354\235\270\354\235\270\355\230\225\353\275\221\352\270\260.py" @@ -0,0 +1,33 @@ +import numpy as np + +def solution(board, moves): + basket = [] # out of range 에러 막기 위해 basket에 0 넣어주기 + cnt = 0 + + # numpy array로 변환해서 전치행렬로 변환하기 + board = np.array(board) + board = board.T + + #moves 도 numpy 변환해서 인덱스로 사용할 수 있도록 + moves = np.array(moves) + moves = moves -1 + + for i in moves: + for j in range(len(board[0])): + # board에 인형이 없다면 pass + if board[i][j] == 0 : + continue + else : #인형이 있다면 basket에 넣어주고 0으로 바꿔줘야함 + basket.append(board[i][j]) + board[i][j] = 0 + break # 더이상 캐릭터 접근에 대한 루프(j) 돌면 안됨 + + # moves 루프(i) 돌다가 같은 캐릭터 만나면 두개 모두 pop + if (len(basket) >=2 ) and (basket[-1] == basket[-2]) : # out of range 에러 주의 + basket.pop() + basket.pop() + # pop 된 개수 세주기 + cnt += 2 + else : + continue + return cnt \ No newline at end of file