We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 734bea8 commit a0392d8Copy full SHA for a0392d8
src/racingcar/main.py
@@ -2,6 +2,11 @@
2
3
4
def main():
5
+ """
6
+ 프로그램을 실행하고, 자동차 경주의 시뮬레이션을 수행하는 함수
7
+ 사용자로부터 자동차 이름과 시도 횟수를 입력받고, 각 시도마다
8
+ 경주를 진행하여 최종 우승자를 출력.
9
10
print("프로그램이 시작되었습니다.")
11
12
car_names = input("경주할 자동차 이름을 입력하세요.(이름은 쉼표로 구분)\n")
@@ -27,11 +32,18 @@ def main():
27
32
print_winner(cars, car_positions)
28
33
29
34
def movement(cars, car_positions):
35
36
+ 각 자동차가 0에서 9 사이의 랜덤 숫자를 생성하여,
37
+ 4 이상의 숫자가 나오면 해당 자동차의 위치를 1 증가시키는 함수
38
30
39
for car in cars :
31
40
if random.randint(0,9) >= 4 :
41
car_positions[car] += 1
42
43
def get_winner(cars, car_positions):
44
45
+ 경주에서 우승한 자동차를 구하는 함수입니다.
46
47
max_value = max(car_positions.values())
48
return [car for car in cars if car_positions[car] == max_value]
49
0 commit comments