Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |
Tags
- 자연어처리
- hackerrank
- 파이썬
- github
- SW Expert Academy
- 데이콘
- 캐치카페
- 맥북
- Baekjoon
- gs25
- 더현대서울 맛집
- Real or Not? NLP with Disaster Tweets
- 코로나19
- Git
- 편스토랑
- dacon
- Docker
- 프로그래머스 파이썬
- ubuntu
- PYTHON
- 우분투
- 백준
- 프로그래머스
- AI 경진대회
- 편스토랑 우승상품
- leetcode
- programmers
- Kaggle
- 금융문자분석경진대회
- ChatGPT
Archives
- Today
- Total
솜씨좋은장씨
[BaekJoon] 25325번 : 학생 인기도 측정 (Python) 본문
728x90
반응형
코딩 1일 1문제! 오늘의 문제는 백준의 학생 인기도 측정 입니다.
👨🏻💻 코드 ( Solution )
def make_popularity_dict(student_name_list):
popularity_dict = {}
for student_name in student_name_list:
popularity_dict[student_name] = 0
return popularity_dict
def measure_popularity(n_student_name_list, student_name_list):
popularity_dict = make_popularity_dict(
student_name_list=n_student_name_list
)
for student_name in student_name_list:
popularity_dict[student_name] += 1
return popularity_dict.items()
def sort_popularity_items(popularity_items):
return sorted(popularity_items, key=lambda x: -x[1])
def print_answer(popularity_items):
for item in popularity_items:
print(f"{item[0]} {item[1]}")
if __name__ == "__main__":
student_list = []
n = int(input())
n_student_name_list = input().split()
for _ in range(n):
student_names = input().split()
student_list += student_names
popularity_items = measure_popularity(
n_student_name_list=n_student_name_list,
student_name_list=student_list
)
sorted_items = sort_popularity_items(
popularity_items=popularity_items
)
print_answer(
popularity_items=sorted_items
)
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
[BaekJoon] 20953번 : 고고학자 예린 (Python) (0) | 2022.09.17 |
---|---|
[BaekJoon] 15702번 : 중간고사 채점 (Python) (0) | 2022.09.16 |
[BaekJoon] 25206번 : 너의 평점은 (Python) (0) | 2022.09.14 |
[BaekJoon] 20499번 : Darius님 한타 안 함? (Python) (0) | 2022.09.13 |
[BaekJoon] 5235번 : Even Sum More Than Odd Sum (Python) (0) | 2022.09.12 |
Comments