Is there a better way of solving Number Series questions using Python other than teaching it basic pattern rules and hoping the rules fit the question? For example. we would have a list of functions that has a rule for each of them and see if the series fits. Is there a Library that does this, and if not am I stuck writing functions every time a new pattern comes along?
given_series = #random series
def maybe_fib(series):
#solve the fib
throw error if wrong
def add_iterating_numbers(series):
#solve the series
throw error if wrong
.
.
.
.
.
list_of_possible_match = [maybe_fib, add_iterating_numbers, . . . , #list like fib, adding prime, taking the first 3 numbers and doing somethign with it]
for each_method in list_of_possible_match:
try:
each_method(given_series)
catch error:
print("didn't work out try another one")
if all_fail:
#teach me new function/method?
Number Series is basically a series of numbers and you have to find the next number that follows up. They can range from simple math patterns, to counting the number of corners in a number like '7' would be 1.
Examples of Number Series:
1 1 2 3 5 8 13 21 34 55 89 (?) - The next number would be 144
1 2 4 7 11 16 (?) - The next number would be 22