chronogramm, röm-zahlen, urls-decode, reverse-wig,

bas64, jägerzaun
This commit is contained in:
2025-07-26 22:39:36 +02:00
parent 07dc37902b
commit 8dc56b70b2
4 changed files with 201 additions and 223 deletions

View File

@@ -12,7 +12,6 @@ def q_sum(n):
n = q_sum(n // 10) + n % 10
return n
# ***recursive iterierte quersummenfunktion***
def iq_sum(n):
if n < 10:
@@ -21,7 +20,6 @@ def iq_sum(n):
n = iq_sum(q_sum(n))
return n
# ***produziert eine Liste mit Primzahlen kleiner als grenze***
# ***nach dem Prinzip des "Sieb des Eratosthenes"***
@st.cache_resource
@@ -39,7 +37,6 @@ def primzahlliste(grenze):
primes.append(i)
return primes
# ***alle permutationen generieren***
def all_perms(liste):
if len(liste) <= 1:
@@ -49,7 +46,6 @@ def all_perms(liste):
for i in range(len(perm) + 1):
yield perm[:i] + liste[0:1] + perm[i:]
# ***zählfunktionen für anagramm suche
def buchstabenzaehl(buchstabe, anzahl):
if buchstabe in anzahl:
@@ -57,14 +53,12 @@ def buchstabenzaehl(buchstabe, anzahl):
else:
anzahl[buchstabe] = 1
def wortzaehl(wort):
anzahl = {}
for buchstabe in wort:
buchstabenzaehl(buchstabe.upper(), anzahl)
return anzahl
# ***Funktionen für Kachelkoordinaten/Maptiles-Funktion
def dec_to_maptiles(lat_deg, lon_deg, zoom):
lat_rad = math.radians(lat_deg)
@@ -73,7 +67,6 @@ def dec_to_maptiles(lat_deg, lon_deg, zoom):
ytile = int((1.0 - math.log(math.tan(lat_rad) + (1 / math.cos(lat_rad))) / math.pi) / 2.0 * n)
return xtile, ytile
def maptiles_to_dec(xtile, ytile, zoom):
n = 2.0 ** zoom
lon_dec = xtile / n * 360.0 - 180.0
@@ -81,7 +74,6 @@ def maptiles_to_dec(xtile, ytile, zoom):
lat_dec = math.degrees(lat_rad)
return lat_dec, lon_dec
# ***Dezimalgrad in Dezimalminuten (Ausgabe als String)
def dec_to_deg(lat_dec, lon_dec):
if lat_dec < 0:
@@ -101,7 +93,6 @@ def dec_to_deg(lat_dec, lon_dec):
return ("{}{} {:.3f} {}{} {:.3f}".format(lat_pre, lat_degree, round(lat_minutes, 3), lon_pre, lon_degree,
round(lon_minutes, 3)))
# ***ReverseWherIGo zu Dezimalgrad
def rwig_to_coords(a, b, c):
lat, lon = 0, 0
@@ -286,3 +277,63 @@ def t9_germandic(eingabetext):
ausgabetext += zeile + " \n"
wbfile.close()
return ausgabetext
def rail_encrypt(plain_text: str, rails: int):
arr = [["" for _ in range(len(plain_text))] for _ in range(rails)]
r = 0
z = 0
plus = True
for b in plain_text:
arr[r][z] = b
z += 1
if r + 1 == rails and plus:
plus = False
r -= 1
elif r - 1 < 0 and not plus:
plus = True
r += 1
elif plus:
r += 1
else:
r -= 1
out = ""
for i in range(rails):
for j in range(len(plain_text)):
out += arr[i][j]
return out
def rail_decrypt(cipher: str, rails: int):
arr = [["_" for _ in range(len(cipher))] for _ in range(rails)]
# cipher ins array reinbasteln
x, y = 0, 0
first_x = True
for b in cipher:
if x >= len(cipher) and y < rails:
y += 1
x = y
first_x = True
arr[y][x] = b
if y == 0 or (first_x and y != rails - 1):
x = x + (rails - y - 1) * 2
first_x = False
elif y == rails - 1 or first_x is False:
x = x + (y * 2)
first_x = True
# dekodierten Text aus array holen
out = ""
x, y = 0, 0
down = True
for _ in range(len(cipher)):
out += arr[y][x]
x += 1
if down and y + 1 == rails:
down = False
y -= 1
elif down:
y += 1
elif down is False and y == 0:
down = True
y += 1
elif down is False:
y -= 1
return out