-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathbreaking-best-and-wrost-records.py
81 lines (56 loc) · 2.25 KB
/
breaking-best-and-wrost-records.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
'''
problem--
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.
For example, assume her scores for the season are represented in the array scores=[12,24,10,24]. Scores are in the same order as the games played. She would tabulate 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 Maria's scores for a season, find and print the number of times she breaks her records for most and least points scored during the season.
Function Description--
Complete the breakingRecords function in the editor below. It must return an integer array containing the numbers of times she broke her records. Index 0 is for breaking most points records, and index 1 is for breaking least points records.
breakingRecords has the following parameter(s):
scores: an array of integers
Input Format--
The first line contains an integer , the number of games.
The second line contains space-separated integers describing the respective values of score0,score1,...,scoren-1.
Constraints--
1<=n<=1000
0<=scores[i]<=10^8
Output Format--
Print two space-seperated integers describing the respective numbers of times her best (highest) score increased and her worst (lowest) score decreased.
Sample Input 0--
9
10 5 20 20 4 5 2 25 1
Sample Output 0--
2 4
'''
#code here
#!/bin/python3
import math
import os
import random
import re
import sys
def breakingRecords(scores):
most=least=scores[0]
mt=0
lt=0
for i in scores:
if i>most:
most=i
mt+=1
if i<least:
least=i
lt+=1
return [mt,lt]
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
n = int(input())
scores = list(map(int, input().rstrip().split()))
result = breakingRecords(scores)
fptr.write(' '.join(map(str, result)))
fptr.write('\n')
fptr.close()