-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathnoti.py
48 lines (39 loc) · 1.63 KB
/
noti.py
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
from collections import defaultdict
# 최상위 디렉터리 경로
base_dir = './' # 실제 디렉터리 경로로 바꾸세요
def count_updates_per_user(weeks):
# 사용자별 문제 업데이트 수를 저장할 딕셔너리
user_problem_count = defaultdict(lambda: defaultdict(int))
for week in weeks:
week_dir = os.path.join(base_dir, week)
if os.path.exists(week_dir):
print(f"Processing {week_dir}")
for problem in os.listdir(week_dir):
problem_dir = os.path.join(week_dir, problem)
if os.path.isdir(problem_dir):
for file in os.listdir(problem_dir):
username = file.split('.')[0] # 파일 이름에서 사용자 이름 추출
user_problem_count[week][username] += 1
return user_problem_count
def print_user_updates(user_problem_count):
for week, users in user_problem_count.items():
print(f"\n{week}:")
print(f"{'User':<20}{'Problems Solved':<15}")
print('-' * 35)
for user, count in users.items():
if user == '':
continue
print(f"{user:<20}{count:<15}")
print('-' * 35)
def main():
weeks = input("보고싶은 주차를 입력하세요 (예: 1,2,3), (전체: *): ")
if weeks == '*':
week_list = [f'week-0{i}' for i in range(1, 9)]
else:
week_list = [f'week-0{week.strip()}' for week in weeks.split(',')]
print(week_list)
user_problem_count = count_updates_per_user(week_list)
print_user_updates(user_problem_count)
if __name__ == "__main__":
main()