Skip to content
Closed
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
1 change: 1 addition & 0 deletions 1678/ch_1_Arthur_Zarins.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print('Hello, world! ipjsed42d')
88 changes: 88 additions & 0 deletions Island_Survival_Game_Arthur_Zarins.py
Original file line number Diff line number Diff line change
@@ -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
25 changes: 25 additions & 0 deletions PRACTICE_Classes 1.py
Original file line number Diff line number Diff line change
@@ -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)

26 changes: 26 additions & 0 deletions Rubik's cube math.py
Original file line number Diff line number Diff line change
@@ -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())
17 changes: 17 additions & 0 deletions Tester.py
Original file line number Diff line number Diff line change
@@ -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)
Binary file not shown.
Binary file not shown.
7 changes: 7 additions & 0 deletions ch_1_Arthur_Zarins.py
Original file line number Diff line number Diff line change
@@ -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)
8 changes: 8 additions & 0 deletions ch_1_Arthur_Zarins_hw.py
Original file line number Diff line number Diff line change
@@ -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'])
103 changes: 103 additions & 0 deletions ch_1_assign_Arthur_Zarins_.py
Original file line number Diff line number Diff line change
@@ -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()
111 changes: 111 additions & 0 deletions ch_2_assign_Arthur_Zarins.py
Original file line number Diff line number Diff line change
@@ -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()
Loading