查找随机字母序列的话? [英] Find words from a sequence of random letters?
问题描述
我工作的一个项目,我第一个通过赋予每个数字一个字母(A = 0,B = 1,等等),翻译了圆周率为英文字母的数字。我转换万位圆周率这给了我这些 8700字母的工作。第二步骤涉及找到有意义的话,从这个生成的字母序列。我想知道是否有人曾经工作过的这样一个项目?有人可以张贴的算法或线性code,这将帮助我轻松找到随机序列的话吗?如果不是$ C $直接C,任何人都可以给我一个更简单的方法来找到词的解决方法吗?
I'm working on a project where I first translated the digits of 'pi' to english letters by assigning each number to a letter (a=0, b=1, etc). I converted 10,000 digits of Pi which gave me these 8700 letters to work with. The second step involves finding meaningful words from this generated letter sequence. I was wondering if anyone has ever worked on such a project? Can somebody post an algorithm or a linear code that will help me easily find the words of the random sequence? If not the code directly, could anyone show me a workaround of an easier approach to finding the words?
此链接已经从上市更方便地选择英文字典中的所有字母。
This link has all the letters from an English dictionary listed for easier selection.
编辑:对不起,我没有提到如何在code工作。在Java code需要两个数字考虑并为其指定一个字符(如:O = 14),因为9不会被分配后的信件。如果数字为25,第2和5以上分开考虑。例如,2526将是Z(25),B(2)和g(6)自26被分成2及6。
I'm sorry I didnt mention how the code works. The java code takes two numbers into consideration and assigns it a character (eg. o=14) since letters after 9 wont be assigned. If the number is above 25, 2 and 5 are considered separately. For example, 2526 would be z(25), b(2) and g(6) since 26 is split into 2 & 6.
推荐答案
这是一个足够小的问题,暴力破解的作品在不到一秒钟的:
This is a sufficiently small problem that bruteforce works in less than a second:
Python的code:
Python code:
for pi in open('pi.txt'):
pi = pi.upper()
words = [word.rstrip() for word in open('wordlist.txt') if word.rstrip().upper() in pi]
(pi.txt是包含字母转换的文件)
(pi.txt is a file containing your converted letters)
要打印长度秩序的话,你可以使用:
To print the words in length order you can use:
words.sort(key=len)
for word in words:
print word
最长的词是:
The longest words are:
high
jive
life
shah
facie
hutch
这篇关于查找随机字母序列的话?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!