Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: A combinatorial problem
Replies: 2   Last Post: Oct 2, 2011 1:59 PM

 Search Thread: Advanced Search

 Messages: [ Previous | Next ]
 Edu59 Posts: 4 Registered: 9/1/11
A combinatorial problem
Posted: Oct 1, 2011 9:07 AM
 Plain Text Reply

Hi:
I am trying to solve this mathematical problem with an unknown matlab built-in function.
Let K=1?20 be the set of the first 20 integers. Consider all combinations of 5 elements selected from the set K. How many of these combinations contain elements that differ by 3?
For example, the combination (1,4,5,9,15) has elements 1 and 4 whose difference is 4-1=3 but the combination (1,2,3,9,15) has no elements that differ by 3. So the combination (1,4,5,9,15) is one I am looking for and the combination (1,2,3,9,15) is not. What is the total number of combinations like (1,4,5,9,15) taken from the first 20 integers.?
I tried the following procedure:
With the built-in matlab function combntns I can enumerate the combinations of n objects taken p at a time and then I can use the function size to calculate the total number of combinations for example:

How can the numbers 1 to 5 be taken in sets of three (that is, what is 5 choose 3)?
combos = combntns(1:5,3)
combos =
1 2 3
1 2 4
1 2 5
1 3 4
1 3 5
1 4 5
2 3 4
2 3 5
2 4 5
3 4 5
size(combos,1) % "5 choose 3"
ans =
10

Is there a matlab function that enumerates combinations with elements that differ by 3 and then use a function like size to compute the total number of combinations.?
Thank you in advance.

Date Subject Author
10/1/11 Edu59
10/1/11 Ben Brink
10/2/11 Avni Pllana

© The Math Forum at NCTM 1994-2018. All Rights Reserved.