获得一个词,其中的字母可以有变体的所有排列 [英] Getting all permutations of a word where letters may have variants

查看:163
本文介绍了获得一个词,其中的字母可以有变体的所有排列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我期待的伪code算法如下问题。

i am looking for the pseudocode algorithm to the following problem.

我想获得一个单词的所有排列。 字母表中的每个字母可能有变。例如在法国字母e也可以是E E E E。 与其他字母一样... AAAA等。

i want to get all permutations of a word. in the alphabet each letter may have variants. for example in french the letter e can also be é è ê ë. the same with other letters... aàâä etc.

现在对于任何给定词我想列出所有的所有字母都变的可能的排列。

now for any given word i want to list all the possible permutations with all variants of all letters.

输入一个字和一个,如果他们有一定的所有字母及其变种。

input is a word and a all letters and their variants if they have some.

推荐答案

下面是一些基本的伪code:

Here is some basic pseudocode:

  1. Generate a list Perm[1...n] of all permutations without considering variants.
  2. For i = 1 to n do
  3.  For j = 1 to |Perm[i]| do
  4.   For k = 1 to #variants(Perm[i][j])
  5.    print Perm[i][1...j-1] (variant #k) Perm[i][j+1...|Perm[i]|]

在的话,产生不考虑变体permuations(已处理过几次SO一个问题,寻找生成排列)。然后,对于每个置换,看看每个字母和它的每一个排列,印有字母其变种取代了字。

In words, generate the permuations without considering variants (a problem already treated several times on SO, look for "generating permutations"). Then, for each permutation, look at each letter and for each of its permutations, print the word with the letter replaced by its variant.

这篇关于获得一个词,其中的字母可以有变体的所有排列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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