.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $6.00

   







Go Back   .com.unity Forums > Shrapnel Community > Space Empires: IV & V

Reply
 
Thread Tools Display Modes
  #1  
Old February 25th, 2007, 06:46 PM
geoschmo's Avatar

geoschmo geoschmo is offline
National Security Advisor
 
Join Date: Jan 2001
Location: Ohio
Posts: 8,450
Thanks: 0
Thanked 4 Times in 1 Post
geoschmo is on a distinguished road
Default OT: Math help. Permutations and Combinations

Here's the question in my math homework this week.

Quote:

A shelf holds 12 books in a row. How many ways are there to choose 5 books so that no two adjacent books are chosen? [Hint: Represent the books that are chosen by bars and the books that are not chosen by stars. Count the number of sequences of five bars and seven stars so that no two bars are adjacent.]
I could not figure out how to present this in one of the formulae we studied in this chapter. The hint was no help to me at all. I did a brute force method approach and counted the possible combinations.

Since the selections must be non-consecutive the longest we can wait to pick our first selection is book 4 and every other book after gives us:
4,6,8,10,12
Now working backwards on the shelf if our first book selected is 3 we get:
3,5,7,9,11
We can pick the same first four and choose 12 for our last books instead of 11 giving us:
3,5,7,9,12
With 3,5, and 7 picked we can also take 10 and 12 giving us:
3,5,7,10,12
With 3, and 5 we can take 8 as our third book giving us:
3,5,8,10,12
And our final pick with 3 as the first choice is:
3,6,8,10,12

Following an identical process and working through all the other options and tabulating the totals I came up with the following:
1 sequence with 4 as the first book selected
5 sequences with 3 as the first book selected
15 sequences with 2 as the first book selected
35 sequences with 1 as the first book selected
Total = 56 sequences

Is there a more elegant way to approach this problem? If we were talking about a shelf with 100 books and choosing 25 my solution would not be very practical.

A guy in my study group came up with C(8,3) which by formula is 8!/(3!5!) which does equal 56, so I suspect he's got the correct idea. I just can't see how he jumped to the formula from the given information since he didn't show any of his work. I've asked him to explain his process, but it's an online class and and I don't know how long it will take him to respond.

Anyone care to give me some help? Anyone, anyone? Buehler?
__________________
I used to be somebody but now I am somebody else
Who I'll be tomorrow is anybody's guess
Reply With Quote
  #2  
Old February 25th, 2007, 09:23 PM
Suicide Junkie's Avatar
Suicide Junkie Suicide Junkie is offline
Shrapnel Fanatic
 
Join Date: Feb 2001
Location: Waterloo, Ontario, Canada
Posts: 11,451
Thanks: 1
Thanked 4 Times in 4 Posts
Suicide Junkie is on a distinguished road
Default Re: OT: Math help. Permutations and Combinations

What if you think of it in terms of the required block of 8 alternating... then choosing spots for the four remaining unchosen books?
Reply With Quote
  #3  
Old February 25th, 2007, 10:52 PM
douglas's Avatar

douglas douglas is offline
Major
 
Join Date: Apr 2004
Location: Atlanta, Georgia
Posts: 1,152
Thanks: 0
Thanked 0 Times in 0 Posts
douglas is on a distinguished road
Default Re: OT: Math help. Permutations and Combinations

Five bars, seven stars, no two bars can be adjacent. The adjacency requirement is equivalent to every bar must have either a star or nothing to its left. Let's introduce a new term, foo, that is a star on the left and a bar on the right. If the leftmost book is a bar, then you have four foos and three stars to arrange, which is a simple problem of C(7, 3). Otherwise, there are five foos and two stars, with C(7, 2) combinations. The solution is the sum of these.

C(7,3) + C(7,2)
7!/(4!*3!) + 7!/(5!*2!)
7*6*5/(3*2) + 7*6/2
7*5 + 7*3
35 + 21 = 56

For the problem of picking 25 non-adjacent books from 100, it would be C(75, 51) + C(75, 50) = 78367246720143449328.

More generally, picking A non-adjacent books from B total is: C(B-A, B-2A+1) + C(B-A, B-2A). Incidentally, this is the same as C(B-A+1, B-2A+1) though I don't feel like going through the proof of that. I just remembered that the two combinations added together above are adjacent numbers in Pascal's Triangle, and their sum is the number right below them, which is given by the other combination.
Reply With Quote
  #4  
Old February 26th, 2007, 05:35 PM
capnq's Avatar

capnq capnq is offline
General
 
Join Date: Feb 2001
Location: Pittsburgh, PA, USA
Posts: 3,070
Thanks: 13
Thanked 9 Times in 8 Posts
capnq is on a distinguished road
Default Re: OT: Math help. Permutations and Combinations

Stuff like this is why I failed three different probability and statistics courses in college.
__________________
Cap'n Q

"Good morning, Pooh Bear," said Eeyore gloomily. "If it is a good morning," he said. "Which I doubt," said he.
Reply With Quote
  #5  
Old February 26th, 2007, 11:13 PM
Will's Avatar

Will Will is offline
Lieutenant Colonel
 
Join Date: Mar 2001
Location: Emeryville, CA
Posts: 1,412
Thanks: 0
Thanked 0 Times in 0 Posts
Will is on a distinguished road
Default Re: OT: Math help. Permutations and Combinations

Another way to think of it (and this is probably how the guy in your study group got C(8,3)):

You have twelve books in a row, and are choosing five. To find the combinations, change the problem slightly to having a row of seven books, and inserting another five such that none of the inserted books are adjacent. Find the number of ways you can insert the books.

I will use the problem's analogy of bars and stars, except I'll be using $ instead of * to avoid confusion with multiplication:

$ $ $ $ $ $ $

Now, you have five bars to insert into this sequence somehow. There are a total of eight slots to possibly add a bar to:

1 $ 2 $ 3 $ 4 $ 5 $ 6 $ 7 $ 8

To insert the first bar, you have 5 bars to choose from to insert into 8 slots. For the second bar, you have 4 bars to choose from to insert into 7 slots... and for the nth bar, you have (5-n) bars to choose from to insert into (8-n) slots. This gives you:

(8*7*6*5*4) / (5*4*3*2*1)

You can multiply this by 1 = 3!/3! to get:

8! / (5! * 3!) = C(8,3)

For the general solution of fitting X bars into a sequence of Y stars, such that no two bars are adjacent, you then have:

(Y+1)*Y* ... *(Y-X+2) / X!

Which you can then multiply by 1 = (Y-X+1)!/(Y-X+1)! to get:

(Y+1)! / X! * (Y-X+1)! = C(Y+1, Y-X+1)

Plugging in the values of 7 stars for Y and 5 bars for X, it is easy to see that we get C(8,3), just like we should.
__________________
GEEK CODE V.3.12: GCS/E d-- s: a-- C++ US+ P+ L++ E--- W+++ N+ !o? K- w-- !O M++ V? PS+ PE Y+ PGP t- 5++ X R !tv-- b+++ DI++ D+ G+ e+++ h !r*-- y?
SE4 CODE: A-- Se+++* GdY $?/++ Fr! C++* Css Sf Ai Au- M+ MpN S Ss- RV Pw- Fq-- Nd Rp+ G- Mm++ Bb@ Tcp- L+
Reply With Quote
  #6  
Old February 26th, 2007, 11:35 PM
narf poit chez BOOM's Avatar

narf poit chez BOOM narf poit chez BOOM is offline
Shrapnel Fanatic
 
Join Date: Mar 2003
Location: CHEESE!
Posts: 10,009
Thanks: 0
Thanked 7 Times in 1 Post
narf poit chez BOOM is on a distinguished road
Default Re: OT: Math help. Permutations and Combinations

What's that '!' ?
__________________
If I only could remember half the things I'd forgot, that would be a lot of stuff, I think - I don't know; I forgot!
A* E* Se! Gd! $-- C-^- Ai** M-- S? Ss---- RA Pw? Fq Bb++@ Tcp? L++++
Some of my webcomics. I've got 400+ webcomics at Last count, some dead.
Sig updated to remove non-working links.
Reply With Quote
  #7  
Old February 26th, 2007, 11:43 PM
Suicide Junkie's Avatar
Suicide Junkie Suicide Junkie is offline
Shrapnel Fanatic
 
Join Date: Feb 2001
Location: Waterloo, Ontario, Canada
Posts: 11,451
Thanks: 1
Thanked 4 Times in 4 Posts
Suicide Junkie is on a distinguished road
Default Re: OT: Math help. Permutations and Combinations

! = factorial.

For nice positive integers, you start with the number, and multiply it by all the numbers below it until you get to 1.

5! = 5x4x3x2x1 = 120

It gets uglier when you throw in negatives, or fractional numbers.
Reply With Quote
  #8  
Old February 27th, 2007, 05:55 PM
Cipher7071's Avatar

Cipher7071 Cipher7071 is offline
Second Lieutenant
 
Join Date: Nov 2003
Posts: 482
Thanks: 1
Thanked 0 Times in 0 Posts
Cipher7071 is on a distinguished road
Default Re: OT: Math help. Permutations and Combinations

I vote for the "foos."
__________________
The great tragedy of science...the slaying of a beautiful hypothesis by an ugly fact. (T. H. Huxley)
Reply With Quote
  #9  
Old February 27th, 2007, 10:41 PM
narf poit chez BOOM's Avatar

narf poit chez BOOM narf poit chez BOOM is offline
Shrapnel Fanatic
 
Join Date: Mar 2003
Location: CHEESE!
Posts: 10,009
Thanks: 0
Thanked 7 Times in 1 Post
narf poit chez BOOM is on a distinguished road
Default Re: OT: Math help. Permutations and Combinations

Why? Do you pity the foo?

Oh man...I'm not sure whether to laugh maniacally or run...
__________________
If I only could remember half the things I'd forgot, that would be a lot of stuff, I think - I don't know; I forgot!
A* E* Se! Gd! $-- C-^- Ai** M-- S? Ss---- RA Pw? Fq Bb++@ Tcp? L++++
Some of my webcomics. I've got 400+ webcomics at Last count, some dead.
Sig updated to remove non-working links.
Reply With Quote
  #10  
Old February 28th, 2007, 10:47 AM
capnq's Avatar

capnq capnq is offline
General
 
Join Date: Feb 2001
Location: Pittsburgh, PA, USA
Posts: 3,070
Thanks: 13
Thanked 9 Times in 8 Posts
capnq is on a distinguished road
Default Re: OT: Math help. Permutations and Combinations

Quote:
narf poit chez BOOM said: I'm not sure whether to laugh maniacally or run...
Why not do both?
__________________
Cap'n Q

"Good morning, Pooh Bear," said Eeyore gloomily. "If it is a good morning," he said. "Which I doubt," said he.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 12:55 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2024, Shrapnel Games, Inc. - All Rights Reserved.