Skip to content

Merge #1516

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 4, 2022
Merged

Merge #1516

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions recursiveStrings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
""" author: Ataba29
code has a matrix each list inside of the matrix has two strings
the code determines if the two strings are similar or different
from each other recursively
"""


def CheckTwoStrings(str1, str2):
# function takes two strings and check if they are similar
# returns True if they are identical and False if they are different

if(len(str1) != len(str2)):
return False
if(len(str1) == 1 and len(str2) == 1):
return str1[0] == str2[0]

return (str1[0] == str2[0]) and CheckTwoStrings(str1[1:], str2[1:])


def main():
matrix = [["hello", "wow"], ["ABSD", "ABCD"],
["List", "List"], ["abcspq", "zbcspq"],
["1263", "1236"], ["lamar", "lamars"],
["amczs", "amczs"], ["yeet", "sheesh"], ]

for i in matrix:
if CheckTwoStrings(i[0], i[1]):
print(f"{i[0]},{i[1]} are similar")
else:
print(f"{i[0]},{i[1]} are different")


main()
95 changes: 95 additions & 0 deletions russian_roulette.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
""" author: Ataba29
the code is just a russian roulette game against
the computer
"""
from random import randrange
import time


def main():

# create the gun and set the bullet
numOfRounds = 6
gun = [0, 0, 0, 0, 0, 0]
bullet = randrange(0, 6)
gun[bullet] = 1
player = False # is player dead
pc = False # is pc dead

# menu
print("/********************************/")
print(" Welcome to russian roulette")
print("/********************************/")
time.sleep(2)
print("you are going to play against the pc")
time.sleep(2)
print("there is one gun and one bullet")
time.sleep(2)
print("all you have to do is pick who starts first")
time.sleep(2)

# take input from the user
answer = input(
"please press 'm' if you want to start first or 'p' if you want the pc to start first: "
)

# check input
while answer != "m" and answer != "p":
answer = input("please enter again ('m' or 'p'): ")

# set turn
if answer == 'm':
turn = "player"
else:
turn = "pc"

# game starts
while numOfRounds != 0 and (pc == False and player == False):
print(f"\nRound number {numOfRounds}/6")
time.sleep(1)
print("the gun is being loaded")
time.sleep(3)
print("the gun is placed on " + ("your head" if turn ==
"player" else "the cpu of the pc"))
time.sleep(3)
print("and...")
time.sleep(1)
print("...")
time.sleep(2)
print("...")
time.sleep(2)
print("...")
time.sleep(2)

# get the bullet in the chamber
shot = gun.pop(numOfRounds - 1)

if shot:
print("THE GUN WENT OFF!!!")
print("YOU DIED" if turn == "player" else "THE PC DIED")
if turn == "player": # set up who died
player = True
else:
pc = True
else:
print("nothing happened phew!")
if turn == "player": # flip the turn
turn = "pc"
else:
turn = "player"

time.sleep(2)
numOfRounds -= 1

time.sleep(1)
print("")
if player:
print("sorry man you died better luck next time")
print("don't forget to send a pic from heaven :)")
else:
print("good job man you survived")
print("you just got really lucky")
print("anyways hope you had fun because i sure did")


main()