Perl - 如何从单词创建所有可能的序列 [英] Perl - How to create all possible sequence from a word

查看:82
本文介绍了Perl - 如何从单词创建所有可能的序列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我必须根据字典将单词翻译成不同的可能单词,这样可以为单词中的每个字母定义不同的含义。

例如,

单词VAEFGH根据我在这里定义的dictonary翻译成各种所有可能的单词。

@V =('''GTT'',''GTC'',''GTA'', ''GTG'');

@A =('''GCT'',''GCC'',''GCA'',''GCG'');

@E =(''GAA'',''GAG'');

@ F =(''TTT'',''TTC'');

@G =('''GGT'',''GGC'',''GGA'',''GGG'');

@H =('''CAT'',' 'CAC'');


只是说,字典中VAEFGH字样的翻译输出的一个例子。将是GTTGCTGAATTTGGTCTC。请通过捐赠您的代码或算法来解决这个问题,为我提供解决方案。


提前致谢,

B.Nataraj

Hi all,
I have to do a translation of a word into different possible word based on a dictionary, which define differ meaning for each letter in a word.
For example,
The word "VAEFGH" to be translated to various all possible words based on the dictonary that I define here like the one.
@V=(''GTT'',''GTC'',''GTA'',''GTG'');
@A=(''GCT'',''GCC'',''GCA'',''GCG'');
@E=(''GAA'',''GAG'');
@F=(''TTT'',''TTC'');
@G=(''GGT'',''GGC'',''GGA'',''GGG'');
@H=(''CAT'',''CAC'');

Just to say, an example of a translated ouput from the dictionary for the word "VAEFGH" is to be "GTTGCTGAATTTGGTCAT". Please provide me the solution by donating your code or else the algorithm to crack this one out.

Thanks in advance,
B.Nataraj

推荐答案

在给出任何解决方案之前,我们想知道你到目前为止所尝试的内容。

但是,只是为了给你一个开头的提示,你需要做的就是为所有必需的数组使用嵌套的foreach()循环来获得一组可能的组合。


-Nithin
Before giving any solution, we would like to know what you have tried so far.
But, just to give you a hint to start with, all you need to do is to use nested foreach() loops for all the required arrays to get a set of possible combinations.

-Nithin



在给出任何解决方案之前,我们想知道你到目前为止所尝试的内容。

但是,只是为了给你一个提示,你需要做的就是为所有必需的数组使用嵌套的foreach()循环来获得一组可能的组合。


-Nithin
Before giving any solution, we would like to know what you have tried so far.
But, just to give you a hint to start with, all you need to do is to use nested foreach() loops for all the required arrays to get a set of possible combinations.

-Nithin



嗨Nithin,

感谢您的回复。是的,我一直在尝试你所说的与嵌套的foreach()循环完全相同的内容,但是我真的很难将它作为一个程序实现。我不是一个普通的程序员,所以我很乐意修改现有代码根据我的需要排序。这就是为什么我把我的关注点发布在这个论坛上。更多我明白做这样一个嵌套循环将消耗更多的计算时间,所以如果任何高级程序员已经为这个问题做了一个启发式方法,那么我将在这里寻找。

Hi Nithin,
Thank you for your reply. Yes, I have been trying exactly what you have said about like nested foreach() loop, but it really confuse me to implement it as a programm..I am not a regular programmer, so I would be happy with modifying existing code of this sort to my need. Thats why I posted my concern into this forum. More I do understand that doing such a nested loop will consume more computational time so if any advanced programmer had done a heuristic approach for this problem would be much sought out for me here.



嗨Nithin,

感谢您的回复。是的,我一直在尝试你所说的与嵌套的foreach()循环完全相同的内容,但是我真的很难将它作为一个程序实现。我不是一个普通的程序员,所以我很乐意修改现有代码根据我的需要排序。这就是为什么我把我的关注点发布在这个论坛上。更多我明白,做这样一个嵌套循环将消耗更多的计算时间,所以如果任何高级程序员已经为这个问题做了一个启发式的方法,我将在这里寻找。
Hi Nithin,
Thank you for your reply. Yes, I have been trying exactly what you have said about like nested foreach() loop, but it really confuse me to implement it as a programm..I am not a regular programmer, so I would be happy with modifying existing code of this sort to my need. Thats why I posted my concern into this forum. More I do understand that doing such a nested loop will consume more computational time so if any advanced programmer had done a heuristic approach for this problem would be much sought out for me here.



如果你有搜索这个论坛你会发现你想要的东西。


我所知道的除非放置一些代码,否则我不会试图帮助你


if you have Searched this forum you would have found something on the lines of what you want.

all i know is i will not attempt to help you unless some code is placed


这篇关于Perl - 如何从单词创建所有可能的序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆