본문 바로가기

분류 전체보기

(256)
백준) 숫자판 점프 https://www.acmicpc.net/problem/2210 2210번: 숫자판 점프 111111, 111112, 111121, 111211, 111212, 112111, 112121, 121111, 121112, 121211, 121212, 211111, 211121, 212111, 212121 이 가능한 경우들이다. www.acmicpc.net arr = [] numbers= [] for i in range(5): a = list(map(str,input().split())) arr.append(a) dx = [0,0,1,-1] dy = [-1,1,0,0] def dfs(x,y,string): if len(string) == 6: if string not in numbers: numbers.ap..
프로그래머스) 둘만의 암호 https://school.programmers.co.kr/learn/courses/30/lessons/155652 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제가 조금 불친절하지만 이해하는데 그닥 어렵지 않았다. 문자열 s에 한글자씩 Index만큼 +를 한다. 만일 플러스 도중 skip에 있는 문자를 만나면 그 단어는 건너뛰게 된다. 만일 s ='a', skip='b' index=1 이라 했을 때, a의 다음 값은 b가 된다. 하지만 b는 skip에 있는 값이므로 pass. 즉 answer 는 c가 된다. 이런 문제는 상당히 간단하다. 문자를 아스..
프로그래머스)무인도 여행 https://school.programmers.co.kr/learn/courses/30/lessons/154540 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 처음 제출한 코드 def solution(maps): answer = [] visit = [[False for _ in range(len(maps[0]))] for _ in range(len(maps))] answer = [] dx = [1,-1,0,0] dy = [0,0,-1,1] def dfs(x,y,cnt): visit[x][y] = True for i in range(4): nx = x ..
백준)Hello World! https://www.acmicpc.net/problem/2557 2557번: Hello World Hello World!를 출력하시오. www.acmicpc.net print('Hello World')
백준)분해합 https://www.acmicpc.net/problem/2231 a = int(input()) answer = 0 for i in range(1,a): b = sum(map(int, str(i))) if i +b == a: answer = i break print(answer)
백준)블랙잭 https://www.acmicpc.net/problem/2798 2798번: 블랙잭 첫째 줄에 카드의 개수 N(3 ≤ N ≤ 100)과 M(10 ≤ M ≤ 300,000)이 주어진다. 둘째 줄에는 카드에 쓰여 있는 수가 주어지며, 이 값은 100,000을 넘지 않는 양의 정수이다. 합이 M을 넘지 않는 카드 3장 www.acmicpc.net from itertools import combinations a,b = map(int,input().split()) c = list(map(int,input().split())) arr = [] for i in combinations(c,3): arr.append(sum(i)) answer = 0 for i in arr: if i
프로그래머스)문자열 나누기 https://school.programmers.co.kr/learn/courses/30/lessons/140108 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 이 문제는 구현문제로 보인다. 풀이는 매우 간단했고, 아이디어 또한 금방 떠올랐는데 문제가 있었다. 처음 제출한 코드를 보자. def solution(s): answer = 0 same = 0 diff = 0 length = len(s) idx = 0 while s: print(s) if s == '': answer+=1 break if idx >= len(s): answer += 1 break..
백준)영역구하기 https://www.acmicpc.net/problem/2583 2583번: 영역 구하기 첫째 줄에 M과 N, 그리고 K가 빈칸을 사이에 두고 차례로 주어진다. M, N, K는 모두 100 이하의 자연수이다. 둘째 줄부터 K개의 줄에는 한 줄에 하나씩 직사각형의 왼쪽 아래 꼭짓점의 x, y좌표값과 오 www.acmicpc.net import sys sys.setrecursionlimit(10000) def dfs(x,y,count): arr[x][y] = 1 for i in range(4): nx = dx[i] + x ny = dy[i] + y if (0