Skip to content

Instantly share code, notes, and snippets.

@MikulasZelinka
Last active September 25, 2023 08:34
Show Gist options
  • Save MikulasZelinka/323d8fa176daa7ca7e68dbe6dc7a42e7 to your computer and use it in GitHub Desktop.
Save MikulasZelinka/323d8fa176daa7ca7e68dbe6dc7a42e7 to your computer and use it in GitHub Desktop.
import turtle
dvojka = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K"]
dvacka = ["L", "M", "N", "O", "P", "R", "S", "T", "U", "V", "X", "Y", "Z"]
stav = [7, 9]
delky = (len(dvojka), len(dvacka))
assert delky == (11, 13)
vysledek = []
def kratsi_shift(i_puvodni, i_novy, delka):
shift = abs(i_puvodni - i_novy)
if shift > delka // 2:
shift = delka - shift
# jedu doleva?
if (i_puvodni - shift == i_novy) or (i_puvodni + delka - shift == i_novy):
shift *= -1
if shift > 0:
shift %= delka
return shift
kreslim = False
for char in "HRFXAOBUJMFMDHDXERFKVAOUEFOGDNJDLCHYHALKVB":
if char in dvojka:
shift = kratsi_shift(stav[0], dvojka.index(char), delky[0])
stav[0] += shift
stav[1] -= shift
else:
shift = kratsi_shift(stav[1], dvacka.index(char), delky[1])
stav[1] += shift
stav[0] -= shift
stav[0] %= delky[0]
stav[1] %= delky[1]
if char in dvojka:
vysledek.append(dvacka[stav[1]])
else:
vysledek.append(dvojka[stav[0]])
# VALITESKVELENYNIMALUJTEKONEMPFYSJVPCSNCOEZ
# HRFXAOBUJMFMDHDXERFKVAOUEFOGDNJDLCHYHALKVB
if char == "G":
kreslim = True
t = turtle.Turtle()
if not kreslim:
continue
if char in dvacka:
t.left(360 / delky[0] * shift)
if char in dvojka:
t.circle(radius=42 if shift < 0 else -42, extent=360 / delky[1] * abs(shift))
print("".join(vysledek))
# VALITESKVELENYNIMALUJTEKONEMPFYSJVPCSNCOEZ
assert "".join(vysledek) == "VALITESKVELENYNIMALUJTEKONEMPFYSJVPCSNCOEZ"
turtle.done()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment