-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTEP_Histogram.py
More file actions
42 lines (30 loc) · 801 Bytes
/
Copy pathTEP_Histogram.py
File metadata and controls
42 lines (30 loc) · 801 Bytes
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
#Topicos especiais em programacao - DCC - UFRJ
#Assignment 1 - Histogram
#Allan Monteiro David
import sys
import math
stepSize = 100;
minPlotNum = 50;
maxPlotNum = 650;
resultArray = {};
inputArray = [ (60, 350), (30, 150), (50, 200), (55, 650), (280, 320), (400, 600), (30, 510), (100, 500), (50, 450) ]
for player in inputArray:
start = player[0];
end = player[1];
if start < minPlotNum:
start = minPlotNum;
if end > maxPlotNum:
end = maxPlotNum;
i = (start - minPlotNum)/stepSize;
i = math.ceil(i);
x = stepSize*i + minPlotNum;
i = (end - minPlotNum)/stepSize;
i = math.floor(i);
finalX = stepSize*i + minPlotNum;
while x <= finalX:
if not x in resultArray:
resultArray[x] = 0;
resultArray[x] += 1;
x += stepSize;
for item in resultArray.items():
print(item);