master > master: code py - algorithmen für rucksackproblem

This commit is contained in:
RD
2022-06-14 01:35:10 +02:00
parent 7cfaf253b3
commit ea36c82728
13 changed files with 500 additions and 1 deletions

View File

@@ -39,6 +39,13 @@ class Stack:
def __contains__(self, value: Any) -> bool:
return value in self.elements;
def __iter__(self) -> Generator[Any, None, None]:
for value in self.elements:
yield value;
def __str__(self) -> str:
return ', '.join([str(value) for value in self.elements[::-1]]);
def push(self, value: Any):
'''
add element to stack
@@ -68,3 +75,6 @@ class Stack:
checks if element in stack:
'''
return element in self.elements;
def empty(self) -> bool:
return len(self) == 0;