master > master: code - decorators angewandt
This commit is contained in:
@@ -9,6 +9,7 @@ from local.maths import *;
|
||||
from local.typing import *;
|
||||
|
||||
from code.core.log import *;
|
||||
from code.algorithms.methods import *;
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# GLOBAL VARIABLES/CONSTANTS
|
||||
@@ -16,10 +17,24 @@ from code.core.log import *;
|
||||
|
||||
#
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# CHECKS
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
def preChecks(L: List[int], **_):
|
||||
assert L == sorted(L), 'Ungültiger Input: L muss aufsteigend sortiert sein!';
|
||||
return;
|
||||
|
||||
def postChecks(L: List[int], x: int, p: int, **_):
|
||||
value = L[p] if p >= 0 else None;
|
||||
assert value == x, 'Der Algorithmus hat versagt.';
|
||||
return;
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# ALGORITHM interpolation
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@algorithmInfos(name='Interpolationssuchalgorithmus', outputnames='p', checks=True, metrics=True, preChecks=preChecks, postChecks=postChecks)
|
||||
def InterpolationSearch(L: List[int], x: int, u: int, v: int) -> int:
|
||||
'''
|
||||
Inputs: L = Liste von Zahlen, x = Zahl, [u, v] = Suchinterval.
|
||||
|
||||
Reference in New Issue
Block a user