2024年4月22日 星期一

身分證檢查

 dd = 'I123456789'


d ='0' + dd[1:]



'''

y = x1+9*x2+

8*d1+7*d2+6*d3+5*d4+4*d5+3*d6+2*d7+1*d8+

d9

'''

x = 'ABCDEFGHJKLMNPQRSTUVXYWZIO'.index(dd[0])+10

# print(x)

x1 = x//10

x2 = x%10

y = x1+ 9 * x2

k = 8

for i in range(1,8+1):

    y = y + k*int(d[i])

    k = k - 1

y = y + int(d[9])

print(y)

if y%10==0:

    print('OK')

else:

    print('wrong')

羅馬數字

 for i in range( 1,102):

    v = i

    s = ''

    r = ['C','XC','L','XL','X','IX','V','IV','I']

    k = 0

    for j in [100,90,50,40,10,9,5,4,1]:

        while v>=j:

            s = s + r[k]

            v = v - j

        k= k +1

    print(s)

2024年4月8日 星期一

資料清理

 d = '''

Tomorrow Will Be Better


When you wake up in the morning

When you haven't started to think

...

...

blow away with the wind

I know you'll do

We pray and believe

that tomorrow will be better.

'''


for i in '.,-※\'\n':

    d = d.replace(i,' ')

for i in d:

    if i >='A' and i<='z' or i in ' ':

        print(i,end='')

進位轉換

 def seven(n):

    s = ''

    while n>=7:

        s = str(n%7)+ s  

        n = n//7

    s = str(n)+ s    

    return s


def twelve(n):

    s = ''

    while n>=12:

        s = '0123456789AB'[n%12]+ s  

        n = n//12

    s = '0123456789AB'[n%12]+ s      

    return s


for i in range(20):

    print(i,seven(i),twelve(i))

線上程式設計評分平台

 https://hackmd.io/@biz-pg/account