From e5ad06fc225cf9579e720bf3871760c7ae630ab4 Mon Sep 17 00:00:00 2001 From: Maksym Kurets Date: Tue, 13 Oct 2026 20:22:48 +0200 Subject: [PATCH] Add matching brackets file properly --- kindergarten_garden.py | 35 ------------- u2/.ipynb_checkpoints/ list_ops-checkpoint.py | 50 +++++++++---------- 2 files changed, 23 insertions(+), 62 deletions(-) delete mode 100644 kindergarten_garden.py diff --git a/kindergarten_garden.py b/kindergarten_garden.py deleted file mode 100644 index f688b33..0000000 --- a/kindergarten_garden.py +++ /dev/null @@ -1,35 +0,0 @@ -class NoSuchStudentException(Exception): - pass - -class Garden: - def __init__(self, diagram, students=None): - self.diagram = diagram - if students is None: - self.students = [ - "Alena", "Boris", "Cyril", "Daniel", "Eva", "František", - "Gitka", "Helena", "Ivana", "Jozef", "Karol", "Ladislav" - ] - else: - self.students = sorted(students) - - self.plant_names = { - "G": "Tráva", - "C": "Ďatelina", - "R": "Reďkovky", - "V": "Fialky" - } - - def plants(self, student): - if student not in self.students: - raise NoSuchStudentException("Student not found") - - index = self.students.index(student) - start = index * 2 - - rows = self.diagram.splitlines() - row1 = rows[0] - row2 = rows[1] - - letters = row1[start:start+2] + row2[start:start+2] - - return [self.plant_names[char] for char in letters] diff --git a/u2/.ipynb_checkpoints/ list_ops-checkpoint.py b/u2/.ipynb_checkpoints/ list_ops-checkpoint.py index b7e2926..9664ba4 100644 --- a/u2/.ipynb_checkpoints/ list_ops-checkpoint.py +++ b/u2/.ipynb_checkpoints/ list_ops-checkpoint.py @@ -6,46 +6,42 @@ def append(list1, list2): pusti.append(exc) return pusti - def concat(list): +def concat(lists): pusti = [] - for gns in list: + for gns in lists: pusti.extend(gns) return pusti - def filter(function, list): +def filter(function, list): pusti = [] for gns in list: if function(gns): pusti.append(gns) return pusti - def length(list): +def length(list): pocatok = 0 for gns in list: pocatok = pocatok + 1 return pocatok - def map(function, list): - pusti = [] - for gns in list: - function(gns) - pusti.append(function(gns)) - return pusti - - def foldl(function, accumulator, initial): - accumulator = initial - for gns in list: - accumulator = function(accumulator, gns) - return accumulator - - def foldr(function, initial, acc): - acc = initial - for gns in list[::-1]: - acc = function(gns, acc) - return acc - - def reverse(list): - pusti = [] +def map(function, list): + pusti = [] for gns in list: - pusti.append(gns) - return pusti[::-1] \ No newline at end of file + pusti.append(function(gns)) + return pusti + +def foldl(function, list, initial): + accumulator = initial + for gns in list: + accumulator = function(accumulator, gns) + return accumulator + +def foldr(function, list, initial): + acc = initial + for gns in list[::-1]: + acc = function(gns, acc) + return acc + +def reverse(list): + return list[::-1] \ No newline at end of file