Unscrambling Words

This is a discussion on Unscrambling Words within the C++ Programming forums, part of the General Programming Boards category; Hello, does anybody know how I would go about making a word unscrabler? Like the user inputs "gorf" and the ...

  1. #1
    Registered User
    Join Date
    Sep 2005
    Location
    USA
    Posts
    69

    Question Unscrambling Words

    Hello, does anybody know how I would go about making a word unscrabler?
    Like the user inputs "gorf" and the computer spits out all possible combinations like
    g
    o
    r
    f
    gg
    go
    gr
    gf
    og
    oo
    or
    of
    rg
    ro
    rr
    rf
    fg
    fo
    fr
    ff
    ggg
    And so on until ffff?
    Thanks,
    Adam

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,074
    Well I don't know how you think "gg" or many of your other examples is "gorf" unscrambled, but if you want a program that spits out all possible permutations of a word, you could look at the solution to the permutations challenge on Cprogramming.com

    http://www.cprogramming.com/challenges/permutesol.html

    Example:
    Code:
    > permute dog
    dgo
    dog
    gdo
    god
    odg
    ogd
    Or if it pleases you:
    Code:
    > permute frog
    frog
    frgo
    forg
    fogr
    fgor
    fgro
    rfog
    rfgo
    rofg
    rogf
    rgof
    rgfo
    orfg
    orgf
    ofrg
    ofgr
    ogfr
    ogrf
    grof
    grfo
    gorf
    gofr
    gfor
    gfro
    Last edited by SlyMaelstrom; 12-12-2005 at 10:10 PM.
    Sent from my iPadŽ

  3. #3
    Super Moderater.
    Join Date
    Jan 2005
    Posts
    374
    Actually a permutation generator is a pretty P.i$$ poor way to tackle anagram problems...

    For the simple reason a nine letter word would take a long time to solve.
    9!


    A letter frequency counter is a much better option.

    anagrams problems with n factorial


    The link to the dictionary file might be dead. Try this one instead...
    Again renaming it 'dictionary.txt' and saving it in your current directory where you intend to run your program.

    http://java.sun.com/docs/books/tutor...dictionary.txt
    Last edited by treenef; 12-13-2005 at 03:04 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 04:06 PM
  2. seg fault at vectornew
    By tytelizgal in forum C Programming
    Replies: 2
    Last Post: 10-25-2008, 02:22 PM
  3. Problem with malloc() and sorting words from text file
    By goron350 in forum C Programming
    Replies: 11
    Last Post: 11-30-2004, 10:01 AM
  4. New Theme
    By XSquared in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 04-01-2004, 08:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21