본문 바로가기
반응형

코딩테스트29

백준 3009 번 파이썬 풀이 안녕하세요 백준 3009 번 파이썬 풀이 입니다 points = [] for i in range(3): x, y = map(int, input().split()) points.append((x, y)) x_coords = [point[0] for point in points] y_coords = [point[1] for point in points] for i in range(2): if x_coords.count(x_coords[i]) == 1: x = x_coords[i] if y_coords.count(y_coords[i]) == 1: y = y_coords[i] print(x, y) 위 코드에서는 입력으로 주어지는 세 점의 좌표를 튜플로 묶어서 리스트 points에 저장합니다. 이후에는 리스트 내.. 2023. 3. 26.
백준 10798번 파이썬 풀이 정답입니다 # 다섯 개의 문자열을 저장할 리스트를 생성합니다. words = [] # 다섯 줄에 걸쳐서 문자열을 입력받아 리스트에 저장합니다. for i in range(5): word = input().strip() # 문자열을 입력받고 양쪽 공백을 제거합니다. words.append(word) # 세로로 읽은 문자열을 저장할 변수를 생성합니다. result = "" # 다섯 개의 문자열 중 가장 긴 문자열의 길이를 구합니다. max_len = max(len(word) for word in words) # 가장 긴 문자열의 길이만큼 반복합니다. for i in range(max_len): # 다섯 개의 문자열을 세로로 읽어서 result에 추가합니다. for j in range(5): # i번째 위치에.. 2023. 3. 24.
백준 1157번 파이썬 풀이 우선 정답 word = input().lower() counts = [0] * 26 for c in word: if c.isalpha(): counts[ord(c) - ord('a')] += 1 max_count = max(counts) max_chars = [chr(i + ord('a')).upper() for i, count in enumerate(counts) if count == max_count] if len(max_chars) == 1: print(max_chars[0]) else: print('?') 설명을 주석으로 적었습니다. 추가 설명 2023. 3. 24.
백준 2444번 파이썬 풀이 n = int(input()) if n == 1: # N이 1인 경우 print('*') else: # N이 2 이상인 경우 for i in range(1, 2*n): # 총 2N-1 줄 출력 if i 2023. 3. 19.
반응형