Maria plays college basketball and wants to go pro. Each season she maintains a record of her play. She tabulates the number of times she breaks her season record for most points and least points in a game. Points scored in the first game establish her record for the season, and she begins counting from there.
scores = [12, 24, 10, 24]
Scores are in the same order as the games played. She tabulates her results as follows:
Count
Game Score Minimum Maximum Min Max
0 12 12 12 0 0
1 24 12 24 0 1
2 10 10 24 1 1
3 24 10 24 1 1
Given the scores for a season, determine the number of times Maria breaks her records for most and least points scored during the season.
Complete the breakingRecords function in the editor below.
breakingRecords has the following parameter(s):
The first line contains an integer n, the number of games.
The second line contains n space-separated integers describing the respective values of score(0), score(1), ... score(n-1).
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'breakingRecords' function below.
#
# The function is expected to return an INTEGER_ARRAY.
# The function accepts INTEGER_ARRAY scores as parameter.
#
def breakingRecords(scores):
# this is my code :)
result = [0, 0]
best = scores[0]
worst = scores[0]
for i in range(len(scores)):
if scores[i] < worst:
worst = scores[i]
result[1] += 1
elif scores[i] > best:
best = scores[i]
result[0] += 1
return result
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
n = int(input().strip())
scores = list(map(int, input().rstrip().split()))
result = breakingRecords(scores)
fptr.write(' '.join(map(str, result)))
fptr.write('\n')
fptr.close()
농구 점수가 정수 리스트로 주어질 때, 최고 기록과 최저 기록이 갱신되는 횟수를 return하는 문제다.