A famous English proverb was coded by me twice: the 1st line consists of 26 letters of the English ABC each being replaced by C for the consonants and by V for the vowels (word=CVCC) while the letters in the second line provide letter C for each of composite numbers in the list corresponding to the value of serial place of the letter and P if the number is prime.
(word=>23,15,18,4=PCCC)
1st line:
CCVCCVCV CVCC CVC VVV CVCCVCV
2nd line:
CCACCPCC PCCC PPC CCC CCPCPCP
Rem1: Y is counted as a vowel
Rem2: A=1 is neither prime nor composite number so it stays A in the second line and V in the first
What is the original proverb?
clearvars
alphabet='abcdefghijklmnopqrstuvwxyz';
vowels='aeiouy';
cons=setdiff( alphabet ,vowels);
line1='CCVCCVCV CVCC CVC VVV CVCCVCV';
line2='CCACCPCC PCCC PPC CCC CCPCPCP';
wds=fileread('c:\words\words8.txt');
l=length(wds)/8;
for i=1:l
w=wds(i*8-7:i*8);
v=w([3,6,8]);
c=w([1,2,4,5,7]);
if isempty(setdiff(v,vowels))
if isempty(setdiff(c,cons))
if w(3)=='a'
good=true;
for j=1:8
n=strfind(alphabet,w(j));
if isprime(n)~=(line2(j)=='P')
good=false;
end
end
end
if good
disp(w)
end
end
end
end
finds only the word "flattery" to match the first word.
Inspection shows "Flattery will get you nowhere."
|
Posted by Charlie
on 2024-08-20 21:53:40 |