2024年5月27日 星期一

queue

 a = list(range(1,31))

i = 1

while len(a)>1:

    if i %3==0:

        a.append(a[0])

    del a[0]

    i = i +1

print(a)

#執行結果

[18]



2024年5月26日 星期日

green judge ...

 https://web.archive.org/web/20210412155705/http://www.tcgs.tc.edu.tw:1218/Problems

2024年5月24日 星期五

交錯字串

 while True:

    try:

        ddd = input()

        print(ddd)

        k = int(input().strip())

        d = input().strip()

        

        dd = ''

        for i in d:

            if i>='a':

              dd+='0'

            else:

                dd+='1'

        

        s = ''

        c = 0

        is0 = True

        isEnd = False

        

        while not isEnd: 

            if is0:

                s += '0'*k

                if s in dd:

                    c += k

                else:

                    isEnd = True

            else:

                s += '1'*k

                if s in dd:

                    c +=k

                else:

                    isEnd = True

            is0 = not is0        

        print(c)

    except:

        break

2024年5月5日 星期日

回家的日子

 def gcd(a,b):

    while a!=b:

        if a>b:

            a = a-b

        else:

            b = b-a

    return a


def lcm(a,b):

    return a*b/gcd(a,b)


n = int(input())

d = [int(i) for i in input().strip().split()]


lcm1 = d[0]

for i in d:

    lcm1 = lcm(lcm1,i)

ddays = lcm1


cd = [int(i) for i in input().strip().split('/')]

cyear ,cmonth,cdays = cd[0],cd[1],cd[2]



dc = [0,31,28,31,30,31,30,31,31,30,31,30,31]

dlc = [0,31,29,31,30,31,30,31,31,30,31,30,31]

        

rdict = {}

c = 0

for y in range(2015,2020+1):

    for m in range(1,13):

        if y%4==0:

            for d in range(1,dlc[m]+1):

                c+=1

                # print(c,':',y,m,d)

                rdict[c]=f'{y}/{m:0>2}/{d:0>2}'

        else:

            for d in range(1,dc[m]+1):

                c+=1

                # print(y,m,d)

                

                rdict[c]=f'{y}/{m:0>2}/{d:0>2}'


findkey =0

for k,v in rdict.items():

    if v=='2015/10/10':

        findkey = k

        # print(k,v)

print(rdict[findkey+ddays])


#4 

#4 5 12 21

#2015/10/10

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='')