diff --git a/1678/ch_1_Arthur_Zarins.py b/1678/ch_1_Arthur_Zarins.py new file mode 100644 index 0000000..e378fc3 --- /dev/null +++ b/1678/ch_1_Arthur_Zarins.py @@ -0,0 +1 @@ +print('Hello, world! ipjsed42d') \ No newline at end of file diff --git a/Island_Survival_Game_Arthur_Zarins.py b/Island_Survival_Game_Arthur_Zarins.py new file mode 100644 index 0000000..47f2310 --- /dev/null +++ b/Island_Survival_Game_Arthur_Zarins.py @@ -0,0 +1,88 @@ +import random +squares = {} +size = 7 +xPos = size // 2 +yPos = size // 2 +for x in range(size): + for y in range(size): + # Add a square + squares.update({str(x) + "-" + str(y): True}) +# print(squares) + + +def printBoard(): + for y in range(size): + line = "" + for x in range(size): + # Add a square + boolo = squares[str(x) + "-" + str(y)] + if boolo == True: + if y == yPos and x == xPos: + line = line + "Pl" + else: + line = line + "[]" + else: + line = line + " " + print(line) + + # else: + # Off-board +# End of function +game = True +while game == True: + printBoard() + legalMove = False + while legalMove == False: + oX = xPos + oY = yPos + move = input("Where will you move? wasd controls\n ") + if move == "w": + yPos = yPos - 1 + if -1 < xPos < size and -1 < yPos < size: + legalMove = True + elif move == "a": + xPos = xPos - 1 + if -1 < xPos < size and -1 < yPos < size: + legalMove = True + elif move == "s": + yPos = yPos + 1 + if -1 < xPos < size and -1 < yPos < size: + legalMove = True + elif move == "d": + xPos = xPos + 1 + if -1 < xPos < size and -1 < yPos < size: + legalMove = True + else: + print("Invalid move") + # Return to last pos if unaccepted + if legalMove == False: + xPos = oX + yPos = oY + # end + # Remove terrain + RX = 0 + RY = 0 + while (RX == xPos and RY == yPos) or squares[str(str(RX) + "-" + str(RY))] == False: + # We want to remove a new part of the Island, and not kill the player + RX = random.randint(0, size) + RY = random.randint(0, size) + if RX >= size: + RX = size - 1 + if RY >= size: + RY = size - 1 + if RX == xPos and RY == yPos: + print() + else: + squares.update({str(RX) + "-" + str(RY): False}) + good = 0 + for x in range(size): + for y in range(size): + # Add to good square count + if squares[str(xPos) + "-" + str(yPos)] == True: + good = good + 1 + if squares[str(xPos) + "-" + str(yPos)] == False: + print("GAME OVER") + game = False + if good < 1: + print("You win!") + game = False diff --git a/PRACTICE_Classes 1.py b/PRACTICE_Classes 1.py new file mode 100644 index 0000000..1a1bb57 --- /dev/null +++ b/PRACTICE_Classes 1.py @@ -0,0 +1,25 @@ +class Bot(): + + def __init__(self, pos, name): + self.name = name + self.pos = pos + self.arm = 0 + self.cube = False + def roll(self, distance): + self.pos = self.pos + distance + def armMove(self, distance): + self.arm = self.arm + distance + def pick(self): + if self.pos == 3: + self.cube = True +Rob = Bot(0, "Rob") +while True: + print("Robot is at pos " + str(Rob.pos) + " with arm pos " + str(Rob.arm) + " and cube is " + str(Rob.cube)) + func = input("cube, roll, armMove?") + if func == "cube": + Rob.pick() + elif func == "armMove": + Rob.armMove(1) + elif func == "roll": + Rob.roll(1) + \ No newline at end of file diff --git a/Rubik's cube math.py b/Rubik's cube math.py new file mode 100644 index 0000000..5b4719c --- /dev/null +++ b/Rubik's cube math.py @@ -0,0 +1,26 @@ + +# Credits: +# Christopher Mowla for providing the function @ https://docs.google.com/file/d/0Bx0h7-zg0f4NTUM1MWUtaDJrbms/edit +# Arthur Zarins for compiling the code +import math + + +class cube(): + def __init__(self, size): + self.size = size + + def combos(self): + # 8 corners have 8 possibilities + total = math.factorial(8) * (3 ** 7) / 24 ** ((self.size + 1) % 2) + # add center edges + total = total * ((math.factorial(12) * (2 ** 10)) ** (self.size % 2)) + # add wing edges + total = total * (math.factorial(24) ** round((self.size - 2) / 2)) + # add centers + total = total * ((math.factorial(24) / (math.factorial(4) ** 6)) + ** round(((self.size - 2) / 2) ** 2)) + return total + +#Disclaimer: This may return inf (infinity) for 10x10 cubes and up. Sadly, computer calculators are also limited. +myCube = cube(9) +print(myCube.combos()) diff --git a/Tester.py b/Tester.py new file mode 100644 index 0000000..43621fd --- /dev/null +++ b/Tester.py @@ -0,0 +1,17 @@ +# Fun test program +testA = "3|(y + |(y^2 + z^3)) + 3|(y - |(y^2 + z^3)) - b/3a" +testB = "c/3a - b^2/9a^2" +testC = "-b^3/37a^3 + bc/6a^2 - d/2a" +answerA = input("x = ") +if(answerA == testA or answerA == "skip"): + answerB = input("z = ") + if(answerB == testB or answerB == "skip"): + answerC = input("y = ") + if(answerC== testC or answerC == "skip"): + answerC = input("Congrats! All questions are correct") + else: + print("x ACTUALLY = " + testC) + else: + print("x ACTUALLY = " + testB) +else: + print("x ACTUALLY = " + testA) diff --git a/__pycache__/ch_1_assign_Arthur_Zarins_.cpython-37.pyc b/__pycache__/ch_1_assign_Arthur_Zarins_.cpython-37.pyc new file mode 100644 index 0000000..eca5102 Binary files /dev/null and b/__pycache__/ch_1_assign_Arthur_Zarins_.cpython-37.pyc differ diff --git a/__pycache__/ch_2_assign_Arthur_Zarins.cpython-37.pyc b/__pycache__/ch_2_assign_Arthur_Zarins.cpython-37.pyc new file mode 100644 index 0000000..88a4f1d Binary files /dev/null and b/__pycache__/ch_2_assign_Arthur_Zarins.cpython-37.pyc differ diff --git a/ch_1_Arthur_Zarins.py b/ch_1_Arthur_Zarins.py new file mode 100644 index 0000000..34c7f24 --- /dev/null +++ b/ch_1_Arthur_Zarins.py @@ -0,0 +1,7 @@ +print('Hello, world!') +print("To run this in VS code, use Ctrl Fn F5") +print("1678 PARENT INFO NIGHT this saturday! 4:30-6:30") +print("Get dad's signature on da WPR") +x = "a" +y = isinstance(x, int) +print(y) \ No newline at end of file diff --git a/ch_1_Arthur_Zarins_hw.py b/ch_1_Arthur_Zarins_hw.py new file mode 100644 index 0000000..e416439 --- /dev/null +++ b/ch_1_Arthur_Zarins_hw.py @@ -0,0 +1,8 @@ +#Reminder for self: to run python programs in Visual Studio code, use Cntrl + Fn + F5 +teams = { + '1678': {'Weight':200, 'Wheels': 4, 'Speed': 9}, + '2583': {'Weight': 300, 'Wheels': 325, 'Speed': 3} +} +def teamStats(teamName): + print("Team " + teamName + " is awesome") +print(teams['1678']['Weight']) \ No newline at end of file diff --git a/ch_1_assign_Arthur_Zarins_.py b/ch_1_assign_Arthur_Zarins_.py new file mode 100644 index 0000000..92effc0 --- /dev/null +++ b/ch_1_assign_Arthur_Zarins_.py @@ -0,0 +1,103 @@ +# Reminder for self: to run python programs in Visual Studio code, use Cntrl + Fn + F5 +teams = { + "1678": {'name': "Citrus", + 'Last Year': 2019, + 'Location': "Davis CA", + 'Rookie Year': 2005, + 'Events': "Sac Regional, Central Valley Regional, AeroSpace Valley Regional, Carver division, Einstein field, RCC Qianjiang International Robotics Invitational, Chezy Champs", + 'Awards': "Capital City Classic 2019, 2018 Madtown Finalist, 2018 Chezy Champs Finalist", + "Competed At": "Davis CA, Fresno CA, Houston TX, Lancaster CA" + }, + "2551": {'name': "Penguins", + 'Last Year': 2019, + 'Location': "Novato CA", + 'Rookie Year': 2008, + 'Events': 'Sac Regional, SF Regional, Galileo divison', + 'Awards': "UC Davis highest rookie seed award, 2018 Sac regional innovation in control", + "Competed At": "San Francisco CA, Sacramento CA, Houston TX, Elk Grove CA" + }, + "3421": {'name': "LizzardTech", + 'Last Year': 2013, + 'Location': "Marysville MI", + 'Rookie Year': 2010, + 'Events': 'MI FRC state championship', + 'Awards': "Liviona district 2012 cooperation award", + "Competed At": "Flint MI, Livonia MI, Ypsilanti MI"}, + "2942": {'name': "PandaRobotics", + 'Last Year': 2018, + 'Location': "Seattle, WA", + 'Rookie Year': 2009, + 'Events': 'Seattle', + 'Awards': "2009 Seattle Imagery award", + "Competed At": "Auburn WA"}, + "3890": {'name': "FakeTeamname", + 'Last Year': 2015, + 'Location': "Boulder, Colorado", + 'Rookie Year': 2003, + 'Events': 'South pacific regional', + 'Awards': "South pacific regional Woodie Flowers award", + "Competed At": "San Francisco CA, Houston TX, Elk Grove CA, Sacramento CA"} + +} +#reference = "is" +def getList(dict): + list = [] + for key in dict.keys(): + list.append(key) + + return list +def nameSweep(teamStrname): + teamNums = getList(teams) + #print(teamNums) + for x in teamNums: + if(teams[x]["name"] == teamStrname): + return x + return 0 + +def teamStats(teamname, attribute): + # New variable refernce will handle grammer related to pluralities + if (attribute == "Events" or attribute == "Rookie Year" or attribute == "Location" or attribute == "Last Year" or attribute == "Awards" or attribute == "Competed At"): + if(teamname in teams): + reference = "is" + stringTest = str(teams[teamname][attribute]).split(",") + attributeDisplay = attribute + if attribute == "Events" and len(stringTest) > 2: + reference = "are" + else: + if attribute == "Events": + attributeDisplay = "only Event" + reference = "is" + + print("Team " + str(teamname) + "'s " + str(attributeDisplay) + + " " + str(reference) + " " + str(teams[teamname][attribute])) + elif (nameSweep(teamname) in teams): + teamname = nameSweep(teamname) + reference = "is" + stringTest = str(teams[teamname][attribute]).split(",") + attributeDisplay = attribute + if attribute == "Events" and len(stringTest) > 2: + reference = "are" + else: + if attribute == "Events": + attributeDisplay = "only Event" + reference = "is" + + print("Team " + str(teamname) + "'s " + str(attributeDisplay) + + " " + str(reference) + " " + str(teams[teamname][attribute])) + else: + print("That team does not exist") + else: + print("That stat does not exist") + +def runContinuous(): + while(True): + a1 = input("What is the team number?\n ") + a2 = input("What's the stat?\n ") + teamStats(a1, a2) + + +# If you want to run the program, uncomment the following line (commented so chapter 3 can work): +# runContinuous() +if __name__ == "__main__": + #Only runs if assignment 1 is called + runContinuous() diff --git a/ch_2_assign_Arthur_Zarins.py b/ch_2_assign_Arthur_Zarins.py new file mode 100644 index 0000000..8543643 --- /dev/null +++ b/ch_2_assign_Arthur_Zarins.py @@ -0,0 +1,111 @@ +import ch_1_assign_Arthur_Zarins_ +# Reminder for self: to run python programs in Visual Studio code, use Cntrl + Fn + F5 + + +def is_number(s): + try: + float(s) + return True + except ValueError: + pass + + +def add(team): + if(str(team) not in ch_1_assign_Arthur_Zarins_.teams): + if is_number(team) == True: + ch_1_assign_Arthur_Zarins_.teams.update({str(team): {"name": "", + "language": "", + "width": "", + "length": "", + "motors": "", + "cameraVision": False + }}) + print("Team " + str(team) + " added successfully.\n ") + else: + print("Team name must be a number") + else: + print("This team already exists") + + +def update(team, stat, updateTxt): + if search(team) == True: + ch_1_assign_Arthur_Zarins_.teams[team].update( + {str(stat): str(updateTxt)}) + print("Successfully updated an attribute of " + team) + + +def remove(team): + if(search(team)): + ch_1_assign_Arthur_Zarins_.teams.pop(str(team), None) + + +def search(team): + if(str(team) in ch_1_assign_Arthur_Zarins_.teams): + print("Team " + team + " exists") + return True + else: + print("Error: team " + team + " does not exist") + return False + + +def listTeams(): + teamList = [] + for i in ch_1_assign_Arthur_Zarins_.teams.keys(): + teamList.append(i) + print("All teams: ") + print(teamList) + + +def teamStats(team): + if(search(team)): + print("Stats for team " + team + ":") + print(ch_1_assign_Arthur_Zarins_.teams[team]) +# Now we can ask questions + + +def runContinuous(): + while True: + # constant prompt + function = input( + "HOME. Type one of the following commands: 1)add 2)update 3)remove 4)search 5)listTeams 6)teamStats\n ") + if function == "add": + # Adds a new team to the database + a1 = input( + "What is the team number? This is how the team will be referred to. WARNING: DUPLICATE TEAM name OVERWRITES OLD DATA\n ") + add(str(a1)) + elif function == "update": + # Updates a team attribute + # MUST REFER TO IT Y NUMBER + a1 = input( + "What is the team number? NAMES NOT ALLOWED for this attribute\n ") + a2 = input( + "What is the team attribute? (name/motors/cameraVision/language/width/length)\n ") + a3 = input("What is the team attribute NEW value?\n ") + update(a1, a2, a3) + elif function == "remove": + # Removes a team + a1 = input("What is the team number / name?\n ") + if(int(ch_1_assign_Arthur_Zarins_.nameSweep(a1)) > 0): + a1 = ch_1_assign_Arthur_Zarins_.nameSweep(a1) + remove(a1) + elif function == "search": + # States if a team exists + a1 = input("What is the team number / name?\n ") + if(int(ch_1_assign_Arthur_Zarins_.nameSweep(a1)) > 0): + a1 = ch_1_assign_Arthur_Zarins_.nameSweep(a1) + search(a1) + elif function == "listTeams": + # State all existing teams + listTeams() + elif function == "teamStats": + # States the stats for the team, specifically the attributes + a1 = input("What is the team number / name?\n ") + if(int(ch_1_assign_Arthur_Zarins_.nameSweep(a1)) > 0): + a1 = ch_1_assign_Arthur_Zarins_.nameSweep(a1) + teamStats(a1) + + +# Uncomment the following line to run the program: +if __name__ == "__main__": + # only run the program if chapter 2 is called + runContinuous() diff --git a/ch_3_assign_Arthur_Zarins.py b/ch_3_assign_Arthur_Zarins.py new file mode 100644 index 0000000..c5f4de2 --- /dev/null +++ b/ch_3_assign_Arthur_Zarins.py @@ -0,0 +1,3 @@ +import ch_2_assign_Arthur_Zarins +import ch_1_assign_Arthur_Zarins_ +ch_2_assign_Arthur_Zarins.runContinuous() \ No newline at end of file diff --git a/ch_4_assign_Arthur_Zarins.py b/ch_4_assign_Arthur_Zarins.py new file mode 100644 index 0000000..303a7e4 --- /dev/null +++ b/ch_4_assign_Arthur_Zarins.py @@ -0,0 +1,58 @@ +import math + + +def is_number(s): + try: + float(s) + return True + except ValueError: + pass + + +class Point: + def __init__(self, x, y): + self.x = x + self.y = y + + def distance(self): + if (is_number(self.x) and is_number(self.y)): + return math.sqrt(float(self.x) ** 2 + float(self.y) ** 2) + else: + return -1 + + +class Point3d(Point): + def __init__(self, x, y, z): + super().__init__(x, y) + self.z = z + + def distance(self): + if (is_number(self.x) and is_number(self.y) and is_number(self.z)): + return math.sqrt(float(self.z) ** 2 + super().distance() ** 2) + else: + return -1 + + +while True: + a1 = input("give the x value of the 2d point \n") + a2 = input("give the y value of the 2d point\n") + a3 = input("give the x value of the 3d point\n") + a4 = input("give the y value of the 3d point\n") + a5 = input("give the z value of the 3d point\n") + boringPoint2d = Point(a1, a2) + coolPoint = Point3d(a3, a4, a5) + + if boringPoint2d.distance() == -1: + print("The 2d point has arguements that are not real numbers") + if coolPoint.distance() == -1: + print("The 3d point has arguements that are not real numbers") + if boringPoint2d.distance() == coolPoint.distance(): + print("They have equal distances") + if boringPoint2d.distance() > coolPoint.distance(): + print("The 2d point's furthur away from the orgin") + elif boringPoint2d.distance() < coolPoint.distance(): + print("The 3d point's furthur away from the orgin") + print("The distance from the 2d point to orgin: " + + str(boringPoint2d.distance())) + print("The distance from the 3d point to orgin: " + str(coolPoint.distance())) +