-
Notifications
You must be signed in to change notification settings - Fork 0
/
day14_scope.py
36 lines (29 loc) · 1.06 KB
/
day14_scope.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
class Difference:
"""
Task:
Complete the Difference class by writing the following:
- A class constructor that takes an array of integers as a parameter and
saves it to the `__elements` instance variable.
- A computeDifference method that finds the maximum absolute difference
between any 2 numbers in __elements and stores it in the
`maximumDifference` instance variable.
"""
def __init__(self, a):
self.__elements = a
maximumDifference = int()
def get_elements(self):
return self.__elements
def computeDifference(self):
array = self.get_elements()
for i in range(len(array)):
for j in range(len(array)):
if array[i] != array[j] and\
Difference.maximumDifference <= abs(array[i] - array[j]):
Difference.maximumDifference = abs(array[i] - array[j])
else: pass
# End of Difference class
_ = input()
a = [int(e) for e in input().split(' ')]
d = Difference(a)
d.computeDifference()
print(d.maximumDifference)