python day 4
This commit is contained in:
parent
98aeaac704
commit
192a9c046e
BIN
2022/04/.02.py.swp
Executable file
BIN
2022/04/.02.py.swp
Executable file
Binary file not shown.
20
2022/04/01.py
Executable file
20
2022/04/01.py
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
INPUT_FILE = 'input'
|
||||
|
||||
def main():
|
||||
content = map(str.strip, open(INPUT_FILE, 'r').readlines())
|
||||
includes = 0
|
||||
for line in content:
|
||||
e1, e2 = line.split(',')
|
||||
e1_from, e1_to = map(int, e1.split('-'))
|
||||
e2_from, e2_to = map(int, e2.split('-'))
|
||||
#r1 = range(int(e1_from), int(e1_to) +1)
|
||||
#r2 = range(int(e2_from), int(e2_to) +1)
|
||||
if (e1_from <= e2_from and e1_to >= e2_to ) or \
|
||||
( e2_from <= e1_from and e2_to >= e1_to ):
|
||||
includes += 1
|
||||
print(includes)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
19
2022/04/02.py
Executable file
19
2022/04/02.py
Executable file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
INPUT_FILE = 'input'
|
||||
|
||||
def main():
|
||||
content = map(str.strip, open(INPUT_FILE, 'r').readlines())
|
||||
includes = 0
|
||||
for line in content:
|
||||
e1, e2 = line.split(',')
|
||||
e1_from, e1_to = map(int, e1.split('-'))
|
||||
e2_from, e2_to = map(int, e2.split('-'))
|
||||
r1 = list(range(int(e1_from), int(e1_to) +1))
|
||||
r2 = list(range(int(e2_from), int(e2_to) +1))
|
||||
if set(r1).intersection(r2):
|
||||
includes += 1
|
||||
print(includes)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
1000
2022/04/input
Executable file
1000
2022/04/input
Executable file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user