diff --git a/EquilibriumIndex.py b/EquilibriumIndex.py index b691b90..b2395b6 100644 --- a/EquilibriumIndex.py +++ b/EquilibriumIndex.py @@ -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 diff --git a/TrueBooj.py b/TrueBooj.py index 4b558b4..0590b15 100644 --- a/TrueBooj.py +++ b/TrueBooj.py @@ -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)