473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Scramble the word

Hello friends,
there is yet another problem for you...
We have got a string say HOUR
Now we need a program that can choose the specified number of words say n from this word in all possible ways and displays them ...for example in this case
for n=3 the output should be
HOU
OUR
URH
RHO
Sep 29 '08 #1
8 5926
donbock
2,426 Expert 2GB
In your example, are you looking for all of the 3-letter combinations or are you also required to weed out combinations that are not found in the dictionary?

Have you had any courses in probability and/or statistics?
Sep 29 '08 #2
boxfish
469 Expert 256MB
It looks from the example like the program is supposed to make words that use the letters in order, but words that go off the end of the original word wrap around to the beginning. No need for any probability. Here's another example of a word:
word = 12345
n = 4
combinations are:
1234
2345
3451
4512
5123
This should be fairly easy using the modulus operator to wrap the indices around.
Sep 29 '08 #3
donbock
2,426 Expert 2GB
The reason I asked about any background in probability and/or statistics is that there's a mathematical concept introduced in those courses that is at the core of what this problem is all about.
Yes; I'm being deliberately coy.
Sep 29 '08 #4
whodgson
542 512MB
Ummm I'm not so sure.
'hour' should have 4! = 24 different combinations where as
'hou' or 'our' should have 3! = 6 different combinations
The next_permutation () C++ generic algorithm demonstrates this.
Expand|Select|Wrap|Line Numbers
  1. int main()
  2. {
  3.     char* s="ABCD";
  4.     for(int i=0;i<24;i++)
  5.     { next_permutation(s,s+4);
  6.     cout<<(i%8?'\t':'\n')<<s;
  7.     }
  8. system("pause");
  9. return 0;
//prints
ABDC ACBD ACDB ADBC ADCB BACD BADC BCAD
BCDA BDAC BDCA CABD CADB CBAD CBDA CDAB
CDBA DABC DACB DBAC DBCA DCAB DCBA ABCD
Sep 30 '08 #5
JosAH
11,448 Expert 8TB
Hello friends,
there is yet another problem for you...
We have got a string say HOUR
Now we need a program that can choose the specified number of words say n from this word in all possible ways and displays them ...for example in this case
for n=3 the output should be
HOU
OUR
URH
RHO
You have to specify the definition of that sequence; why not HOU, HOR, HUR
and OUR? You either want P(4,3) or C(4,3) or something else; please elaborate.

kind regards,

Jos
Sep 30 '08 #6
From your example, I think what you want is C(a,n), meaning no repetitions.
You are not only asking for the code, which they won't give you, but you also want them to guess what the output of the program should be. Try to be more specific next time.
Sep 30 '08 #7
donbock
2,426 Expert 2GB
To understand what P(4,3) and C(4,3) mean you should Google "permutation combination".
Sep 30 '08 #8
You have to specify the definition of that sequence; why not HOU, HOR, HUR
and OUR? You either want P(4,3) or C(4,3) or something else; please elaborate.

kind regards,

Jos
Actually i am concerned with only selection of the letters not their sequence .So i need C(4,3) nt P(4,3).
Sep 30 '08 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Klaus Ambrass | last post by:
Hi all, I write applications for my company's intraweb, and recently we've had some eager users trying to get at some data they shouldn't. The way they did it was to look at the pages input tags...
3
by: gdogg1587 | last post by:
Greetings. I'm working on a program that will "descramble" words. Think of a word scramble game where there is a list of characters, and several blank spaces to denote the word(s) that you are...
4
by: Steve | last post by:
Hi, I am trying to do a very simple "encryption" of a text string in java script. For instance, if the user enters : steve, I want to just convert each character to its ASCII value and add 5...
3
by: Jeremy S | last post by:
What are some options for scrambling information in the QueryString. Consider this URL for example: SomePage.aspx?userid=15 I don't care if there is something in the querystring - I'd just...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
2
by: ashish1779 | last post by:
hii, i am new in php i am doing scrambling a content, but i want to scrambled a sentence not a word scrambled. so please help me. thanks
0
by: alivip | last post by:
I write code to get most frequent words in the file I won't to implement bigram probability by modifying the code to do the following: How can I get every Token (word) and ...
3
by: onindita | last post by:
hello everyone! i m very here. i tried to make a program that will reverse the letters in each of a sequence of words while preserving the order of the words themselves. Sample Input Hello...
0
by: Pramod Elig | last post by:
I developed this code which works fine in my current system which has office 2007, but when I run in word 2000 this doesn’t work. Can you please help me to code word automation using late binding. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.