venumadhava

Simple C program

5 posts in this topic

hey guys i have tried to write a program on jumbled words in C

    i.e.

 -----> If we give a word it should display all the scrambled words of entered word

 

 

 

            E.g. IF GIVEN WORD :  car

                      THEN IT SHOULD SHOW ALL THE SCRAMBLE WORDS OF IT

                                     car

                                     cra

                                     acr

                                     arc

                                     rac

                                     rca 

             HOPE you all understood 

      and i hope someone can do this?!!!!

Share this post


Link to post
Share on other sites

That's just a simple permutation. Here's how I would do it in perl... 

 

[spoiler]

#!/usr/bin/perl
use List::Permutor;

$scalar='car';
my @array = split(//,$scalar);

my $permutor = List::Permutor->new( @array);
while ( my @permutation = $permutor->next() ) {
    print( join('',@permutation)."\n" );
}

[/spoiler]

Edited by heisenbug

Share this post


Link to post
Share on other sites

There are a few ways to that. Some good, some really slow. 

 

As simple as your question seems, a lot of theory and thought is put into creating efficient brute-force / exhaustive search algorithms.

 

You could probably google stack overflow with the "site:" operator and find a good solution. Or you could study how exhaustive search algorithms work and are designed.

 

Just my two cents on it....

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now