summaryrefslogtreecommitdiff
path: root/adt-stack/stack.py
diff options
context:
space:
mode:
authorZhongheng Liu <z.liu@outlook.com.gr>2025-02-19 09:43:52 +0200
committerZhongheng Liu <z.liu@outlook.com.gr>2025-02-19 09:43:52 +0200
commit8834da60a01294fd509c7cebf3b129fcc378d152 (patch)
treea1c6c4bd71e95780f87d35240754c5b54d3042ae /adt-stack/stack.py
parent34bd7099d27656b4454015b0c410ca1713db5271 (diff)
downloadcs-y13-8834da60a01294fd509c7cebf3b129fcc378d152.tar.gz
cs-y13-8834da60a01294fd509c7cebf3b129fcc378d152.tar.bz2
cs-y13-8834da60a01294fd509c7cebf3b129fcc378d152.zip
chore: changing to ipynb
Diffstat (limited to 'adt-stack/stack.py')
-rw-r--r--adt-stack/stack.py37
1 files changed, 0 insertions, 37 deletions
diff --git a/adt-stack/stack.py b/adt-stack/stack.py
deleted file mode 100644
index e99f231..0000000
--- a/adt-stack/stack.py
+++ /dev/null
@@ -1,37 +0,0 @@
-stack = [None for index in range(0,10)]
-basePointer = 0
-topPointer = -1
-stackFull = 10
-
-def push(item):
- global stack, topPointer
- topPointer += 1
- if topPointer >= stackFull:
- print("ERROR Cannot insert more.")
- return
- stack[topPointer] = item
- print(stack)
-def pop():
- global stack, topPointer
- if topPointer < basePointer:
- print("ERROR List is empty, cannot pop.")
- return
- itemPopped = stack[topPointer]
- print(f"I popped this {itemPopped}")
- stack[topPointer] = None
- topPointer -= 1
- print(stack)
-def test():
- push(1)
- push(2)
- push(69)
-
- pop()
- pop()
-
- print(stack)
-
- pop()
- pop()
-
-test()