#Charles Wolf #homework 11 #Feel free to share this# #CN23(L):inputs a sequence of 2's and 3's and finds its curling number if the number is less than or equal to 4. CN:=proc(L) local i,n,c: n:=nops(L): c:=1: if n=1 then 1: else for i from 1 to trunc(n/2) do if [seq(L[n-j],j=0..i-1)]=[seq(L[n-j-i],j=0..i-1)] then c:=max(c,2): if n>=3*i then if [seq(L[n-j-i],j=0..i-1)]=[seq(L[n-j-2*i],j=0..i-1)] then c:=max(c,3): if n>=4*i then if [seq(L[n-j-2*i],j=0..i-1)]=[seq(L[n-j-3*i],j=0..i-1)] then c:=4: fi:fi:fi:fi:fi: od: fi: c: end: #CS(n): finds mu(n), except for possibly very high numbers where a 4 or 5 may occur. But I don't think Maple can handle that anyway. CS:=proc(n) local c,L,i,j,L1,mu: mu:=n: for i from 0 to 2^(n)-1 do #In order to generate each sequence of length n of 2's and 3's, I start with [2\$n], and then add the binary representation of a number, which is just #a sequence of 0's and 1's. This generates every sequence of 2's and 3's of length n. L:=[2\$n]: L1:=convert(i,base,2): L:=L+[op(L1),0\$(n-nops(L1))]: c:=CN(L): if c>1 then for j from n while (c>1) do c:=CN(L): L:=[op(L),c]: mu:=max(j,mu): od: fi: od: mu: end: