-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKata04.py
More file actions
45 lines (40 loc) · 1.12 KB
/
Kata04.py
File metadata and controls
45 lines (40 loc) · 1.12 KB
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
import re
#Parte uno
pattern = "\s(\d+).\s+(\d+).\s+(\d+).*"
mint = 99999
day = 0
for i, line in enumerate(open('weather.dat')):
match=re.search(pattern, line)
if match:
newMin = int(match.group(2))-int(match.group(3))
if mint > newMin:
mint = newMin
day = match.group(1)
print day
#Parte dos
pattern = "\d+\.\s(\w+).*(\s\d+)\s*-\s+(\d+)*"
mint = 99999
day = 0
for i, line in enumerate(open('football.dat')):
match=re.search(pattern, line)
if match:
newMin = int(match.group(2))-int(match.group(3))
if mint > newMin:
mint = newMin
day = match.group(1)
print day
#Parte tres
def general(patern, file):
mint = 99999
day = 0
for i, line in enumerate(open(file)):
match=re.search(patern, line)
if match:
newMin = int(match.group(2))-int(match.group(3))
if mint > newMin:
mint = newMin
day = match.group(1)
print day
#Llamadas al metodo general
general('\s(\d+).\s+(\d+).\s+(\d+).*', 'weather.dat')
general('\d+\.\s(\w+).*(\s\d+)\s*-\s+(\d+)*', 'football.dat')