View this page "Assignment #3"

3 views
Skip to first unread message

Scott Haines

unread,
May 6, 2010, 3:36:22 AM5/6/10
to Hacker Dojo PHP
Homework has been updated. Aaron caught a typo in the Workshop problem

Click on http://groups.google.com/group/hacker-dojo-php/web/assignment-3?hl=en
- or copy & paste it into your browser's address bar if that doesn't
work.

Caryl Westerberg

unread,
May 10, 2010, 12:54:53 PM5/10/10
to hacker-...@googlegroups.com
Hi Scott,

Just a quick comment on the formula - It will only work when the number of sides (s) is greater than or equal to the number of dice (d). (d <= s). A more general case is more complex.  Has anyone else solved it for the case where d > s?

Caryl
---------------------------
Workshop.

Problem: *edited
You need to compute the total number of unique possible combination's for n number of dice rolled at random. (*note. N stands for a dynamic number at run-time)

Given the following formula, please create a working class named Dice that will accept a public variable of $totalDice during Instantiation with a method called computePossibilities that will return the number of total combination's available for $totalDice.

Combos = (s x s - q ... ) where s = sides and q = sides - 1 for each dice in $totalDice
Example: 3 dice = (6 x 5 x 4) = 120 possible combination's.
--
Caryl Westerberg
cjw...@acm.org

Rise 'n Shine!


Scott Haines

unread,
May 14, 2010, 10:33:26 AM5/14/10
to hacker-...@googlegroups.com
Caryl,
The formula has been modified slightly from a book I was reading called Innumeracy by John Allen Paulos (http://www.amazon.com/Innumeracy-Mathematical-Illiteracy-Its-Consequences/dp/0809058405/ref=sr_1_1?ie=UTF8&s=books&qid=1273847285&sr=1-1)

He has some chapters devoted to probability and chance, how many unique combinations of ice cream cones (3 scoop) can you get at Baskin Robins (32 flavors), 32 x 31 x 30 combinations if you don't want to repeat the same 3 in order. It gets more complex, but I thought it would turn into a very interesting word problem.

The formula was probably off by a little! I have never been perfect at writing mathematical proofs or visual algorithmic structures. (I am doing MIT Open Course on Algorithms though to try and change that) 

I hope that homework assignment proved to be a little fun though, and I had never thought about the sides comparison.

A for effort! Stumping the teacher!

By the way, I am not sure if you saw my comment on free amazon ec2 accounts, Doug is setting this up through Amazon for the first 10 or so who want the accounts. They are a corporate sponsor of the Dojo.
--
Scott Haines
Founder / Creative Director / Lead Architect
Newfront Creative LLC
P 408.905.8473 C 408.705.7833
http://www.newfrontcreative.com
http://www.twitter.com/newfront
Reply all
Reply to author
Forward
0 new messages