분류 전체보기
![퍼즐[백준1525] - python](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbUx9fi%2FbtrnCmtAZaq%2FZaakED58WqRDMbjKV1AYaK%2Fimg.png)
퍼즐[백준1525] - python
배열 자체를 bfs에 넣고 매번 꺼낸 배열을 string으로 변환해서 비교를 하려고 시도했었다가. 이건 아니다 싶어서 bfs에 문자열을 넣고 x,y의 좌표를 이용해서 배열에서 바꿔야 하는 0의 인덱스를 계산해서 다음 값과 바꿔주는 형식으로 시도했었다. 근데 이 방법은 메모리 부족으로 통과 하지 못했고. 결국 다른 분들의 코드를 참고했다. 정답코드 먼저 살펴보자 dx = [0, 0, 1, -1] dy = [1, -1, 0, 0] def bfs(): while q: now = q.popleft() if now == "123456789": return cntDict[now] pos = now.find("9") x = pos // 3 y = pos % 3 for i in range(4): nx = x + dx[..
![리모컨[백준-1107] - python](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FnewFR%2FbtrnHRlN4pj%2Fj3waFE9J1v6lZPCuUxn0Pk%2Fimg.png)
리모컨[백준-1107] - python
정답코드 먼저 살펴보자 def BOJ1107(): n = int(input()) m = int(input()) count = abs(100 - n) button = [True] * 10 if m != 0 : for errored in list(map(int, input().split())) : button[errored] = False for i in range(1000001) : listed_number = list(str(i)) listed_number_length = len(listed_number) flag = True for number in listed_number : if button[int(number)] == False : flag = False break if flag : count =..
![병든 나이트[백준 1783] - python](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FmM7AN%2FbtrnC13ZSh1%2F0zDuNkWUrjy4rZZ49c9LUk%2Fimg.png)
병든 나이트[백준 1783] - python
예전에 무진장 겁먹고 못풀었던 문제 정답코드 먼저 살펴보자 n,m = map(int, input().split()) if n == 1 : print(1) elif n == 2 : print(min((m + 1) // 2, 4)) else : if m < 7 : print(min(m, 4)) else : print(m - 2) 핵심은 1,2,3,4 조건의 경우 무조건 오른쪽으로 움직인다는 거다.(왼쪽으로는 돌아올수 없다.) 4번 다 완료하면 오른쪽으로 이동한 수는 6이 된다. 왠지 6이 기준점이 될것 같았다. n이 1이면 이동은 불가능해서 1 n이 2이면 최대 4의 경우이거나 m을 2로 나눈 경우중 최솟값의 가지수를 가지게 된다 n이 3이상이면 위로 혹은 아래로 이동하는 경우의 수는 제약을 받지 않으므로 ..
![컴퓨터는 어떻게 켜질까?[컴퓨터 부팅 과정]](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fb2ATAv%2FbtrnHSE87Wj%2FQSOLE5FYXpjx7ZDeMwARkk%2Fimg.png)
컴퓨터는 어떻게 켜질까?[컴퓨터 부팅 과정]
1. 전원이 들어오면 cpu는 ROM에 있는 BIOS 프로그램을 메모리에 올려 실행시킵니다. 2. BIOS(Basic Input Output System)은 POST(Power On Self Test)를 실행하여 필요 하드웨어에 이상이 없는지 체크합니다. 3. BIOS는 저장매체의 첫번째 섹터에 있는 MBR에 접근하여 부트 로더를 메모리에서 실행시킵니다. 4. 메모리에서는 부트 섹터에 접근하고 운영체제 이미지를 메모리에 올려 운영체제를 실행시킵니다. 1. 전원이 들어오면 cpu는 ROM에 있는 BIOS 프로그램을 메모리에 올려 실행시킵니다. 컴퓨터가 켜지면 power supply에 전원이 들어오고 메모리(ROM) 0번지 주소의 데이터를 읽습니다. ROM-BIOS에서 BIOS프로그램이 메모리로 올라갑니다...
![RGB거리[백준 1149] - python](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fbg0HZS%2FbtrnE9AtkoK%2FamX47U2jQPG4ZkCk5AVtl0%2Fimg.png)
RGB거리[백준 1149] - python
정답 코드 먼저 살펴보자 n = int(input()) cost = [] for _ in range(n) : cost.append(list(map(int, input().split()))) for i in range(1, len(cost)) : cost[i][0] = min(cost[i-1][1], cost[i-1][2]) + cost[i][0] cost[i][1] = min(cost[i-1][0], cost[i-1][2]) + cost[i][1] cost[i][2] = min(cost[i-1][0], cost[i-1][1]) + cost[i][2] print(min(cost[n-1][0], cost[n-1][1], cost[n-1][2])) 너무 어렵게 생각했었다. 각 라운드에 빨강, 파랑, 초록을 색..
![RGB거리2[백준 17404] - python](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FdAEWT6%2FbtrnCAMkgvk%2FHbnpfLPaMIXvWir0vRu9FK%2Fimg.png)
RGB거리2[백준 17404] - python
너무 어려웠다. 결국 다른 분들의 잘 짜신 코드를 참고했다. ㅠㅠ 정답코드 먼저 살펴보자 n = int(input()) cost = [] INF = 1e9 for _ in range(n): cost.append(list(map(int, input().split()))) result = INF for start_number in range(3) : dist = [[0] * 3 for _ in range(len(cost))] for i in range(3) : if i != start_number : dist[0][i] = INF else : dist[0][i] = cost[0][i] for i in range(1, len(cost)): dist[i][0] = min(dist[i-1][1], dist[i-1..
![숨바꼭질3[백준13549] - python](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fod1zH%2FbtrnCAZWN8l%2FSkvoZmdK4NZWK8xzGC5LEk%2Fimg.png)
숨바꼭질3[백준13549] - python
숨바꼭질 시리즈 3번째 문제다 정답 코드 먼저 살펴보자 from collections import deque n, k = map(int, input().split()) location = [-1] * 100001 time = 0 queue = deque() queue.append([n, time]) location[n] = 0 while queue : curr_n, curr_time = queue.popleft() next_n = curr_n * 2 if 0 3 -> 6 -> 12 ii) 4 -> 5 -> 6 -> 12 6에 접근을 하는 경우가 i)의 경우 1, ii)의 경우 2이다. 내 코드에서는 ii)의 경우가 먼저 6에 접근이 되었고 i)의 경우에서 6에 접근할때 기존 6에 업데이트를 해주어야 했다..
![숨바꼭질2[백준 12851] - python](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FHx7uP%2FbtrnJdhOoWm%2FfsDKK9qfnt2UccitESg7X1%2Fimg.png)
숨바꼭질2[백준 12851] - python
방문한 곳의 최소 시간과 방법의 수를 출력해주어야 한다. 각 지점마다 두개의 정보를 가지고 있어야 하므로 이차원 배열로 선언해 주었다. 정답 코드 먼저 살펴보자 n, k = map(int, input().split()) MAX_LENGTH = 100001 visited = [[-1, 0] for _ in range(MAX_LENGTH)] queue = [] queue.append(n) # 처음 방문한 곳은 방문정보와 방법의 수를 업데이트 visited[n][0] = 0 visited[n][1] = 1 while queue : x = queue.pop(0) for i in [x-1, x+1, x*2] : if 0
![깃헙 js 파일 다운로드 하기](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FbF7ngO%2Fbtrnfz8aoI1%2FWENlqEfbBYNxKtRqmHI5Hk%2Fimg.png)
깃헙 js 파일 다운로드 하기
가끔 깃헙에 있는 파일을 하나만 다운로드 받고 싶을때가 많다. 이번에 찾은 방법을 적어두려고 한다. 1. 깃헙 접속 2. 파일의 raw로 접근 3. terminal에서 wget (rawlink) 치고 실행 하면 다운받아진다!! wget(WebGet)은 리눅스의 기본 명령어다 웹 상의 파일을 다운로드 받을때 사용하는 다운로더 이다!! macos 에서 사용하기 위해서 이전에 brew install wget으로 설치를 진행해 주었다. brew는 macos용 패키지 관리도구이다!!(루비로 만들어졌다) ubuntu에는 비슷한 역할로 apt-get이 있다!
![최소공배수 [백준 1934] - python](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FVRtQB%2FbtrneuF5m9h%2FTYzSV6PLjbuvQPqrxU2l0K%2Fimg.png)
최소공배수 [백준 1934] - python
앞으로 글을 작성할때 근거를 같이 작성하려고 한다. 코드를 작성한 근거나, 자료구조를 선택한 근거, 어떤 논리를 적용한 근거... 너무 무지성으로 진행하고 있었지 않나 싶다. 개인적인 이야기는 각설하고 코드를 같이 살펴보자 def gcd(first, second) : array = [0] * (first + 1) for i in range(1, first+1) : if first % i == 0 : array[i] = 1 max_num = 0 for i in range(len(array)): if array[i] == 1 and second % i == 0: max_num = i return max_num t = int(input()) for _ in range(t) : a,b = map(int, inp..