From 7601194a0e1ea98cdd9e17fbd50039c236b298cb Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: 2022年6月20日 04:58:34 +0000 Subject: [PATCH] deploy: dad4769e7730feeb04c5cf056c5e0afd6462eed5 --- .nojekyll | 0 index.html | 67 +++++++++++++++++++++++++++++++++++++++++++++++ modules/pyfuck.py | 21 +++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 .nojekyll create mode 100644 index.html create mode 100644 modules/pyfuck.py diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/index.html b/index.html new file mode 100644 index 0000000..a214f6f --- /dev/null +++ b/index.html @@ -0,0 +1,67 @@ + + + + + + + + + + PyFuck Playground + + - paths: + - ./modules/pyfuck.py + + + +
+
+

💘PyFuck Playground

+
+ + + +
+ + +
+ PyFuck Script +
+ + + +
+ + from pyfuck import PyFuck + + def make_pyfuck(*ags, **kwgs): + python_code = Element("python-script").element.value + pyfuck = PyFuck.make_pyfuck(python_code) + pyscript.write('pyfuck-script', f"exec({pyfuck})") + pyscript.write('copy-button', "Copy to Clipboard") + + button = Element('pyfuck-button') + button.element.onclick = make_pyfuck + + +

AltStyle によって変換されたページ (->オリジナル) /

+ diff --git a/modules/pyfuck.py b/modules/pyfuck.py new file mode 100644 index 0000000..be3f39f --- /dev/null +++ b/modules/pyfuck.py @@ -0,0 +1,21 @@ +class PyFuck: + # PyFuck コードを生成 + @classmethod + def make_pyfuck(self, python_code: str) -> str: + pyfuck = "" + for c in python_code: + pyfuck += f"chr({self.__num_to_fuck(str(ord(c)))})+" + return pyfuck[:-1] + + # 数値を PyFuck に変換 + def __num_to_fuck(num: str) -> str: + digit: int = len(num) # num の文字数 + num = int(num) + ones = int("1" * digit) # 11111....111 の数値 + fucks = [] # [1111, 111, 11, 1] + while num> 0 and ones> 0: + while num> 0 and ones> 0 and num>= ones: + num -= ones + fucks.append(ones) + ones = ones // 10 + return "+".join(map(str, fucks))