mustangsally
mustangsally
  • Threads: 25
  • Posts: 2463
Joined: Mar 29, 2011
December 31st, 2017 at 12:11:49 PM permalink
standard deck of cards
values:
Ace = 1
2 thru 9 pip value (2-9)
10 = 10
J, Q, K = 10

draw 10 cards without replacement
calculate uniques in draw 10 from deck of cards
for 8, 6 and 4 uniques (all would be ok)

example 10 card draw
A,2,3,4,5
6,K,10,3,J
unique (or distinct type of value)
A,2,3,4,5,6,K
10,3,J are repeat
so
count = 7 unique values

I have no place to start except brute force (yuk)
uniquesways
18008
21590732
357596616
4654960768
52922437952
65627446272
74736901120
81627324416
9187564032
104194304

was thinking maybe figure repeats 1st then subtract from 1
without replacement throws me outside

this has to be hard. (or everyone could do it)

My KU friend asked about it.
Happy New Year!

Sally
I Heart Vi Hart
JB
Administrator
JB
  • Threads: 334
  • Posts: 2089
Joined: Oct 14, 2009
December 31st, 2017 at 1:21:51 PM permalink
Since the suits don't matter, you can go about this in a different way.

Have 10 loops, one for each point value, where each loop counter goes from 0 to 4 (or 0 to 16 for 10-pointers) inclusive. This is only 33,203,125 iterations.

Inside the innermost loop, sum the 10 counts and continue the loop (skip the inner body) if the sum is not 10.

Calculate the number of uniques.

Calculate the weight factor for this distribution.

Increase the counts for this number of uniques by this weight factor.

Presto, it takes a second or two and produces the same results you calculated above.

C# code:


using System;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var counts = new long[11];

for (var _A = 0; _A <= 4; ++_A)
for (var _2 = 0; _2 <= 4; ++_2)
for (var _3 = 0; _3 <= 4; ++_3)
for (var _4 = 0; _4 <= 4; ++_4)
for (var _5 = 0; _5 <= 4; ++_5)
for (var _6 = 0; _6 <= 4; ++_6)
for (var _7 = 0; _7 <= 4; ++_7)
for (var _8 = 0; _8 <= 4; ++_8)
for (var _9 = 0; _9 <= 4; ++_9)
for (var _T = 0; _T <= 16; ++_T)
{
if ((_A + _2 + _3 + _4 + _5 + _6 + _7 + _8 + _9 + _T) != 10) continue;

var unique = 0;

unique += _A != 0 ? 1 : 0;
unique += _2 != 0 ? 1 : 0;
unique += _3 != 0 ? 1 : 0;
unique += _4 != 0 ? 1 : 0;
unique += _5 != 0 ? 1 : 0;
unique += _6 != 0 ? 1 : 0;
unique += _7 != 0 ? 1 : 0;
unique += _8 != 0 ? 1 : 0;
unique += _9 != 0 ? 1 : 0;
unique += _T != 0 ? 1 : 0;

var weight = 1L;

weight *= Combin( 4, _A);
weight *= Combin( 4, _2);
weight *= Combin( 4, _3);
weight *= Combin( 4, _4);
weight *= Combin( 4, _5);
weight *= Combin( 4, _6);
weight *= Combin( 4, _7);
weight *= Combin( 4, _8);
weight *= Combin( 4, _9);
weight *= Combin(16, _T);

counts[unique] += weight;
}

Console.WriteLine(" 1 = {0:#,##0}", counts[ 1]);
Console.WriteLine(" 2 = {0:#,##0}", counts[ 2]);
Console.WriteLine(" 3 = {0:#,##0}", counts[ 3]);
Console.WriteLine(" 4 = {0:#,##0}", counts[ 4]);
Console.WriteLine(" 5 = {0:#,##0}", counts[ 5]);
Console.WriteLine(" 6 = {0:#,##0}", counts[ 6]);
Console.WriteLine(" 7 = {0:#,##0}", counts[ 7]);
Console.WriteLine(" 8 = {0:#,##0}", counts[ 8]);
Console.WriteLine(" 9 = {0:#,##0}", counts[ 9]);
Console.WriteLine("10 = {0:#,##0}", counts[10]);
Console.ReadLine();
}

static int Combin(int n, int k)
{
if (k > n) return 0;
if (n == k) return 1;
if (k > (n - k)) k = n - k;

var num = 1;
var den = 1;

for (var z = 1; z <= k; --n, ++z)
{
num *= n;
den *= z;

if ((num % den) == 0)
{
num /= den; den = 1;
}
}

return num / den;
}
}
}
mustangsally
mustangsally
  • Threads: 25
  • Posts: 2463
Joined: Mar 29, 2011
December 31st, 2017 at 7:24:48 PM permalink
thank you

looks like my code in R and Excel did ok
but is slow to use.
this was easier

still there should be an easier math solution
I would think
will look more into it next year!
I Heart Vi Hart
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6741
Joined: Jun 22, 2011
January 1st, 2018 at 7:38:58 AM permalink
Quote: mustangsally

still there should be an easier math solution
I would think
will look more into it next year!


I think the main reason there isn't is, the number of cards of each value isn't the same. There are 16 10s, but only 4 9s, 8s, ..., 2s, and 1s.

Look at the possible ways of having three unique values:
8-1-1 (e.g. eight 10s, one 6, and one 9)
7-2-1
6-3-1
6-2-2
5-4-1
5-3-2
4-4-2
4-3-3
Since the only value with more than 4 cards is 10, the first six lines have to start with 10s
mustangsally
mustangsally
  • Threads: 25
  • Posts: 2463
Joined: Mar 29, 2011
January 1st, 2018 at 9:29:24 AM permalink
Quote: ThatDonGuy

I think the main reason there isn't is, the number of cards of each value isn't the same.

yes, I thought that. I think it deals with 2 summations and basic inclusion-exclusion.
Quote: ThatDonGuy

Look at the possible ways of having three unique values:
<snip>
Since the only value with more than 4 cards is 10, the first six lines have to start with 10s

That's it!
"Look at the possible ways"

partitions

I have some R code that does just that
(actually there R lots of script for that, just did not have any reason to use any of them)
and from there it is super easy
to sum all the possible ways for each draw combo.

of course, the C# code worked so well, I completed my project real fast already.
so this will get on the wait list.

thank you
Now parade time and football!
Sally
I Heart Vi Hart
  • Jump to: