Skip to content
Open
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
7 changes: 0 additions & 7 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +0,0 @@
{
"files.associations": {
"iosfwd": "cpp",
"__node_handle": "cpp"
}
"python.pythonPath": "C:\\Users\\9dayl\\AppData\\Local\\Programs\\Python\\Python37\\python.exe"
}
45 changes: 45 additions & 0 deletions week-4/Python/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from collections import deque


def sum_lists():
#I dont know how we were supposed to input the #'s but
# I'd just use a standard iterative input loop until None
ll1=deque([5,6,3])
ll2=deque([8,4,2])

#used to represent the tens place
multi=1
total=0
#this makes multiplying easy since I can start at the
#ones place
ll1.reverse()
for num in ll1:
total+=num*multi
multi*=10

#Repeats the same process
multi=1
ll2.reverse()

for num in ll2:
total+=num*multi
multi*=10
print(total)

def words_reverse():
s=deque(["I"," ","l","o","v","e"," ","g","e","e","k","s"," ","f","o","r"," ","g","e","e","k","s"])
templist=""
#check to see if it's one word
if " " not in s:
print(s)
else:
#copy deque using a string, then split by spaces
for i in s:
templist+=i
templist=templist.split(" ")

#return split version to s, then reverse it
s=deque(templist)
s.reverse()
print(s)

91 changes: 91 additions & 0 deletions week-6/Python/daylen-robertson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import binarytree
from binarytree import Node, build


#Creates a mirror of the tree
def mirror():
#Pass in any values to create a tree
values = [7, 3, 2, 6, 9, 1, 5, 8]
if len(values)==1:
print(values)
elif len(values)==0:
print("None")
else:
tree1=build(values)

for i in range(len(tree1)):
try:
temp=tree1[i].left
tree1[i].left=tree1[i].right
tree1[i].right=temp
except:
print("no index")

print(tree1)





#By alternating, we're able to go down the path where the leaf is
def make_branches(leaf,branches,branchess):

for num in range(len(tree1)):
if leaves[leaf] in tree1[num].left:
#adds to branch
branches.append(tree1[num].left)
#checks if we're done with this branch
if tree1[num].left==leaves[leaf]:
branchess.append(branches)
branches=[]
break
elif leaves[leaf] in tree1[num].right:
branches.append(tree1[num].right)
if tree1[num].right==leaves[leaf]:
branchess.append(branches)
branches=[]
break

#This runs the code that recursively creates root to leaf branches
#Pass in any values you'd like
values = [7, 3, 2, 6, 9, 1, 5, 8]
if len(values)==1:
print(values)
elif len(values)==0:
print("None")
else:
tree1=build(values)
branchess=[]
branch=list(tree1)
leaves=tree1.leaves
for leaf in range(len(leaves)):
branches=[tree1[0]]
make_branches(leaf,branches,branchess)
print(branchess)


#MUST RUN BRANCH CREATION FUNCTION FIRST
#finds max difference between node and differences
def max_diff(branchess):
branchess.extend((list(tree1),list(tree1.left),list(tree1.right)))

newBranch=[]
newBranches=[]
#This is to get rid of the new lines and help us retrieve the numeric representation of the nodes
for branch in branchess:
branch=str(branch).strip('\n')
for i in list(branch):
if i.isnumeric():
newBranch.append(int(i))
newBranches.append(newBranch)
newBranch=[]

print(newBranches)
maxDiff=0

#this is to compare the differences between each node and it's decendants
for branchDiff in newBranches:

if maxDiff<(max(branchDiff)-min(branchDiff)):
maxDiff=(max(branchDiff)-min(branchDiff))
print(maxDiff)
46 changes: 46 additions & 0 deletions week-8/Python/daylen-robertson.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

def stone_love():
from bisect import bisect_left
#On hacker earth the first test case is incorrect bc their output doesn't make sense with the input.
#I could be wrong though, if so, I have code that will run for that too, just a simple nested for loop
#The loop uses a dictionary with # stone keys and day values and checks if the value is >= Q
#That was time inefficient though
num=input().split()
n=int(num[0])
qq=int(num[1])
numStone=input().split()
qStones=input().split()



total=0
array=[]
for j in numStone:
total+=int(j)
array.append(total)

for q in qStones:
print(bisect_left(array,int(q))+1)


def repeated_k_times():
n=int(input())
array=input().split()
array.sort()
arrayset=set(array)
arrayset=sorted(arrayset)
dic=dict.fromkeys(arrayset)


k=int(input())

#sets values to 0
for i in dic:
dic[i]=0

#When it equals k, print #
for i in array:
dic[i]+=1
if int(dic[i])==k:
print (i)
break
Empty file removed week-8/Python/main.py
Empty file.