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
8 5926
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?
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.
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.
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. - int main()
-
{
-
char* s="ABCD";
-
for(int i=0;i<24;i++)
-
{ next_permutation(s,s+4);
-
cout<<(i%8?'\t':'\n')<<s;
-
}
-
system("pause");
-
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
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
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.
To understand what P(4,3) and C(4,3) mean you should Google "permutation combination".
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).
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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
|
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 ...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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,...
|
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...
| |