2025年4月25日 星期五

大樂透模擬

 # -*- coding: utf-8 -*-

import random


d = list(range(1,49+1))

# print(d)

c0 = 0

c1 = 0

c2 = 0

c3 = 0

c3s = 0

c4 = 0

c5 = 0

c6 = 0

for j in range(4160):

  random.shuffle(d)

  b = d[:7]

  b.sort()

  print('b:',b)

  

  # p = [1,2,3,4,5,6,49]

  p = list(range(1,49+1))

  random.shuffle(p)

  p = p[:7]

  p.sort()

  print('P:',p)

  

  c =0

  rn = []

  for i in p[:6]:

    if i in b[:6]:

      c=c+1

      rn.append(i)

  print(rn,end=' ... ')

  print('中',c,'號')

  rs = False

  if b[6]==p[6]:rs = True

  print()

  if c==0 :c0+=1

  if c==1 :c1+=1

  if c==2 :c2+=1

  if c==3 :

      c3+=1

      if rs == True:

          c3s += 1

  if c==4 :c4+=1

  if c==5 :

      c5+=1

      # print('第',j,'次, 共花費:',j*50//10000,'萬元')

      # break

  if c==6 :c6+=1

  

print('中0號:',c0,'次')

print('中1號:',c1,'次')

print('中2號:',c2,'次')

print('中3號:',c3,'次  $:',c3*400)

print('中3號+特別號:',c3s,'次  $:',c3s*1000)

print('中4號:',c4,'次  $:',c4*2000)

print('中5號:',c5,'次')

print('中6號:',c6,'次')


total = c3*400 + c3s*1000 + c4*2000

print('共中獎:',total,'元')


print(4160,'次, 共花費:',4160*50//10000,'萬元')


  

沒有留言:

張貼留言