-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathage.py
82 lines (65 loc) · 2.24 KB
/
age.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
points = [] # formatted as [[x,y], [x,y], [x,y]]
xValues = [16, 18, 20, 22, 25, 28, 30, 35, 40, 45, 50, 60, 70] # values to get y values for
samplePoints = [[16, 15], [18, 17], [20, 18], [22, 19], [25, 21], [28, 23], [30, 25], [35, 28], [40, 30], [45, 32], [50, 35], [60, 45], [70, 55]]
def getValues():
print("Please provide the lowest non-creepy dateable age for someone of age <x>:")
for value in xValues:
points.append([value, int(input(str(value) + " > "))])
return
# getValues()
# print(points)
def plotPoints(toPlot):
maxX = 0
maxY = 0
minX = 10000000
minY = 10000000
for point in toPlot:
if point[0] > maxX:
maxX = point[0] + 1
if point[1] > maxY:
maxY = point[1] + 1
if point[0] < minX:
minX = point[0] - 1
if point[1] < minY:
minY = point[1] - 1
yAxisLabelLength = 0
dummyMaxY = maxY
while dummyMaxY >= 1:
yAxisLabelLength += 1
dummyMaxY /= 10
for y in reversed(range(minY,maxY)):
thisYLabelLength = 0
dummyY = y
while dummyY >= 1:
thisYLabelLength += 1
dummyY /= 10
line = ""
for i in range(0,yAxisLabelLength-thisYLabelLength):
line+=" "
line += str(y) + "|"
for x in range(minX, maxX):
thisPointChar = " "
for point in toPlot:
if point[0] == x and y < point[1]:
thisPointChar = "||"
if point[1] == y and x < point[0]:
thisPointChar = "=="
if point[0] == x and point[1] == y:
thisPointChar = "[]"
line+=thisPointChar
print(line)
bottomBorder = ""
for i in range(0,yAxisLabelLength):
bottomBorder += " "
bottomBorder += "+"
while len(bottomBorder) < ((maxX-minX)*2) + yAxisLabelLength + 1:
bottomBorder+="-"
print(bottomBorder)
xAxisLabel = ""
for i in range(0,yAxisLabelLength):
xAxisLabel += " "
xAxisLabel+=" "
while len(xAxisLabel) < ((maxX-minX)*2) + yAxisLabelLength + 1:
xAxisLabel+=str(int(((len(xAxisLabel)-3)/2)+minX)) + " "
print(xAxisLabel)
plotPoints(samplePoints)