diff options
| author | nekineki <nekineki@nekineki.net> | 2022-12-04 06:33:13 +0100 |
|---|---|---|
| committer | nekineki <nekineki@nekineki.net> | 2022-12-04 17:51:51 +0100 |
| commit | fb7bb01bef44123912586b63561fcfca937f1acb (patch) | |
| tree | f8ed76a75a797cdab8cfb054ace20234a7aca886 /2022/day4/asd.py | |
| parent | 1e01b4cfd75bb19b65aea71313be0dda55a1b61c (diff) | |
day4
Diffstat (limited to '2022/day4/asd.py')
| -rwxr-xr-x | 2022/day4/asd.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/2022/day4/asd.py b/2022/day4/asd.py new file mode 100755 index 0000000..7989e3e --- /dev/null +++ b/2022/day4/asd.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python3 + +# filename = "ref.txt" +filename = "pzl.txt" +res1 = 0 +res2 = 0 +with open(filename) as f: + for line in f: + line = line.strip() + prvi,drugi = line.split(',') + ps, pe = [int(i) for i in prvi.split('-')] + ds, de = [int(i) for i in drugi.split('-')] + + if ps <= ds and pe >= de: + res1 += 1 + elif ps >= ds and pe <= de: + res1 += 1 + + if ds <= pe <= de: + res2 += 1 + elif ps <= de <= pe: + res2 += 1 + + print(res1) + print(res2) + |
