Proof of concept
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
__pycache__/
|
||||
55
proof_of_concept/credit_cardle.py
Normal file
55
proof_of_concept/credit_cardle.py
Normal file
@@ -0,0 +1,55 @@
|
||||
import random
|
||||
|
||||
import credit_cards
|
||||
|
||||
GUESSES = 5
|
||||
|
||||
def main():
|
||||
card: credit_cards.CreditCard = random.choice(credit_cards.credit_cards)
|
||||
|
||||
correct_issuer = False
|
||||
correct_card = False
|
||||
|
||||
for guess in range(GUESSES):
|
||||
if guess == 0:
|
||||
print(f"Annual Fee: {card.annual_fee}")
|
||||
print(f"Signup Bonus: {card.signup_bonus}")
|
||||
print(f"Default Multiplier: {card.default_multiplier}")
|
||||
elif guess == 1:
|
||||
print(f"Points type: {card.points_type.value}")
|
||||
elif guess == 2:
|
||||
print(f"Category Multipliers: {[f'{multiplier[0].name}, {multiplier[1]}' for multiplier in card.category_multipliers]}")
|
||||
else:
|
||||
other_index = guess-3
|
||||
if other_index < len(card.other):
|
||||
print(f"Other: {card.other[other_index]}")
|
||||
|
||||
while True:
|
||||
if not correct_issuer:
|
||||
issuer_guess = input("Issuer Guess?")
|
||||
if issuer_guess in credit_cards.CardIssuer:
|
||||
issuer_guess = credit_cards.CardIssuer(issuer_guess)
|
||||
break
|
||||
|
||||
while True:
|
||||
card_name_guess = input("Card Name Guess?")
|
||||
if card_name_guess not in credit_cards.card_names_by_issuer[issuer_guess]:
|
||||
print(credit_cards.card_names_by_issuer[issuer_guess])
|
||||
else:
|
||||
break
|
||||
|
||||
|
||||
if issuer_guess == card.issuer and not correct_issuer:
|
||||
correct_issuer = True
|
||||
print("Correct issuer Guess!")
|
||||
|
||||
if card_name_guess == card.card_name:
|
||||
correct_card = True
|
||||
print("Correct card guess!")
|
||||
|
||||
if correct_issuer and correct_card:
|
||||
break
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
84
proof_of_concept/credit_cards.py
Normal file
84
proof_of_concept/credit_cards.py
Normal file
@@ -0,0 +1,84 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import NamedTuple, Tuple
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
from enum import Enum, auto
|
||||
|
||||
class CardIssuer(Enum):
|
||||
AmericanExpress="American Express"
|
||||
|
||||
class SignUpBonus(NamedTuple):
|
||||
points: int
|
||||
time_months: int
|
||||
spend: int
|
||||
|
||||
class PointsCategory(Enum):
|
||||
Hotel=auto
|
||||
Travel=auto
|
||||
Delta=auto
|
||||
Gas=auto
|
||||
Restaurant=auto
|
||||
SuperMarket=auto
|
||||
|
||||
class PointsType(Enum):
|
||||
CashBack=auto
|
||||
DeltaSkyMiles="Delta SkyMiles®"
|
||||
|
||||
|
||||
@dataclass
|
||||
class CreditCard:
|
||||
issuer: CardIssuer
|
||||
card_name: str
|
||||
annual_fee: int
|
||||
signup_bonus: SignUpBonus
|
||||
points_type: PointsType
|
||||
default_multiplier: float
|
||||
category_multipliers: Sequence[Tuple[PointsCategory, float]]
|
||||
other: Sequence[str]
|
||||
|
||||
|
||||
credit_cards = [
|
||||
CreditCard(
|
||||
CardIssuer.AmericanExpress,
|
||||
"Delta SkyMiles® Reserve American Express Card",
|
||||
650,
|
||||
SignUpBonus(70000, 6, 5000),
|
||||
PointsType.DeltaSkyMiles,
|
||||
1,
|
||||
[
|
||||
(PointsCategory.Delta, 3)
|
||||
],
|
||||
[
|
||||
"15 Visits per Medallion® Year to the Delta Sky Club® when flying Delta",
|
||||
"$2,500 Medallion® Qualification Dollars with MQD Headstart each Medallion Qualification Year and earn $1 MQD for each $10 in purchases",
|
||||
"$240 Resy Credit",
|
||||
"$120 Rideshare Credit",
|
||||
"15% off when using miles to book Award Travel",
|
||||
]
|
||||
),
|
||||
CreditCard(
|
||||
CardIssuer.AmericanExpress,
|
||||
"Delta SkyMiles® Gold American Express Card",
|
||||
150,
|
||||
SignUpBonus(50000, 6, 2000),
|
||||
PointsType.DeltaSkyMiles,
|
||||
1,
|
||||
[
|
||||
(PointsCategory.Delta, 3)
|
||||
(PointsCategory.Restaurant, 2),
|
||||
(PointsCategory.SuperMarket, 2),
|
||||
],
|
||||
[
|
||||
"15% off when using miles to book Award Travel",
|
||||
"$200 Delta Flight Credit: After you spend $10,000 in purchases on your Card in a calendar year, you can receive a $200 Delta Flight Credit to use toward future travel.",
|
||||
"$100 Delta Stays Credit: Get up to $100 back per year as a statement credit after using your Delta SkyMiles® Gold American Express Card to book prepaid hotels or vacation rentals through Delta Stays on delta.com.",
|
||||
]
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
card_names_by_issuer = {issuer: [] for issuer in CardIssuer}
|
||||
|
||||
for card in credit_cards:
|
||||
card_names_by_issuer[card.issuer].append(card.card_name)
|
||||
Reference in New Issue
Block a user