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 |
Tags
- github
- 우분투
- 자연어처리
- 프로그래머스
- 파이썬
- Docker
- 프로그래머스 파이썬
- leetcode
- AI 경진대회
- Real or Not? NLP with Disaster Tweets
- Kaggle
- 백준
- 편스토랑
- 캐치카페
- gs25
- SW Expert Academy
- Git
- PYTHON
- ChatGPT
- dacon
- 맥북
- Baekjoon
- hackerrank
- ubuntu
- 코로나19
- 편스토랑 우승상품
- 데이콘
- 더현대서울 맛집
- programmers
- 금융문자분석경진대회
Archives
- Today
- Total
솜씨좋은장씨
[BaekJoon] 25325번 : 학생 인기도 측정 (Python) 본문
728x90
반응형
![](http://t1.daumcdn.net/tistory_admin/static/images/xBoxReplace_250.png)
코딩 1일 1문제! 오늘의 문제는 백준의 학생 인기도 측정 입니다.
25325번: 학생 인기도 측정
학생 이름이 공백으로 구분된 문자열 A가 주어진다. 문자열 A에는 중복된 학생 이름이 존재하지 않는다. 학생 이름은 알파벳 소문자로 이루어져 있다. 각 학생이 좋아하는 학생의 학생 이름 목록
www.acmicpc.net
👨🏻💻 코드 ( 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
)
GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07
1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.
github.com
'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 |