From 364590c5635229bb253bfc26d0c6271b0552e122 Mon Sep 17 00:00:00 2001 From: schoeffelbe82781 Date: Mon, 31 Mar 2025 14:56:13 +0200 Subject: [PATCH] Added and fixed Comments --- schoeffelbe/pr01.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/schoeffelbe/pr01.py b/schoeffelbe/pr01.py index a639e3b..b590dbb 100644 --- a/schoeffelbe/pr01.py +++ b/schoeffelbe/pr01.py @@ -39,7 +39,7 @@ def max_sequence_2(z: MemoryArray): return m, l, r def _max_sequence_3_sub(z: MemoryArray, l: Literal, m: Literal, r: Literal): - # find max-sum from Middle to left (including on elem from right) + # find max-sum from Middle to left linksMax = MemoryCell(MIN_VALUE) sum = MemoryCell(0) links = MemoryCell(l) @@ -50,7 +50,7 @@ def _max_sequence_3_sub(z: MemoryArray, l: Literal, m: Literal, r: Literal): linksMax.set(sum) links.set(i) - # find max-sum from Middle to right (inluding one elem from left) + # find max-sum from Middle to right rechtsMax = MemoryCell(MIN_VALUE) sum.set(0); startRight = MemoryCell(1) + m @@ -114,6 +114,7 @@ def max_sequence_4(z: MemoryArray): max.set(aktSum) links.set(aktLinks) rechts.set(i) + # if negative we start new Sum -> Restart must be better than continue if aktSum < Literal(0): aktSum.set(0) aktLinks.set(MemoryCell(1) + i)