Created
August 2, 2012 00:13
-
-
Save beraldo/3231800 to your computer and use it in GitHub Desktop.
Programinha simples pra checar se você ficou rico(a) (loteria)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 ) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 2 3 4 5 6 | |
32 44 12 8 48 46 | |
32 44 12 8 10 22 | |
32 44 10 3 6 9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 44 12 8 48 46 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment