0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Joke] c0ffee python版

Last updated at Posted at 2024-10-04

c0ffeeをpythonで書いてみました。

辞書ファイルから、16進数で表せる単語を探します。Oは0に置換します。

例えば、CAFE C0DE BEEF C0FFEE DEADBEEF等です。

chmod +x c0ffee.pyとして実行権を付け、./c0ffee.py dictionaryfile.txtとして実行してください。
辞書ファイルは、TABかスペースか改行で区切られた英単語列です。

c0ffee.py
#!/usr/bin/python
import sys

def hexword(w):
    w=w.replace('O','0').replace('o','0')
    for k in w:
        if k.upper() not in 'ABCDEF0':
            return ""
    return w

def main():
    fn=sys.argv[1]
    with open(fn,"rt") as file:
        text=file.read()
    words=text.split()
    words=[w for w in words if w]
    for i in words:
        if w:=hexword(i):
            print(w)

if __name__=="__main__":
    main()
0
0
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?