-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathday2-2.py
More file actions
35 lines (31 loc) · 823 Bytes
/
Copy pathday2-2.py
File metadata and controls
35 lines (31 loc) · 823 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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function
#input function for both python2.7 and 3
def getInput(prompt=''):
try:
line = raw_input(prompt)
except NameError:
line = input(prompt)
return line
print('Enter/paste content. Ctrl-D to save. ', end='')
spreadsheet = []
while True:
try:
line = getInput()
except EOFError:
break
spreadsheet.append(line)
result = []
for line in spreadsheet:
values = line.split()
values.sort(key=int)
for num1 in values:
for num2 in values:
num1 = int(num1)
num2 = int(num2)
if num1 == num2:
continue
if num1 % num2 == 0:
result.append(num1 // num2)
print(sum(result))