본문 바로가기

list3

백준 1475 - 방 번호 (Python) 코드 import math from sys import stdin N = list(map(int, stdin.readline().rstrip())) # 1 count = [0 for _ in range(10)] # 2 for i in N: # 3 count[i] += 1 if max(count) == count[6] or max(count) == count[9]: # 4 six_nine = math.ceil((count[6]+count[9])/2) count[6] = six_nine count[9] = six_nine print(max(count)) # 5 풀이 0부터 9까지의 수가 한 세트이므로, 각 숫자들의 개수를 카운팅 했을 때 가장 큰 값이 정답이 된다. #1: 방번호의 각 숫자들로 list 생성.. 2022. 5. 30.
프로그래머스 - 신고 결과 받기 (Python) (2022 KAKAO BLIND RECRUITMENT) 코드 def solution(id_list, report, k): answer = [] block_id = [] set_report = set(report) # 1 report_cnt = {id: 0 for id in id_list} # 2 mail_cnts = {id: 0 for id in id_list} # 3 for id in set_report: # 4 report_cnt[id.split()[1]] += 1 for i in report_cnt: # 5 if report_cnt.get(i) >= k: block_id.append(i) for i in set_report: # 6 if i.split()[1] in block_id: mail_cnts[i.split()[0]] += 1 answer = l.. 2022. 5. 22.
백준 1157 - 단어공부 (Python) 문제 알파벳 대소문자로 된 단어가 주어지면, 이 단어에서 가장 많이 사용된 알파벳이 무엇인지 알아내는 프로그램을 작성하시오. 단, 대문자와 소문자를 구분하지 않는다. 입력 첫째 줄에 알파벳 대소문자로 이루어진 단어가 주어진다. 주어지는 단어의 길이는 1,000,000을 넘지 않는다. 출력 첫째 줄에 이 단어에서 가장 많이 사용된 알파벳을 대문자로 출력한다. 단, 가장 많이 사용된 알파벳이 여러 개 존재하는 경우에는 ?를 출력한다. 풀이 # 단어를 입력받고 대문자로 변환한다. word = input() word = word.upper() # 각 alphabet의 아스키코드를 인덱스로 갖는 list를 생성한다. alphabet = [0 for _ in range(91)] # 문자열 i가 포함될 경우 요소를 .. 2022. 5. 2.