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?
A computer search showed only a single possible word for the first and the last word of the phrase: "Flattery ____ ___ ___ nowhere"
For words 2, 3, and 4, the number of possible words found in my wordlist was 222, 40, and 8. One of the 8 choices for the 4th word was "you". The other words of the proverb were present in the respective lists.
"Flattery will get you nowhere."
--------------
def vowelcode(word):
ans = ''
for char in word:
if char in 'aeiouy':
ans += 'V'
else:
ans += 'C'
return ans
def primecode(word):
ans = ''
for char in word:
num = ord(char) - 96
if num == 1:
ans += 'A'
continue
if isprime(num):
ans += 'P'
else:
ans += 'C'
return ans
wordss = [w for w in words if len(w) in [3,4,7,8]]
possibles = [[] for i in range(5)]
vs = ['CCVCCVCV', 'CVCC', 'CVC', 'VVV', 'CVCCVCV']
ps = ['CCACCPCC', 'PCCC', 'PPC', 'CCC', 'CCPCPCP']
for w in wordss:
for loc in range(5):
if vowelcode(w) == vs[loc] and primecode(w) == ps[loc]:
possibles[loc].append(w)
|
Posted by Larry
on 2024-08-21 08:57:25 |