first 2 functions
This commit is contained in:
13
Dockerfile
Normal file
13
Dockerfile
Normal file
@@ -0,0 +1,13 @@
|
||||
FROM python:3.13-slim
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY ./app/* .
|
||||
|
||||
RUN pip3 install -r requirements.txt
|
||||
|
||||
EXPOSE 8501
|
||||
|
||||
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
|
||||
|
||||
ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
||||
42
app/app.py
Normal file
42
app/app.py
Normal file
@@ -0,0 +1,42 @@
|
||||
# app.py
|
||||
import streamlit as st
|
||||
from tools import *
|
||||
|
||||
st.set_page_config(
|
||||
page_title="tebarius mysteryhelfer web",
|
||||
page_icon="./favicon.ico", # Alternativ: "favicon.ico" (Pfad als String)
|
||||
layout="wide"
|
||||
)
|
||||
st.logo('./logo.png', size='large')
|
||||
|
||||
# Optional: Standard für den Session State setzen
|
||||
if 'letzte_aktion' not in st.session_state:
|
||||
st.session_state['letzte_aktion'] = None
|
||||
if 'output_text' not in st.session_state:
|
||||
st.session_state['output_text'] = ''
|
||||
|
||||
st.image('./logo-mit-tb.png', width=200)
|
||||
st.title("Textverarbeitung mit Sidebar und Wiederholen-Button")
|
||||
# Eingabefeld im Hauptbereich
|
||||
input_text = st.text_area('Gib deinen Text hier ein:', height=150)
|
||||
|
||||
# --- Sidebar: Buttons selektieren und Aktion setzen ---
|
||||
st.sidebar.header("Aktionen")
|
||||
if st.sidebar.button(label='Ceasarchiffre (all)', use_container_width=True):
|
||||
st.session_state['output_text'] = cesar_all(input_text)
|
||||
st.session_state['letzte_aktion'] = 'funktion1'
|
||||
if st.sidebar.button('BW,BWW,... ermitteln', use_container_width=True):
|
||||
st.session_state['output_text'] = buchstabenwortwert(input_text)
|
||||
st.session_state['letzte_aktion'] = 'funktion2'
|
||||
|
||||
# --- Hauptbereich: Button für Wiederholung der letzten Aktion ---
|
||||
if st.button("Letzte Aktion wiederholen"):
|
||||
if st.session_state['letzte_aktion'] == 'funktion1':
|
||||
st.session_state['output_text'] = cesar_all(input_text)
|
||||
elif st.session_state['letzte_aktion'] == 'funktion2':
|
||||
st.session_state['output_text'] = buchstabenwortwert(input_text)
|
||||
|
||||
# Ausgabefeld
|
||||
st.text_area('Ausgabe:', value=st.session_state['output_text'], height=150)
|
||||
|
||||
|
||||
1
app/data/e.txt
Normal file
1
app/data/e.txt
Normal file
File diff suppressed because one or more lines are too long
168065
app/data/en_US-large.txt
Normal file
168065
app/data/en_US-large.txt
Normal file
File diff suppressed because it is too large
Load Diff
2152638
app/data/german.dic
Normal file
2152638
app/data/german.dic
Normal file
File diff suppressed because it is too large
Load Diff
1
app/data/phi.txt
Normal file
1
app/data/phi.txt
Normal file
File diff suppressed because one or more lines are too long
1
app/data/pi.txt
Normal file
1
app/data/pi.txt
Normal file
File diff suppressed because one or more lines are too long
BIN
app/favicon.ico
Normal file
BIN
app/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 159 KiB |
156
app/helper.py
Normal file
156
app/helper.py
Normal file
@@ -0,0 +1,156 @@
|
||||
import math
|
||||
|
||||
# ***recursive quersummenfunktion***
|
||||
def q_sum(n):
|
||||
if n < 10:
|
||||
return n
|
||||
else:
|
||||
n = q_sum(n // 10) + n % 10
|
||||
return n
|
||||
|
||||
|
||||
# ***recursive iterierte quersummenfunktion***
|
||||
def iq_sum(n):
|
||||
if n < 10:
|
||||
return n
|
||||
else:
|
||||
n = iq_sum(q_sum(n))
|
||||
return n
|
||||
|
||||
|
||||
# ***produziert eine Liste mit Primzahlen kleiner als grenze***
|
||||
# ***nach dem Prinzip des "Sieb des Eratosthenes"***
|
||||
def primzahlliste(grenze):
|
||||
primes = []
|
||||
is_prime = [True] * grenze
|
||||
is_prime[0] = False
|
||||
is_prime[1] = False
|
||||
for i in range(2, int(math.sqrt(grenze))):
|
||||
if is_prime[i]:
|
||||
for j in range((i * i), grenze, i):
|
||||
is_prime[j] = False
|
||||
for i in range(len(is_prime)):
|
||||
if is_prime[i]:
|
||||
primes.append(i)
|
||||
return primes
|
||||
|
||||
|
||||
# ***alle permutationen generieren***
|
||||
def all_perms(liste):
|
||||
if len(liste) <= 1:
|
||||
yield liste
|
||||
else:
|
||||
for perm in all_perms(liste[1:]):
|
||||
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:
|
||||
anzahl[buchstabe] = anzahl[buchstabe] + 1
|
||||
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)
|
||||
n = 2.0 ** zoom
|
||||
xtile = int((lon_deg + 180.0) / 360.0 * n)
|
||||
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
|
||||
lat_rad = math.atan(math.sinh(math.pi * (1 - 2 * ytile / n)))
|
||||
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:
|
||||
lat_pre = "S"
|
||||
else:
|
||||
lat_pre = "N"
|
||||
if lon_dec < 0:
|
||||
lon_pre = "W"
|
||||
else:
|
||||
lon_pre = "E"
|
||||
lat = abs(lat_dec)
|
||||
lon = abs(lon_dec)
|
||||
lat_degree = int(lat)
|
||||
lon_degree = int(lon)
|
||||
lat_minutes = (lat - lat_degree) * 60
|
||||
lon_minutes = (lon - lon_degree) * 60
|
||||
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
|
||||
a = int(a)
|
||||
b = int(b)
|
||||
c = int(c)
|
||||
if (a % 1000 - a % 100) / 100 == 1:
|
||||
lat_sign = 1
|
||||
lon_sign = 1
|
||||
elif (a % 1000 - a % 100) / 100 == 2:
|
||||
lat_sign = -1
|
||||
lon_sign = 1
|
||||
elif (a % 1000 - a % 100) / 100 == 3:
|
||||
lat_sign = 1
|
||||
lon_sign = -1
|
||||
elif (a % 1000 - a % 100) / 100 == 4:
|
||||
lat_sign = -1
|
||||
lon_sign = -1
|
||||
else:
|
||||
return 0, 0
|
||||
if ((c % 100000 - c % 10000) / 10000 + (c % 100 - c % 10) / 10) % 2 == 0:
|
||||
lat = lat_sign * (
|
||||
(a % 10000 - a % 1000) / 100
|
||||
+ (b % 100 - b % 10) / 10
|
||||
+ (b % 100000 - b % 10000) / 100000
|
||||
+ (c % 1000 - c % 100) / 10000
|
||||
+ (a % 1000000 - a % 100000) / 100000000
|
||||
+ (c % 100 - c % 10) / 100000
|
||||
+ a % 10 * 1.0E-5)
|
||||
elif ((c % 100000 - c % 10000) / 10000 + (c % 100 - c % 10) / 10) % 2 != 0:
|
||||
lat = lat_sign * (
|
||||
(b % 1000000 - b % 100000) / 10000
|
||||
+ a % 10 + (a % 10000 - a % 1000) / 10000
|
||||
+ (c % 1000000 - c % 100000) / 10000000
|
||||
+ (c % 1000 - c % 100) / 100000
|
||||
+ (c % 100 - c % 10) / 100000
|
||||
+ (a % 1000000 - a % 100000) / 10000000000)
|
||||
if ((c % 100000 - c % 10000) / 10000 + (c % 100 - c % 10) / 10) % 2 == 0:
|
||||
lon = lon_sign * (
|
||||
(a % 100000 - a % 10000) / 100
|
||||
+ (c % 1000000 - c % 100000) / 10000
|
||||
+ c % 10 + (b % 1000 - b % 100) / 1000
|
||||
+ (b % 1000000 - b % 100000) / 10000000
|
||||
+ (a % 100 - a % 10) / 10000
|
||||
+ (c % 100000 - c % 10000) / 100000000
|
||||
+ b % 10 * 1.0E-5)
|
||||
elif ((c % 100000 - c % 10000) / 10000 + (c % 100 - c % 10) / 10) % 2 != 0:
|
||||
lon = lon_sign * (
|
||||
(b % 100 - b % 10) * 10
|
||||
+ c % 10 * 10
|
||||
+ (a % 100 - a % 10) / 10
|
||||
+ (a % 100000 - a % 10000) / 100000
|
||||
+ (b % 1000 - b % 100) / 10000
|
||||
+ b % 10 * 0.001
|
||||
+ (c % 100000 - c % 10000) / 100000000
|
||||
+ (b % 100000 - b % 10000) / 1000000000)
|
||||
return round(lat, 5), round(lon, 5)
|
||||
BIN
app/logo-mit-tb.png
Normal file
BIN
app/logo-mit-tb.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 366 KiB |
BIN
app/logo.png
Normal file
BIN
app/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
BIN
app/requirements.txt
Normal file
BIN
app/requirements.txt
Normal file
Binary file not shown.
4012
app/tools.py
Normal file
4012
app/tools.py
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user