Skip to content

Instantly share code, notes, and snippets.

@beraldo
Created August 2, 2012 00:13
Show Gist options
  • Save beraldo/3231800 to your computer and use it in GitHub Desktop.
Save beraldo/3231800 to your computer and use it in GitHub Desktop.
Programinha simples pra checar se você ficou rico(a) (loteria)
#!/usr/bin/env python
# coding: utf-8
#
# Verifica se você teve sorte e ganhou na loteria
#
# nome do arquivo com as apostas
PLAYS_FILENAME="plays.txt"
# nome do arquivo com o resultado
RESULT_FILENAME="result.txt"
# array de apostas
plays = []
# array com o resultado
result = []
# Lê o resultado
fp_result = open( RESULT_FILENAME )
numbersAsString = fp_result.read().strip()
fp_result.close()
result = numbersAsString.split( " " )
fp_plays = open( PLAYS_FILENAME )
# lê as aspostas
for line in fp_plays.readlines():
line = line.strip()
numbers = line.split( " " )
plays.append( numbers )
fp_plays.close()
for play in plays:
matches = set( play ) & set( result )
totalMatches = len( matches )
if totalMatches >= 4:
if totalMatches == 4:
print( "* Quadra: " ),
if totalMatches == 5:
print( "** Quina: " ),
if totalMatches == 6:
print( "!!!!!******** SENA!!!!!!: " ),
print( ", ".join( play ) )
1 2 3 4 5 6
32 44 12 8 48 46
32 44 12 8 10 22
32 44 10 3 6 9
32 44 12 8 48 46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment