'Copyright 2000 The American Cryptogram Association (ACA) '3613 Piedmont Drive, Plano TX 75075-6234 'All rights reserved. 'Program code from the Computer Column 'for Nov/Dec 2000. The program drags 'a crib through three-square ciphertext 'and displays the number of matches at 'each cipher position. See the Computer 'Column for details. 'Sq3Crib.Bas Demo ciphertext is from 'E-21 Jul/Aug 2000 C$= "ENT VUB VET BLA BTB BEU MIA KPY" C$=C$+"LPE ONH ASY MQG ANN AHT OZY BYA" C$=C$+"DWC MXC ENB MPE KNH LII VKN HLP" C$=C$+"NMG CMF ISL KRP PML SKU RKM ZVM" C$=C$+"FWT QMR YNX LQO ASS GKB XKS XME" C$=C$+"WVV TMZ NLY UWH VUN MUC CKA BNI" C$=C$+"OID PVF IUU FKL DOR RVO GIG HTV" C$=C$+"ERT ZMR TKY BKX LPE USC XKF MWB" C$=C$+"KMI QMM VXL CYR FKX YSH HDN NYK C$=C$+"IKE SSO PLF RLU XMS ZLZ BSA WRT" C$=C$+"AMG LLL ENR NMV OCY CWQ DRX KNX" C$=C$+"GVC CWI PYD TCS UVR EBX" 'Crib is next Pt$="MAYBEONEOFMANYTHINGSITCANMEAN" Ct3$ = RemoveSpaces$(C$) Ct2$ = RemoveMiddleLtr$(Ct3$) LPt = Len(PT$) LCt2 = Len(Ct2$) NumPtPosns = LCt2 - LPt + 1 'Ct2$ is cipher with middle letters 'omitted. Pt$ is dragged from posn '1 to NumPtPosns in Ct2$, CLin$ 'receives triads to be printed. NLin$ 'holds the counts to be printed. 10, '11, 12 are shown as a, b, c, etc. CLin$="" : NLin$="" : TriadCount=0 For I = 1 to NumPtPosns Step 2 Triad$ = Mid$(Ct3$,2*I-(I+1)\2,3) CLin$ = CLin$+Triad$+" " CtSeg$ = Mid$(Ct2$,I,LPt) N1$ = Coincidences$(CtSeg$,Pt$) CtSeg$ = Mid$(Ct2$,I+1,LPt) N2$ = Coincidences$(CtSeg$,Pt$) NLin$ = NLin$+N1$+" "+N2$+" " TriadCount = TriadCount+1 If TriadCount >= 18 Then Print CLin$ : Print NLin$ CLin$= "" : NLin$="" TriadCount = 0 End If Next I If Clin$<>"" Then Print CLin$ : Print NLin$ End If End ' End of main program 'Returns count as char: 0-9, a=10 etc. Function Coincidences$(C$,P$) C=0 'C is count of matches L = Len(P$) For I=1 to L If Mid$(C$,I,1) = Mid$(P$,I,1) Then C = C + 1 End If Next I If C<10 then A=48 else A=97 : C=C-10 Coincidences$ = Chr$(A + C) End Function 'Coincidences$ Function RemoveMiddleLtr$(S$) T$="" L = Len(S$) For I=1 to L If ((I+1) Mod 3)<>0 Then C$=Mid$(S$,I,1) T$=T$+C$ End If Next I RemoveMiddleLtr$=T$ End Function 'RemoveMiddleLtr Function RemoveSpaces$(S$) T$="" L = Len(S$) For I=1 to L C$=Mid$(S$,I,1) If C$<>" " Then T$=T$+C$ Next I RemoveSpaces$=T$ End Function 'RemSpaces