diff options
Diffstat (limited to '2024/2A.py')
| -rw-r--r-- | 2024/2A.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/2024/2A.py b/2024/2A.py new file mode 100644 index 0000000..6604a82 --- /dev/null +++ b/2024/2A.py @@ -0,0 +1,26 @@ +res = 0 + +with open("2.in") as f: + for i in f: + increasing = False + decreasing = False + safe = True + n = i.split() + prev = -1 + for j in n: + j = int(j) + if prev == -1: + prev = j + continue + if prev < j: + increasing = True + elif prev > j: + decreasing = True + if (abs(prev - j) > 3 or prev == j or (j > prev and decreasing or j < prev and increasing or increasing and decreasing or not increasing and not decreasing)): + safe = False + # break + prev = j + if safe: + res += 1 + +print(res) |
