|
|
| Do you know where your variables are? | |
| PerlMonks |
Re^2: Parens permutations (formula)by tye (Sage) |
| on Aug 05, 2003 at 15:57 UTC ( [id://281141]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
And these counts can be computed much faster using: Taking $len==4 for example, that boils down to: which is an interesting equation. A mathematician might write it as: And it is interesting to me that I need to test for 1==$len but I don't need to test for 0==$parens. Note that replacing $len with $parens+1 and $parens with $len-1 gives us the same values. So I suspect the equation can be rewritten as (mostly) the product of two binomial coefficents (number of different subsets of size S you can pick from a set of size N). But I don't have the time to figure out all of the off-by-ones at the moment. Update: But C(P+L,P+1) == C(P+L,L-1) == (P+L)!/(P+1)!/(L-1)! so ?? == C(P+L,P+1)/(P+L). So the number of ways to put P parens into a string of length L is ...I think. (: Now, someone just needs to explain why this formula makes sense. Then we'll have worked the problem "backward" and in future math classes the solution can be presented in the "forward" direction and we can intimidate another generation of students into thinking that they'd never be able to solve math problems... thus continuing a long tradition of mathematicians. ;) - tye
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||