initial project commit

This commit is contained in:
tilo 2025-10-16 16:51:35 +02:00
parent 524c2901cd
commit 67eb44796c
5 changed files with 56 additions and 0 deletions

35
main.py Normal file
View File

@ -0,0 +1,35 @@
from tabulate import tabulate
from numeric.compute import matmul, transpose, rot_2D
from util.tools import substring
if __name__ == '__main__':
# Substring
original = "GEEKSFORGEEKS"
# print(substring(original, 0, 5)) # Output: GEEKS
# print(substring(original, 5)) # Output: FORGEEKS
# Matrix multiplication
matrix_a = [[3, 4, -1, 4],
[-2, 2, 5, 1]
]
matrix_b = [[1, 3, -2],
[2, 5, 1],
[-1, 4, -4],
[2, 3, 6]
]
matrix_c = matmul(matrix_a, matrix_b)
# print("Ergebnis C = A * B:")
# for row in matrix_c:
# print(row)
# Transposition
matrix = [
[1, 2, 3],
[4, 5, 6]
]
# print(tabulate(transpose(matrix)))
# Rotation
print(tabulate(rot_2D(90)))

0
numeric/__init__.py Normal file
View File

BIN
requirements.txt Normal file

Binary file not shown.

0
util/__init__.py Normal file
View File

21
util/tools.py Normal file
View File

@ -0,0 +1,21 @@
def substring(string: str, start: int, end: int = 0) -> str:
"""
A substring function
:param string: The string
:param start: The starting index
:param end: The ending index. If None, this is set to the length of the substring :return:
"""
if not isinstance(string, str):
raise ValueError("No string provided")
if not isinstance(start, int):
raise ValueError("No starting index provided")
if end is None:
end = len(str)
result = ""
for i in range(start, end):
result += string[i]
return result