Skip to content

Instantly share code, notes, and snippets.

@danuker
Created January 30, 2016 19:01
Show Gist options
  • Save danuker/e17643e0e665377eff5c to your computer and use it in GitHub Desktop.
Save danuker/e17643e0e665377eff5c to your computer and use it in GitHub Desktop.
# Loto edition
# pret bilet: 4.8 lei
# castig mediu din 2005: aprox. 14000000 lei
import random
castig_mediu = 14000000
bilet = 4.8
def extragere():
return random.sample(range(1, 50), 6)
def castig(bagat, iesit):
bagat, iesit = set(bagat), set(iesit)
if bagat == iesit:
return castig_mediu - bilet
else:
return -bilet
bagat = [1, 2, 3, 4, 5, 6]
incercari = 100000000
castig_total = 0
for i in range(incercari):
extrase = extragere()
castig_total += castig(bagat, extrase)
if i % 1000000 == 0:
print("Total:", castig_total)
print("Medie:", castig_total/(i+1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment