2025年6月5日 星期四

7槓法顯示數字

 def fr(s):

  t = ''

  for i in range(5):

    for j in [int(k) for k in s]:

      t+=r[j][i]+'\t'

    t+='\n'

  return t

    

r0 = [

' - ',

'| |',

'   ',

'| |',

' - '

]


r1 = [

'   ',

'  |',

'   ',

'  |',

'   '

]


r2 = [

' - ',

'  |',

' - ',

'|  ',

' - '

]


r3 = [

' - ',

'  |',

' - ',

'  |',

' - '

]


r4 = [

'   ',

'| |',

' - ',

'  |',

'   '

]


r5 = [

' -  ',

'|  ',

' - ',

'  |',

' -  '

]


r6 = [

'    ',

'|  ',

' - ',

'| |',

' -  '

]


r7 = [

' - ',

'  |',

'   ',

'  |',

'    '

]


r8 = [

' - ',

'| |',

' - ',

'| |',

' - '

]


r9 = [

' - ',

'| |',

' - ',

'  |',

'   '

]



r = []

r.append(r0)

r.append(r1)

r.append(r2)

r.append(r3)

r.append(r4)

r.append(r5)

r.append(r6)

r.append(r7)

r.append(r8)

r.append(r9)


d = '12304'

print(fr(d))  

d = '4321'

print(fr(d))  


d = '9876543210'

print(fr(d))


Output:



沒有留言:

張貼留言