Problem 181

A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.

This forum is NOT meant to discuss solution methods for a problem.

In particular don't post any code fragments or results.

Don't start begging others to give partial answers to problems

Don't ask for hints how to solve a problem

Don't start a new topic for a problem if there already exists one


See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
User avatar
sfabriz
Posts: 175
Joined: Thu Apr 06, 2006 12:18 am
Location: London - UK

Problem 181

Post by sfabriz »

Hello,

about problem181: what the answer would be for BBWW ?

Would it be 9 with the following groups?

BBWW
B,BWW - BB,WW - BBW,W - BW,BW
B,B,WW - B,BW,W - BB,W,W
B,W,W,W

Cheers,
sfabriz
Image
User avatar
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: Problem 181

Post by daniel.is.fischer »

Yep.
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
Robert_Gerbicz
Posts: 26
Joined: Sat Oct 13, 2007 2:44 pm

Re: Problem 181

Post by Robert_Gerbicz »

Yes, that's correct.
User avatar
sfabriz
Posts: 175
Joined: Thu Apr 06, 2006 12:18 am
Location: London - UK

Re: Problem 181

Post by sfabriz »

Ah, all right, thank you very much, now I should know what to do.

Cheers,
sfabriz
Image
Taifu
Posts: 34
Joined: Sun Jan 13, 2008 8:38 pm

Re: Problem 181

Post by Taifu »

sfabriz wrote:Hello,

about problem181: what the answer would be for BBWW ?

Would it be 9 with the following groups?

BBWW
B,BWW - BB,WW - BBW,W - BW,BW
B,B,WW - B,BW,W - BB,W,W
B,W,W,W

Cheers,
sfabriz
sfabriz,
perhaps last one is B,B,W,W ? :-)
Ciao.
Marco.
Image
User avatar
sfabriz
Posts: 175
Joined: Thu Apr 06, 2006 12:18 am
Location: London - UK

Re: Problem 181

Post by sfabriz »

Taifu wrote: sfabriz,
perhaps last one is B,B,W,W ? :-)
Ciao.
Marco.
Yes, it is indeed. It's just a typo.
Ciao!
Image
robheus
Posts: 31
Joined: Thu Jun 12, 2008 5:01 pm

Problem 181

Post by robheus »

Here is how the problem is formulated:
Having three black objects B and one white object W they can be grouped in 7 ways like this:
(BBBW)	(B,BBW)	(B,B,BW)	(B,B,B,W) 	(B,BB,W)	(BBB,W)	(BB,BW)

In how many ways can sixty black objects B and forty white objects W be thus grouped?
As we can see from the example, the colors don't matter at all, and it seems the problem can be simply re-formulated like this:
In how many ways can any number (including zero) of separators be placed in any position between any two objects (objects layed out sequentially in a row) if there are N objects (so, there are N-1 positions between objects).
Which is realy a simple problem, as it is the summation of placing 0 up to N-1 seperators in N-1 possible locations (each location can have at most 1 seperator), and for placing k seperators in N-1 possible positions this is the well-known formula:

(summation of)
n! / ( k! * (n-k)! )

where n=N-1 and k from 0..N-1

In fact you do not need to use combinatorics equations, since it is either one of N-1 places contains a separator yes or no, which is simply the power equation:

2N-1-1

For 4 objects we have thus 3 places, and the above equation yields 7.

But this turns out to be the wrong answer as for the case of 60 B and 40 W (= 100) objects, I assumed this would be 299-1 which is 633825300114114700748351602687.

So I suppose this re-formulation is somehow wrong, but then I don't understand the problem.

In what way does the color matter???

(and perhaps I think the problem needs clearer formulation if that is the case, since the example looks like the color does not matter, just the number of objects)
Last edited by robheus on Thu Jun 12, 2008 7:30 pm, edited 1 time in total.
User avatar
stijn263
Posts: 1505
Joined: Sat Sep 15, 2007 11:57 pm
Location: Netherlands

Re: Problem 181

Post by stijn263 »

With B = 2 and W = 2 I get 9 ways to group:
BBWW
B,BWW - BB,WW - BBW,W - BW,BW
B,B,WW - B,BW,W - BB,W,W
B,W,W,W
And with B = 4 I get 5 ways to group:
BBBB
B,BBB - BB,BB
B,B,BB
B,B,B,B
Doraki
Posts: 13
Joined: Sat Apr 19, 2008 9:59 pm

Re: Problem 181

Post by Doraki »

In that example, what about the (BB,B,W) grouping ?
robheus
Posts: 31
Joined: Thu Jun 12, 2008 5:01 pm

Re: Problem 181

Post by robheus »

stijn263 wrote:With B = 2 and W = 2 I get 9 ways to group:
BBWW
B,BWW - BB,WW - BBW,W - BW,BW
B,B,WW - B,BW,W - BB,W,W
B,W,W,W
The last one I assume is incorrect and should be
B,B,W,W
since we use 2 B and 2 W, but that is aside of the issue.
And with B = 4 I get 5 ways to group:
BBBB
B,BBB - BB,BB
B,B,BB
B,B,B,B
I get the picture, I guess.

So I guess that:
(B,B,B,W)
and
(B,W,B,B
) (for the original 2 B 2 W problem) designate the same grouping and count only once.

and while for the 4 B variant
(B,B,BB
) is equal to
(B,BB,B)
and equal to
(BB,B,B)
and count as 1

in case of the 2 B 2 W variant

(B,B,WW) is different from (B,BW,W) and count as 2
Last edited by robheus on Thu Jun 12, 2008 7:38 pm, edited 2 times in total.
robheus
Posts: 31
Joined: Thu Jun 12, 2008 5:01 pm

Re: Problem 181

Post by robheus »

Doraki wrote:In that example, what about the (BB,B,W) grouping ?
In the example given, there are 2 B and 2 W so there is no
(BB,B,W)
group.

Edit: If referring to the original problem, the
(BB,B,W)
group is already considered, but in a different ordering:
(B,BB,W)
.
But for this type of problem, the ordering of the elements in the group are not important.
User avatar
GenePeer
Posts: 112
Joined: Sat Apr 03, 2010 1:14 pm
Contact:

Re: Problem 181

Post by GenePeer »

Can anyone explain to me the C code Robert_Gerbicz "translated" from posted PARI solution? I don't mean explaining what the code is doing (C is very similar to Java so I was able to implement it) but explaining its relation to the problem.

Thanks.
Image
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 181

Post by hk »

This forum is not a place to discuss solutions.
So if someone wants to answer this question please do so in the problems forum.
It's still open and there is plenty of room there.

@GenePeer: as the problems forum is still open, the place to ask your question is there.
Image
War ruins the life and health of untold numbers of innocent children.
User avatar
GenePeer
Posts: 112
Joined: Sat Apr 03, 2010 1:14 pm
Contact:

Re: Problem 181

Post by GenePeer »

Those forums seem to be active only when the problem is released. I was hoping someone who understands it would send me a PM, not discuss it here.

PS: Can there be a notification system like "View your posts" where you can see if there are new replies in forums you posted in? Maybe this could help spark activity in those threads.
Image
User avatar
hk
Administrator
Posts: 12832
Joined: Sun Mar 26, 2006 10:34 am
Location: Haren, Netherlands

Re: Problem 181

Post by hk »

The correct way would have been:
post your question in the problems forum and ask here if someone is willing to answer it there.
In that way your question (and hopefully answer) would contribute to the problems forum and spark activity there.
PM-ing explanations to each other doesn't contribute to the community.
Image
War ruins the life and health of untold numbers of innocent children.
User avatar
GenePeer
Posts: 112
Joined: Sat Apr 03, 2010 1:14 pm
Contact:

Re: Problem 181

Post by GenePeer »

Done.

I just posted a question on the problem's solution-thread. Can someone answer it? Thanks.
Image
LarryBlake
Posts: 100
Joined: Sat Aug 29, 2009 8:49 pm

Re: Problem 181

Post by LarryBlake »

I get the correct answers for BBBW and BBWW.

For B(5)W(5), I get 335. Is that correct?
Image
User avatar
Marcus_Andrews
Administrator
Posts: 1637
Joined: Wed Nov 09, 2011 5:23 pm

Re: Problem 181

Post by Marcus_Andrews »

LarryBlake wrote:I get the correct answers for BBBW and BBWW.

For B(5)W(5), I get 335. Is that correct?
I'm afraid not -- but you're close!
snapey1979
Posts: 5
Joined: Thu Mar 01, 2012 1:11 pm

Re: Problem 181

Post by snapey1979 »

I found the example for this problem a little confusing. In particular, as I read it, you had to keep the original "string" of Black and Whites in the same order. i.e. for BBWW, I thought the groupings were (BBWW), (B,BWW), (BB,WW), (BBW,W), (B,B,WW), (B, BW,W), (BB,B,W) and (B,B,W,W). But, crucially, not (BW,BW)

This forum explanation of groups for BBWW (i.e. (BW, BW) is valid) explained this, but without the forum I think I would have banged my head for a long time (particularly as my solution with the order of the original string preserved gives the right answers for a number of cases).

I wonder if a further example with a grouping that includes such a group might be useful. On the other hand, might just be me as many others have passed this way before...
Perlkonig
Posts: 5
Joined: Tue Aug 21, 2012 3:31 pm

Re: Problem 181

Post by Perlkonig »

Uhm, why is the grouping (BB,B,W) not also valid? Is that what I'm supposed to figure out? Thus the phrase "thus grouped"? If so, my suggestion would be to reword the problem to make the "riddle" aspect more explicit.
Post Reply