Help := proc() print("CCg(P, A, k1)"); end proc; #CC(P, A, k1): Implements the Ceaser Code but with an arbitrary alphabet #Inputs a message and alphabet, both in the form of a list of lowercase letters, #and an integer k from 0 to to the length of the alphabet, outputs the encrypted message #but throws a FAIL message if a letter in the message is not in the alphabet #For example #CCg([d,o,r,o,n], [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z],2) #should output [f,q,t,q,p], but #CCg([d,o,r,o,n,1], [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z],2) #will output FAIL and terminate early CCg := proc(P, A, k1) local T, i1; for i1 to nops(P) do if not has(P[i1], A) then return FAIL; end if; end do; for i1 to nops(A) do T[A[i1]] := A[((i1 + k1 - 1) mod 26) + 1]; end do; [seq(T[P[i1]], i1 = 1 .. nops(P))]; end proc; #Alph here is unecessary but allowed me to avoid typing out AlphT explicitly Alph:=[a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]: AlphT: #T is the totals by word length and place, F is the simple totals of each letter T: F; for i1 to 26 do AlphT[Alph[i1]] := i1; F[i1] := 0; end do; read "/Users/isaaclam/Desktop/ENGLISH.txt"; for x1 from 3 to 10 do for y1 to x1 do for z1 to 26 do T[x1, y1][z1] := 0; end do; end do; end do; for x1 from 3 to 10 do L := ENG()[x1]; for a1 to nops(L) do w1 := L[a1]; for y1 to x1 do ++T[x1, y1][AlphT[w1[y1]]]; ++F[AlphT[w1[y1]]]; end do; end do; end do;