Skip to content

Commit

Permalink
updating main (#3)
Browse files Browse the repository at this point in the history
I haven't updated main in a while. Updating main via gh web.
  • Loading branch information
iamserda authored Jan 30, 2025
2 parents f4b3c4d + e7d7a28 commit 86bf0f1
Show file tree
Hide file tree
Showing 427 changed files with 30,861 additions and 217 deletions.
Binary file removed .DS_Store
Binary file not shown.
151 changes: 0 additions & 151 deletions 2024/card_issuer/main.py

This file was deleted.

2 changes: 0 additions & 2 deletions 2024/leetcode/27/challenge.py

This file was deleted.

58 changes: 0 additions & 58 deletions 2025/README.md

This file was deleted.

6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

### EXTRA RESOURCES (Some Paid, Some Free):
- [Interesting Code](https://www.keithschwarz.com/interesting/) by Stanford Prof. Keith Schawrz
- [Advent of Code [2025]](https://adventofcode.com/2025)
- [Advent of Code [2024]](https://adventofcode.com/2024)
- [Advent of Code [2023]](https://adventofcode.com/2023)
- [Advent of Code [2022]](https://adventofcode.com/2022)
- [Advent of Code [202]](https://adventofcode.com/2021)
Expand All @@ -21,7 +23,9 @@
- [Advent of Code [2017]](https://adventofcode.com/2017)
- [Advent of Code [2016]](https://adventofcode.com/2016)
- [Advent of Code [2015]](https://adventofcode.com/2015)
- [Marlen09](https://leetcode.com/Marlen09/)

### LEETCODE.COM:
- [leetcoder: Marlen09](https://leetcode.com/Marlen09/)

## SEE THE FUTURE:
In the future, I plan to add more content like:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
81 changes: 81 additions & 0 deletions card_issuer/helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import random

amex_issued_set = set()
visa_issued_set = set()
master_issued_set = set()


def issue_card(user_credit):
"""issue card based on credit"""
if user_credit < 300 or user_credit > 850:
print("One of our Client Concierge will be with your shorty!")
return None

if user_credit >= 720:
print("Excellent, we can offer you the Deluxe AMEX card.\nProcessing....\n")
return select_card("amex")

if user_credit >= 690:
print("Great, we can offer you our Premium VISA card.\nProcessing....\n")
return select_card("visa")

if user_credit >= 630:
print(
"Awesome, we can offer you own of our Premium MASTERCard.\nProcessing....\n"
)
return select_card("master")


def get_servicers():
"""returns an object of card servicers available at the firm"""
return {
"amex": {"function": amex_factory, "issued": amex_issued_set},
"visa": {"function": visa_factory, "issued": visa_issued_set},
"master": {"function": master_factory, "issued": master_issued_set},
}


def select_card(pmt_servicer: str) -> str:
"""selects card for customer"""
if not pmt_servicer or pmt_servicer not in ["amex", "visa", "master"]:
error_message = "Card Payment Servicer was not provided. Info logged. Application will terminate now."
raise ValueError(error_message)
servicers = get_servicers()
card_generator = servicers[pmt_servicer]["function"]
issued_cards_set = servicers[pmt_servicer]["issued"]
return generate_card(pmt_servicer, card_generator, issued_cards_set)


def generate_card(svc, card_generator, verifier):
"""generates a new card based on servicer:str, card_generator:def, verifier:set"""
new_card = card_generator()
while new_card in verifier:
new_card = card_generator()
return new_card


def amex_factory():
"""generates a fake amex card"""
amex_id = random.randint(32000, 85000)
group_nums = random.randint(312123, 985430)
customer_nums = random.randint(32000, 85000)
return f"{amex_id}-{group_nums}-{customer_nums}"


def visa_factory():
"""generates a fake visa card"""
visa_id = random.randint(4100, 4999)
bank_id = random.randint(1111, 9000)
group_id = random.randint(1110, 9900)
client_id = random.randint(1100, 9990)
return f"{visa_id}-{bank_id}-{group_id}-{client_id}"


def master_factory():
"""a fake master card generator"""

issuer_id = random.randint(5100, 5999)
group_id1 = random.randint(1111, 9999)
group_id2 = random.randint(1111, 9999)
customer_id = random.randint(1111, 9999)
return f"{issuer_id}-{group_id1}-{group_id2}-{customer_id}"
77 changes: 77 additions & 0 deletions card_issuer/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
"""importing datetime module"""
import datetime
import random
from helpers import issue_card

scapital_clients = {}


def get_user_info(new_user=True):
"""prompt user for information to create account"""
if new_user:
print(f"System Time: {datetime.datetime.now()}")
fname = input("Enter your first name: ")
lname = input("Enter your last name: ")
username, pwd = create_user_profile()
m, d, y = input("Enter DOB: MM-DD-YYYY: ").split("-")
dob = datetime.datetime(year=int(y), month=int(m), day=int(d))
credit_score = int(input("Enter your FICO score: "))

scapital_clients[username]["first"] = fname
scapital_clients[username]["last"] = lname
scapital_clients[username]["dob"] = dob
scapital_clients[username]["password"] = pwd
scapital_clients[username]["credit_score"] = credit_score

return username


def create_user_profile():
"""creates user profile"""
username = input("Enter your username: ")

while username in scapital_clients.keys():
print("This username already exist, please try again")
username = input("Enter your username: ")

pwd_constraints = "Passwords must be: 8 characters long and alphanumeric."
password = input(pwd_constraints + "\nEnter your password: ")
while not password or len(password) <= 8 or not str(password).isalnum():
password = input("Enter your password: ")
scapital_clients[username] = {"user": username, "pwd": password}
return username, password


def start_app(start=False):
if start:
print("Welcome to Simus Capital Premium Cards Service!")
username = get_user_info()
user_data = scapital_clients[username]
fname = user_data["first"]
greeting = f"Hi {fname}!"
print(greeting)
print()
print("Accessing credit history...")
card_issued = issue_card(user_data["credit_score"])
# print(card_issued)s
if card_issued is None:
print(
"Please provide your local contact phone number,\nand a member of our client concierge will reach out to you\nwithin 60 minutes."
)
contact_number = input()
scapital_clients[username]["phone"] = (
contact_number
if len(contact_number) >= 8
else "".join("555-555-5555".split("-"))
)
print(f"{scapital_clients[username]["first"]}, thank you for using S Capital as your preferred financial institution.")
print(f"Our team will review your account and get back to you within 30 days.")
print(f"We will contact you at {scapital_clients[username]["phone"]}")
return
scapital_clients[username]["card1"] = card_issued
print("Congratulations!")
print("Welcome to the Simus Capital card-holders family!")
print(f"Your new car number is {scapital_clients[username]['card1']}")

if __name__ == "__main__":
start_app(start=True)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 86bf0f1

Please sign in to comment.