from microbit import *
from random import randint
shapes = "TIJLOSZTIJLOSZTIJLOSZTIJLOSZTIJLOSZT "
display.show("-")
while True:
if button_a.was_pressed():
display.show(" ")
sleep(100)
ln = len(shapes)
if ln == 1:
break
r = randint(0,ln-2)
display.show(shapes[r])
if r == 0:
shapes = shapes[1:]
else:
shapes = shapes[0:r] + shapes[r+1:]
display.show("=")
由於 MicroPython 不是一般 Python,它只提供精簡版的函數庫,所以不足的功能要自己寫。上面的程式每按一次 A 鍵,隨機抽一個拼塊,因此程式將 36 個拼塊依序排列一字串,亂數隨機抽一個,被抽到的字塊拿掉,未被抽走的字塊再合併成一字串,再隨機抽籤,直到抽完為止。
完美正方形生成工具
-
所有網頁製作都只用到claude,幾乎每次提示詞一發出,claude立即能正確理解,高效應答。 直接把玩:
ejsoon_perfect_square36data 22 192 192 86 49 57 41 8 28 37 19 9 47 35 4 31
14 10 36 17 26 12 71 62 59...
1 天前

沒有留言:
張貼留言