From 56d0dc79eb0a9c001f23cc2b180c2ba716bd5567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BD=D0=B4=D1=80=D0=B5=D0=B9?= <50486086+DarkCat09@users.noreply.github.com> Date: Tue, 8 Jun 2021 16:29:22 +0400 Subject: [PATCH] One more math bruteforce script --- math_bruteforce/logic_exercise_bruteforce.py | 29 ++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 math_bruteforce/logic_exercise_bruteforce.py diff --git a/math_bruteforce/logic_exercise_bruteforce.py b/math_bruteforce/logic_exercise_bruteforce.py new file mode 100644 index 0000000..0b67b6b --- /dev/null +++ b/math_bruteforce/logic_exercise_bruteforce.py @@ -0,0 +1,29 @@ +print("") +print("*** EXERCISE BRUTEFORCE ***") +print("") + +light_count = 120 +lamps_in_chnd = 1 +lamps_in_scn = 3 + +chnd_lamps_count = 0 +scn_lamps_count = 0 +solved = False + +for chnd_count in range(light_count+1): + for scn_count in range(light_count+1): + #if (chnd_count + scn_count) > light_count: + #continue + chnd_lamps_count = lamps_in_chnd * chnd_count + scn_lamps_count = lamps_in_scn * scn_count + solved = (chnd_lamps_count == scn_lamps_count) and (chnd_lamps_count > 0) and (scn_lamps_count > 0) + print(chnd_lamps_count, chnd_count, scn_lamps_count, scn_count, solved) + if (solved): + print("OK") + break + if (solved): + break + +print("") +print("Finished") +input("")