(In reply to
Too many to list by Jer)
Jer was right.
Below is a recursive program which solves the problem. It gave the exact values as in Jer's solution.
I then ran the program for all length sequences up to 3^10 and compiled a list of the smallest and largest values. It turns out both sequences are in Sloane's at oeis.org
The smallest is A007051 a(n) = (3^n + 1)/2
The largest is A060816 a(0) = 1; a(n) = (5*3^(n-1) - 1)/2 for n > 0
The list for different lengths of sequences is
n;all;unique;smallest;largest
0 1 1 1 1
1 1 1 2 2
2 2 2 5 7
3 6 4 14 22
4 24 8 41 67
5 120 16 122 202
6 720 32 365 607
7 5040 64 1094 1822
8 40320 128 3281 5467
9 362880 256 9842 16402
10 3628800 512 29525 49207
answer_list = []
def crunch(aList):
global answer_list
if len(aList) == 1:
return answer_list.append(aList[0])
elif len(aList) == 2:
return answer_list.append(abs(aList[1] - aList[0]))
elif len(aList) > 2:
for index, element in enumerate(aList[1:]):
copy = aList[:]
copy[index] = abs(copy[index] - copy[index-1])
copy.pop(index-1)
crunch(copy)
data = [1,3,3**2,3**3,3**4,3**5,3**6,3**7,3**8,3**9,3**10]
crunch(data)
print('the count is ', len(answer_list),' of which ',len(set(answer_list)),' are unique'
,'\n',answer_list,'\n',sorted(list(set(answer_list))))
|
Posted by Larry
on 2020-10-13 18:59:40 |