9
1
In this task you are given an odd number of white balls and the same number of black balls. The task is to count all the ways of putting the balls into bins so that in each bin there is an odd number of each color.
For example, say we have 3 white balls. The different ways are:
(wwwbbb)
(wb)(wb)(wb)
for the two different possibilities.
If we have 5 white balls the different ways are:
(wwwwwbbbbb)
(wwwbbb)(wb)(wb)
(wwwb)(wbbb)(wb)
(wb)(wb)(wb)(wb)(wb)
You can take the input, which is a single integer, in any way you like. The output is just a single integer.
Your code must be fast enough so that you have seen it complete for 11 white balls.
You can use any language or library that you like.
Please clarify, can our output be just the number of different ways? That is, a single number as output? – orlp – 2018-04-14T19:10:13.877
@orlp I think that is what Lembik meant. There are also only 705432 possible combinations disregarding the rules of odd numbers only for 11 balls of each colour – fəˈnɛtɪk – 2018-04-14T19:12:35.520
@orlp Yes a single number. Having said that, it would be very interesting to see the list of possible assignments of balls in bins if anyone wanted to show those too. – None – 2018-04-14T19:16:45.997
5
I assume this is from https://math.stackexchange.com/questions/2736933/how-many-ways-to-get-an-odd-number-of-each-color-in-each-bin You should cite it @Lembik
– qwr – 2018-04-14T19:21:12.6333I think you should take out the speed criterion or make it more specific. "Fast enough" is too vague. – dylnan – 2018-04-14T19:56:00.597
1You know that PPCG users are crazy enough that they would rather spending money on using a supercomputer to compute it for 11 than taking 1 more byte? So why wasting their money?
:)
– user202729 – 2018-04-15T02:48:43.340rather spending money on using a supercomputer
only apply for [tag:code-golf], though – l4m2 – 2018-04-15T16:00:30.560relevant to current conversation – ASCII-only – 2018-04-17T10:13:07.583
1
(remark: It's possible to calculate P function efficiently with a complicated formula. It may be possible to calculate this function too, with a suitable formula.)
– user202729 – 2018-04-18T15:00:46.027I have added this to the On-Line Encyclopedia of Integer Sequences (OEIS) as sequence A302919.
– Peter Kagey – 2019-03-16T00:21:53.293