Question:
Write a program(preferably in c)to:
*Input a string S of x length with each letter denoted by l1,l2,l3,...lx.
*Input integer variable z.
*Display all possible non -repeating combinations of the individual letters of the string S as strings of length z( in no particular order.)
Example 1:
(input string) "AB"
(input integer variable) 2
(display result)
"AA"
"BB"
"AB"
"BA"
Example 2:
(input string) "AB"
(input integer variable) 1
(display result)
"A"
"B"
Example 3:
(input string) "AB"
(input integer variable) 3
(display result)
"AAA"
"BBB"
"AAB"
"ABA"
"BAA"
"BBA"
"BAB"
"ABB"
I actually solved this problem, well, partially solved, my solution was very buggy and outputted many many duplicate strings. Let's see if someone can solve this :-)
Iterative and recursive answers are accepted, iterative answer gets 5 points, recursive answer gets 4 points and both of the answers submitted by a single person gets 25 points. (I know, I know, my point scheme doesn't make any sense, that's not the point)
Write a program(preferably in c)to:
*Input a string S of x length with each letter denoted by l1,l2,l3,...lx.
*Input integer variable z.
*Display all possible non -repeating combinations of the individual letters of the string S as strings of length z( in no particular order.)
Example 1:
(input string) "AB"
(input integer variable) 2
(display result)
"AA"
"BB"
"AB"
"BA"
Example 2:
(input string) "AB"
(input integer variable) 1
(display result)
"A"
"B"
Example 3:
(input string) "AB"
(input integer variable) 3
(display result)
"AAA"
"BBB"
"AAB"
"ABA"
"BAA"
"BBA"
"BAB"
"ABB"
I actually solved this problem, well, partially solved, my solution was very buggy and outputted many many duplicate strings. Let's see if someone can solve this :-)
Iterative and recursive answers are accepted, iterative answer gets 5 points, recursive answer gets 4 points and both of the answers submitted by a single person gets 25 points. (I know, I know, my point scheme doesn't make any sense, that's not the point)