Word Scramble

This is a discussion on Word Scramble within the C++ Programming forums, part of the General Programming Boards category; our requirements are as follows: take a single word entered by the user and display all possible combinations of the ...

  1. #16
    Unregistered
    Guest
    our requirements are as follows:
    take a single word entered by the user and display all possible combinations of the letters without using doubble letters
    (as in the word "sam" a combo could not be ssa.)
    the purpose is to take the output file and run it through a spell check to determine the combos that are real words.
    by the way we are begining our second year of programming.
    oh and the combos we use com from the daily jumble puzzle
    in the newspaper. hope that helps you help us.
    thanks-
    sm



    note to cc - dude you realy need to be more descriptive
    "what were ya raised in a barn?"
    see you tomorow-
    sm

  2. #17
    registered
    Guest
    Originally posted by Prelude

    for ( int i = 0; i < len; i++ ) {
    perm ( s, len - 1 );
    if ( len == 2 )
    std::cout<< s <<std::endl;
    rotate ( s, len );
    }
    My somewhat disturbed classmate wasn't able to convert it back to our "ap style" programming. I was able to get your code to work. Thanks. While I was commenting though, I didn't exactly understand this loop. What does it exactly do? Mostly the if(len == 2).

    thanks

  3. #18
    Registered
    Guest
    I actually didn't mean what does it do; I meant why does it need to do it?

    Desperatly in need student

  4. #19
    Unregistered
    Guest
    cc call me
    -sm
    ps call clark to get my number
    no i am not disturbed, im just confused-
    sm

  5. #20
    Unregistered
    Guest
    write post when you see message
    -sm

  6. #21
    registered
    Guest
    i'll call your cell

  7. #22
    Unregistered
    Guest
    call now

  8. #23
    Unregistered
    Guest
    call my house

  9. #24
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >I meant why does it need to do it?
    It needs to do it to rotate the word properly. Recurse until there are only two letters and then swap them, then move back and do the same thing. It makes more sense if you step through the code, but here is the basic idea:
    Code:
    word = cat
      word = at
        word = t
      print cat
      rotate at
        word = a
      print cta
      rotate ta
    rotate atc
      word = tc
        word = c
      print atc
      rotate tc
        word = t
      print act
      rotate ct
    rotate tca
      word = ca
        word = a
      print tca
      rotate ca
        word = c
      print tac
      rotate ac
    rotate tca
    -Prelude
    My best code is written with the delete key.

  10. #25
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    Posts
    608
    Originally posted by BMJ
    Hey, I'm just making sure... people on this board have a habit of poorly phrasing questions; sheesh
    very true. lol
    Email: Klinerr1@nc.rr.com || AIM: MisterSako || MSN: sakotheinsane@hotmail.com

    -the shroom has spoken

  11. #26
    Unregistered
    Guest
    cc try my cell now

  12. #27
    registered
    Guest
    your cell phone isn't on and your home phone is an answering machine

  13. #28
    Unregistered
    Guest
    dude not cool

  14. #29
    Registered
    Guest
    I stepped through the code atleast 15 times at this section
    quote:
    --------------------------------------------------------------------------------
    Originally posted by Prelude

    for ( int i = 0; i < len; i++ ) {
    perm ( s, len - 1 );
    if ( len == 2 )
    std::cout<< s <<std::endl;
    rotate ( s, len );
    }


    --------------------------------------------------------------------------------

    I still can't see the pattern. I must be blind.

    word = cat
    word = at
    word = t
    print cat
    rotate at
    word = a
    print cta
    rotate ta
    rotate atc
    word = tc
    word = c
    print atc
    rotate tc
    word = t
    print act
    rotate ct
    rotate tca
    word = ca
    word = a
    print tca
    rotate ca
    word = c
    print tac
    rotate ac
    rotate tca

    Why does the word get shorter and eventually to the length of a char and then the rotate occurs? My brain needs more of a jump start.

  15. #30
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Damn people, get MSN Messenger or something. Stop flooding the board with "call me" "I did. You were sleeping." "Ok, I'm awake now. Call again." "Ok, I will." "Ok, did you?" "Ok Yeah." No one cares about your phone conversation. Get some message program, or sign in and privately message people.

    Quzah.
    Hope is the first step on the road to disappointment.

Page 2 of 3 FirstFirst 123 LastLast
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, 03:06 PM
  2. please help with binary tree, urgent.
    By slickestting in forum C Programming
    Replies: 2
    Last Post: 07-22-2007, 07:55 PM
  3. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  4. Wrong Output
    By egomaster69 in forum C Programming
    Replies: 7
    Last Post: 01-28-2005, 05:44 PM
  5. Using 'if' with char arrays or string objects
    By c++_n00b in forum C++ Programming
    Replies: 36
    Last Post: 06-06-2002, 09:04 PM

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