From ca52ffd5ef0f875d8f60348097c0510321912570 Mon Sep 17 00:00:00 2001 From: Funky Waddle Date: Fri, 2 Dec 2022 23:05:02 -0600 Subject: [PATCH] Update to be multi-ticket reportable. --- .gitignore | 56 ++++++++++++++++------------------ LotteryChecker.sublime-project | 28 +++++++++++++++++ lib/Ticket.py | 13 +++++--- megamillions/game.py | 8 +++-- megamillions/picks.py | 14 +++++++-- powerball/game.py | 8 +++-- powerball/picks.py | 20 ++++++++++-- 7 files changed, 106 insertions(+), 41 deletions(-) create mode 100644 LotteryChecker.sublime-project diff --git a/.gitignore b/.gitignore index b24d71e..4d4dfbc 100644 --- a/.gitignore +++ b/.gitignore @@ -7,44 +7,42 @@ node_modules/ dist/ -# Compiled Java class files -*.class - # Compiled Python bytecode *.py[cod] # Log files *.log -# Package files -*.jar - -# Maven -target/ -dist/ - -# JetBrains IDE -.idea/ - -# Unit test reports -TEST*.xml - -# Generated by MacOS -.DS_Store - -# Generated by Windows -Thumbs.db - # Applications *.app *.exe *.war -# Large media files -*.mp4 -*.tiff -*.avi -*.flv -*.mov -*.wmv +# Cache files for Sublime Text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# Workspace files are user-specific +*.sublime-workspace + +# Project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using Sublime Text +# *.sublime-project + +# SFTP configuration file +sftp-config.json +sftp-config-alt*.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +Package Control.merged-ca-bundle +Package Control.user-ca-bundle +oscrypto-ca-bundle.crt +bh_unicode_properties.cache diff --git a/LotteryChecker.sublime-project b/LotteryChecker.sublime-project new file mode 100644 index 0000000..0e19509 --- /dev/null +++ b/LotteryChecker.sublime-project @@ -0,0 +1,28 @@ +{ + "build_systems": + [ + { + "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", + "name": "Anaconda Python Builder", + "selector": "source.python", + "shell_cmd": "./venv/bin/python -u \"$file\"" + } + ], + "folders": + [ + { + "follow_symlinks": true, + "path": "." + } + ], + "settings": + { + "anaconda_linting": true, + "anaconda_linting_behaviour": "always", + "pep257": false, + "python_interpreter": "./venv/bin/python", + "test_command": "./venv/bin/python -m unittest discover", + "use_pylint": false, + "validate_imports": true + } +} diff --git a/lib/Ticket.py b/lib/Ticket.py index 76eba03..4e8f981 100644 --- a/lib/Ticket.py +++ b/lib/Ticket.py @@ -31,9 +31,11 @@ class Ticket: self.process_winnings(special_ball_wins, non_special_ball_wins) def check_numbers(self): - for num in self.my_picks: - if num in self.winning_numbers: - self.matched_numbers.append(num) + # for num in self.my_picks: + # if num in self.winning_numbers: + # self.matched_numbers.append(num) + self.matched_numbers = list( + set(self.my_picks).intersection(set(self.winning_numbers))) def check_special_ball(self): self.matched_special_ball = False @@ -60,7 +62,10 @@ class Ticket: print(f'Your Numbers: {self.my_picks}') print(f'Your {special_ball}: {self.my_special_ball}') print(f'Matched Numbers: {self.matched_numbers}') - print(f'Matched {special_ball}: {"True" if self.matched_special_ball else "False"}') + print( + f'Matched {special_ball}: ' + f'{"True" if self.matched_special_ball else "False"}' + ) if self.winnings > 0: print(f'Ticket is worth: {self.winnings}') else: diff --git a/megamillions/game.py b/megamillions/game.py index 5188804..7dafe23 100755 --- a/megamillions/game.py +++ b/megamillions/game.py @@ -5,13 +5,17 @@ from .MegaMillions import MegaMillions cur_picks = [] cur_pb = 0 -winnings = 0 +winnings = {} for idx, tkt in enumerate(my_picks): cur_picks = tkt['picks'] cur_pb = tkt['mb'] + tktnum = tkt['ticket'] pbtkt = MegaMillions(cur_picks, cur_pb) pbtkt.process_ticket() - winnings += pbtkt.get_ticket_winnings() + key = 'Ticket ' + str(tktnum) + if key not in winnings.keys(): + winnings[key] = 0 + winnings[key] += pbtkt.get_ticket_winnings() print("Total Winnings:", winnings) diff --git a/megamillions/picks.py b/megamillions/picks.py index f6bd662..2750289 100644 --- a/megamillions/picks.py +++ b/megamillions/picks.py @@ -1,4 +1,14 @@ my_picks = [ - {'picks': (1, 2, 3, 4, 5), 'mb': 9}, - {'picks': (2, 3, 4, 5, 6), 'mb': 19}, + {'picks': (9, 11, 42, 53, 69), 'mb': 22, 'ticket': 1}, + {'picks': (6, 11, 24, 42, 69), 'mb': 17, 'ticket': 1}, + {'picks': (2, 20, 24, 43, 48), 'mb': 13, 'ticket': 1}, + {'picks': (3, 7, 20, 47, 68), 'mb': 13, 'ticket': 1}, + {'picks': (5, 9, 13, 18, 25), 'mb': 9, 'ticket': 1}, + + # quick picks # + {'picks': (13, 37, 44, 50, 61), 'mb': 9, 'ticket': 2}, + {'picks': (1, 36, 43, 55, 68), 'mb': 25, 'ticket': 2}, + {'picks': (2, 13, 44, 52, 70), 'mb': 15, 'ticket': 2}, + {'picks': (8, 21, 27, 63, 64), 'mb': 2, 'ticket': 2}, + {'picks': (14, 42, 48, 57, 58), 'mb': 4, 'ticket': 2}, ] diff --git a/powerball/game.py b/powerball/game.py index 7cff0ba..a898175 100755 --- a/powerball/game.py +++ b/powerball/game.py @@ -5,13 +5,17 @@ from .Powerball import Powerball cur_picks = [] cur_pb = 0 -winnings = 0 +winnings = {} for idx, tkt in enumerate(my_picks): cur_picks = tkt['picks'] cur_pb = tkt['pb'] + tktnum = tkt['ticket'] pbtkt = Powerball(cur_picks, cur_pb) pbtkt.process_ticket() - winnings += pbtkt.get_ticket_winnings() + key = 'Ticket ' + str(tktnum) + if key not in winnings.keys(): + winnings[key] = 0 + winnings[key] += pbtkt.get_ticket_winnings() print("Total Winnings:", winnings) diff --git a/powerball/picks.py b/powerball/picks.py index fcd1e89..769abda 100644 --- a/powerball/picks.py +++ b/powerball/picks.py @@ -1,4 +1,20 @@ my_picks = [ - {'picks': (1, 2, 3, 4, 5), 'pb': 22}, - {'picks': (2, 3, 4, 5, 6), 'pb': 19}, + {'picks': (9, 11, 42, 53, 69), 'pb': 22, 'ticket': 1}, + {'picks': (6, 11, 24, 42, 69), 'pb': 17, 'ticket': 1}, + {'picks': (2, 20, 24, 43, 48), 'pb': 13, 'ticket': 1}, + {'picks': (3, 7, 20, 47, 68), 'pb': 13, 'ticket': 1}, + {'picks': (5, 9, 13, 18, 25), 'pb': 9, 'ticket': 1}, + + # Quick Picks # + {'picks': (4, 10, 17, 36, 67), 'pb': 16, 'ticket': 2}, + {'picks': (14, 20, 33, 41, 59), 'pb': 26, 'ticket': 2}, + {'picks': (32, 39, 56, 58, 67), 'pb': 23, 'ticket': 2}, + {'picks': (5, 12, 24, 61, 64), 'pb': 11, 'ticket': 2}, + {'picks': (11, 13, 16, 24, 35), 'pb': 25, 'ticket': 2}, + + {'picks': (32, 38, 47, 54, 62), 'pb': 26, 'ticket': 3}, + {'picks': (2, 10, 53, 62, 67), 'pb': 14, 'ticket': 3}, + {'picks': (1, 19, 37, 52, 66), 'pb': 22, 'ticket': 3}, + {'picks': (18, 35, 51, 65, 67), 'pb': 24, 'ticket': 3}, + {'picks': (17, 35, 42, 48, 65), 'pb': 7, 'ticket': 3}, ]