from common import *

MORSECODE = {

'A':(0,1),

'B':(1,0,0,0),

'C':(1,0,1,0),

'D':(1,0,0),

'E':(0,),

'F':(0,0,1,0),

'G':(1,1,0),

'H':(0,0,0,0),

'I':(0,0),

'J':(0,1,1,1),

'K':(1,0,1),

'L':(0,1,0,0),

'M':(1,1),

'N':(1,0),

'O':(1,1,1),

'P':(0,1,1,0),

'Q':(1,1,0,1),

'R':(0,1,0),

'S':(0,0,0),

'T':(1,),

'U':(0,0,1),

'V':(0,0,0,1),

'W':(0,1,1),

'X':(1,0,0,1),

'Y':(1,0,1,1),

'Z':(1,1,0,0),

'0':(1,1,1,1,1),

'1':(0,1,1,1,1),

'2':(0,0,1,1,1),

'3':(0,0,0,1,1),

'4':(0,0,0,0,1),

'5':(0,0,0,0,0),

'6':(1,0,0,0,0),

'7':(1,1,0,0,0),

'8':(1,1,1,0,0),

'9':(1,1,1,1,0),

'.':(0,1,0,1,0,1),

':':(1,1,1,0,0,0),

',':(1,1,0,0,1,1),

';':(1,0,1,0,1,0),

'?':(0,0,1,1,0,0),

'=':(1,0,0,0,1),

'\'':(0,1,1,1,1,0),

'/':(1,0,0,1,0),

'!':(1,0,1,0,1,1),

'-':(1,0,0,0,0,1),

'_':(0,0,1,1,0,1),

'"':(0,1,0,0,1,0),

'(':(1,0,1,1,0),

')':(1,0,1,1,0,1),

'$':(0,0,0,1,0,0,1),

'&':(0,1,0,0,0),

'@':(0,1,1,0,1),

'+':(0,1,0,1,0)

}

MDT = 200

def morse(me):

for i in range(len(me)):

try:

c = me.upper()[i]

d = MORSECODE[c]

except:

continue

print(c, d)

for i in range(len(d)):

print(d[i])

clear(np, 32)

if d[i]:

sleep_ms(MDT*3)

else:

sleep_ms(MDT)

clear(np)

sleep_ms(MDT)

sleep_ms(MDT*5)

PYZEN = "\

Beautiful is better than ugly.\

Explicit is better than implicit.\

Simple is better than complex.\

Complex is better than complicated.\

Flat is better than nested.\

Sparse is better than dense.\

Readability counts.\

Special cases aren't special enough to break the rules.\

Although practicality beats purity.\

Errors should never pass silently.\

Unless explicitly silenced.\

In the face of ambiguity, refuse the temptation to guess.\

There should be one-- and preferably only one --obvious way to do it.\

Although that way may not be obvious at first unless you're Dutch.\

Now is better than never.\

Although never is often better than *right* now.\

If the implementation is hard to explain, it's a bad idea.\

If the implementation is easy to explain, it may be a good idea.\

Namespaces are one honking great idea -- let's do more of those!\

"

def run():

morse('Hello, world.')

while 1:

morse(PYZEN)

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐