diff --git a/recursiveStrings.py b/recursiveStrings.py new file mode 100644 index 00000000000..874a1b0a104 --- /dev/null +++ b/recursiveStrings.py @@ -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() diff --git a/russian_roulette.py b/russian_roulette.py new file mode 100644 index 00000000000..337f8be8a86 --- /dev/null +++ b/russian_roulette.py @@ -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()