Last active
September 25, 2023 08:34
Revisions
-
mikulas1 revised this gist
Sep 25, 2023 . 1 changed file with 23 additions and 1 deletion.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ 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"] @@ -27,6 +29,9 @@ def kratsi_shift(i_puvodni, i_novy, delka): return shift kreslim = False for char in "HRFXAOBUJMFMDHDXERFKVAOUEFOGDNJDLCHYHALKVB": if char in dvojka: shift = kratsi_shift(stav[0], dvojka.index(char), delky[0]) @@ -45,7 +50,24 @@ def kratsi_shift(i_puvodni, i_novy, delka): 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() -
mikulas1 revised this gist
Sep 25, 2023 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed. -
MikulasZelinka created this gist
Sep 25, 2023 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ 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 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]]) print("".join(vysledek)) # VALITESKVELENYNIMALUJTEKONEMPFYSJVPCSNCOEZ assert "".join(vysledek) == "VALITESKVELENYNIMALUJTEKONEMPFYSJVPCSNCOEZ"