#OK to post homework #GLORIA LIU, Apr 20 2024, Assignment 25 read `C26.txt`: #=====================================# #1. Continue to work on your project due May 1, 11:00pm #=====================================# #2. Using the file ENGLISH.txt, where ENG() is a list of length 26 whose i-th entry is the list of words of length i, find #Out of the 26^2=676 pairs of letters how many actualy show up as consecutive two letters? (For example for the word #[a,l,e,x] the pairs [a,l],[l,e],[e,x] shosed up. #Out of the 26^2=676 pairs of letters how many show up up as consecutive two lettersmore than ten times? #Out of the 26^3=175676 triples of letters how many actualy show up as consecutive three letters? (For example for the word #[v,a,l,e,n,t,i,n,o] the triples [v,a,l],[a,l,e],[l,e,n],[e,n,t],[n,t,i],[t,i,n],[i,n,o] showed up) 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]: pairs:=proc() local DB,S,I1,Table,L,Letter,Letter2,length,W: DB:=ENG(): S:={}: for Letter in ALPH do for Letter2 in ALPH do Table[Letter,Letter2]:=0: od: od: for L in DB do for W in L do length:=nops(W): for I1 from 1 to length-1 do S:=S union {[W[I1],W[I1+1]]}: Table[W[I1], W[I1+1]]:=Table[W[I1], W[I1+1]]+1: od: od: od: S,op(Table): end: result:=pairs(): nops(result[1]); Table:=result[2]: count:=0: for Letter in ALPH do for Letter2 in ALPH do if Table[Letter,Letter2]>=10 then count:=count+1: fi: od: od: count; #I got that there were 593 pairs in total, and 500 of them appeared 10 times or more triples:=proc() local DB,S,I1,L,length,W: DB:=ENG(): S:={}: for L in DB do for W in L do length:=nops(W): for I1 from 1 to length-2 do S:=S union {[W[I1],W[I1+1],W[I1+2]]}: od: od: od: S: end: nops(triples()); #I got that there were 6639 triples #=====================================# #3. Finish up procedure TM(SetL) that should output a 28 by 28 matrix (in decimals) where the order is #ALPH1:=[ST,a,b,c ..., z, EN], and the [i,j] entry is the probability that if you are currently at letter ALPH1[i] that the #letter after that is ALPH1[j]. The last row should of course be all zeores. #Skipped