-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBreaking the Records.py
92 lines (61 loc) · 2.35 KB
/
Breaking the 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
81
82
83
84
85
86
87
88
89
90
'''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 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
is for breaking most points records, and index
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
.
Constraints
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
'''
#!/bin/python3
import math
import os
import random
import re
import sys
# Complete the breakingRecords function below.
def breakingRecords(scores):
worst = scores[0]
best = scores[0]
cmin = 0
cmax = 0
if(len(scores)==1):
return [0,0]
for i in range(1,len(scores)):
if(scores[i]<worst):
cmin += 1
worst = scores[i]
elif(scores[i]>best):
cmax += 1
best = scores[i]
arr = [cmax,cmin]
return(arr)
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()