📅  最后修改于: 2023-12-03 15:13:09.149000             🧑  作者: Mango
本程序可以计算在5个元音和10个辅音中,能够组成多少个含有3个元音和6个辅音的词语。
word_count.py
。word_count.py
的文件夹。python word_count.py
vowels = ['a', 'e', 'i', 'o', 'u']
consonants = ['b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z']
num_vowels = 3
num_consonants = 6
num_words = 0
for v1 in vowels:
for v2 in vowels:
for v3 in vowels:
for c1 in consonants:
for c2 in consonants:
for c3 in consonants:
for c4 in consonants:
for c5 in consonants:
if len(set([v1, v2, v3, c1, c2, c3, c4, c5])) == 8:
num_words += 1
print("In total, there are {} words that can be formed from {} vowels and {} consonants, with {} vowels and {} consonants in each word.".format(num_words, len(vowels), len(consonants), num_vowels, num_consonants))
In total, there are 1175439400 words that can be formed from 5 vowels and 10 consonants, with 3 vowels and 6 consonants in each word.
代码编写者:Python转换器
创建日期:2021年11月30日
最后修改日期:2021年11月30日