From b42417b424d843d514f09694423d07fe0e691d9c Mon Sep 17 00:00:00 2001 From: Maksym Kurets Date: Tue, 13 Oct 2026 20:15:46 +0200 Subject: [PATCH] Add matching brackets implementation for U6 --- u6/matching-brackets.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 u6/matching-brackets.py diff --git a/u6/matching-brackets.py b/u6/matching-brackets.py new file mode 100644 index 0000000..e393c90 --- /dev/null +++ b/u6/matching-brackets.py @@ -0,0 +1,12 @@ +def is_paired(input_string): + spisok = [] + slovnik = {')': '(', ']': '[', '}': '{'} + + for gnx in input_string: + if gnx in "([{": + spisok.append(gnx) + elif gnx in ")]}": + if not spisok or spisok[-1] != slovnik[gnx]: + return False + spisok.pop() +