From c05f73f8232f4b0f431a355e0108a2032fb73a6e Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Tue, 3 Dec 2024 12:23:16 +0800 Subject: add: 2A.py --- 2024/2A.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 2024/2A.py 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) -- cgit v1.2.3