Our server costs ~$56 per month to run. Please consider donating or becoming a Patron to help keep the site running. Help us gain new members by following us on Twitter and liking our page on Facebook!
Current time: February 25, 2025, 1:52 pm

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Here's a simple programming problem for you to solve
#1
Here's a simple programming problem for you to solve
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)
Reply



Messages In This Thread
Here's a simple programming problem for you to solve - by ErGingerbreadMandude - April 26, 2016 at 4:46 am

Possibly Related Threads...
Thread Author Replies Views Last Post
  Cryptocurrency in simple details. WinterHold 49 6083 September 10, 2021 at 11:02 am
Last Post: Spongebob
  Programming Language Swift Poll Shining_Finger 24 5339 December 2, 2015 at 7:21 pm
Last Post: bennyboy
  Programming Question Shining_Finger 8 1713 December 2, 2015 at 5:30 pm
Last Post: Tiberius
  Programming the Human Mind: Shining_Finger 21 5546 November 24, 2015 at 7:56 pm
Last Post: bennyboy
  Anyone into Android programming? emjay 97 22332 September 20, 2015 at 6:50 am
Last Post: bennyboy
  Advice Sought for Web Programming AFTT47 13 3971 April 4, 2015 at 10:41 pm
Last Post: bennyboy



Users browsing this thread: 1 Guest(s)