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
20 changes: 19 additions & 1 deletion EquilibriumIndex.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,20 @@
def eqindex(data):
#do code here
'''
a generator function that returns the equilibruim indices of a given list
'''

# get the sums of the reversed data list (data[-1], data[-1] + data[-2+],
# data[-1] + data[-2] + data[-3], ect.)
bw_sums = [sum(data[::-1][:i+1]) for i, x in enumerate(data[::-1])]
# initialize a value to hold the sums of the values
sums = 0
# loop through each value in the list
for i, n in enumerate(data):
# add the value to the sums variable
sums += n
# check if sums is in backwards sum list, excluding the reverse index
# and higher of the initial list
if sums in bw_sums[:-(i+1)]:
# add one so indices ar x[1], x[2], ... x[n] rather than
# x[0], x[1], ... x[n-1]
yield i + 1
14 changes: 13 additions & 1 deletion TrueBooj.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
def truebooj(number):
# do code here
'''
function to return a number, or a string depending on if the remainder of
the number argument divided by 3, 5, or 10 is = 0
'''

if number % 10 == 0:
return 'TrueBooj'
elif number % 5 == 0:
return 'Booj'
elif number % 3 == 0:
return 'True'
else:
return str(number)