[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

string manipulation

hi,

i need to write a function in c# that get a string like that "hello world"
and returns the all letters combination for eich word in the input string , for example:
"holle wlord"
"ohlel world"
"leloh oldw"
exc..

thanks.
0
bwz
Asked:
bwz
  • 3
  • 3
  • 3
1 Solution
 
Aurora27Commented:
just write a loop to replace each letter in the next position...and then loop for string's length
0
 
Aurora27Commented:
Is there a pattern required?

CT.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
bwzAuthor Commented:
there is a case for pattern , but i dont want it be to much complicated
0
 
Göran AnderssonCommented:
Just split the string into words:

string word[] = input.Split(' ');

and get the permutations for each word.

Do you want the permuations for each word (i.e. for the example 120+120 combinations), or do you want all combinations of all permutations of all words (120*120 combinations)?
0
 
bwzAuthor Commented:
i the combination for each word and not for all the letters in the string
0
 
Göran AnderssonCommented:
Yes, but do you want the permuations for each word separately, or all combinations of all permuatations?

I.e. for "ab cde", do you want:

ab, ba
cde, ced, dce, dec, ecd, edc

or

ab cde
ab ced
ab dce
ab dec
ab ecd
ab edc
ba cde
ba ced
ba dce
ba dec
ba ecd
ba edc

For the first, just loop through the words and get the permuations. For the second you would create a list for each word that contains the permutations, then use an array of indexes to loop through all combinations.
0
 
Aurora27Commented:
Author, you need to be clear in your question. If thats a college assignment, then just post the question as is. we can look at it.

CT.
0
 
bwzAuthor Commented:
greenGhost:
i mean to your second option.

Aurora27:
it's not by written task that i got.. it's a task that i should prepare ASAP

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now