Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Unique patterns

3 views
Skip to first unread message

zaca...@gmail.com

unread,
Sep 11, 2007, 6:18:18 PM9/11/07
to
1. Im sorry if i have posted in the wrong group.
2. English is not my native language and if i have trouble explaining
my self im sorry for that too.
3. This is NOT homework. I have gotten that message alot and its
simply enoying!

It has to do with cards. A deck of cards has 52 cards and a single
card can have 4 different suits and 13 different values.
I drawing two cards, obiously they cant be exactly simular. Also im
ignoring the order of the cards im drawing.
e.g.
52*51 / 2! = 1326 different hands

A single card can be looked upon like this:
{Suit, Value}
fx.
NB! im using ranges starting from zero fx. 0-3 instead of 1-4.

{3,12} & {3,11}

This hand would equal Ace King or Queen King in the same suit,
dependent on Ace being assigned lowest or highest value, but it doesnt
matter here.

The goal is to somehow calculate this specific hands unique patter in
the range of 0-1325.
Of course this can be done, quite easily all though the soltion to the
problem illudes me, but im allso interested in different ways of doing
it as im confident that it is possible to derive various information
from this patter if done proberbly, fx. if the cards are suited,
connected or both, or if a pair is present.
If my assumption is incorrect i will still need the solution though.
Allso i need a generel solution for hands with up to 7 cards. 7 cards
however is the limit.

NB! The ability to derive the actual values and suit of the cards
later on is NOT important.


I hope you can and will help me.


Regards

Message has been deleted

matt271...@yahoo.co.uk

unread,
Sep 11, 2007, 8:03:06 PM9/11/07
to

If you number the cards from 1 to 52 (however you choose) and order
the hand by ascending card number, then I think the formula I gave
recently at http://groups.google.com/group/sci.math/browse_frm/thread/eb65d32877f11001.
for converting combinations to "sequence numbers" might do what you
need. For each unique hand it should give you a corresponding unique
"hand number". You would need n = 52 and k = number of cards in hand.
You would need to subtract one if you want the hand numbering to start
at zero.

zaca...@gmail.com

unread,
Sep 11, 2007, 8:08:11 PM9/11/07
to
> recently athttp://groups.google.com/group/sci.math/browse_frm/thread/eb65d32877f....

> for converting combinations to "sequence numbers" might do what you
> need. For each unique hand it should give you a corresponding unique
> "hand number". You would need n = 52 and k = number of cards in hand.
> You would need to subtract one if you want the hand numbering to start
> at zero.- Skjul tekst i anførselstegn -
>
> - Vis tekst i anførselstegn -

thanks, ill look at it.

zaca...@gmail.com

unread,
Sep 11, 2007, 8:17:22 PM9/11/07
to
> thanks, ill look at it.- Skjul tekst i anførselstegn -

>
> - Vis tekst i anførselstegn -

is this the answer you are talking about?

C(n, k) - sum_j=1^k C(n - x(j), k - j + 1)

if that is the case i dont quite understand it.
Im fairly good at math, but when it comes to this im lost.

matt271...@yahoo.co.uk

unread,
Sep 11, 2007, 8:31:05 PM9/11/07
to

Yes. There's a post in that thread at http://groups.google.com/group/sci.math/msg/ba950279560ed270
which gives an explanation of what the formula means, along with an
example of how to apply it. See if that makes any sense.


zaca...@gmail.com

unread,
Sep 11, 2007, 8:52:04 PM9/11/07
to
> Yes. There's a post in that thread athttp://groups.google.com/group/sci.math/msg/ba950279560ed270

> which gives an explanation of what the formula means, along with an
> example of how to apply it. See if that makes any sense.- Skjul tekst i anførselstegn -

>
> - Vis tekst i anførselstegn -

I cant say i understand this, but i do understand that 52! is a HUGE
number, so enless i have misinterpeted something, this is not useable.
C(x, y) = x!/(y!*(x - y)!)

matt271...@yahoo.co.uk

unread,
Sep 11, 2007, 9:10:12 PM9/11/07
to

52! is indeed a huge number, but C(52,k) is not huge for small k (and
if you have large k -- i.e. large hands -- then you inevitably will be
dealing with huge numbers because there are so many different hands).
The way I wrote the definition above is the usual way, but you do not
actually need to calculate 52! because large chunks of the numerator
and denominator cancel. Specifically:

C(52,1) = 52/1!
C(52,2) = 52*51/2!
C(52,3) = 52*51*50/3!
C(52,4) = 52*51*50*49/4!
etc.

zaca...@gmail.com

unread,
Sep 11, 2007, 9:35:43 PM9/11/07
to
> etc.- Skjul tekst i anførselstegn -

>
> - Vis tekst i anførselstegn -

ok, so in this case C(n,k) = 1326, that i can understand.
the formula:


C(n, k) - sum_j=1^k C(n - x(j), k - j + 1)

however still doesnt make sence, ive tryed to read your post again and
again and i would hate to make you explain it again, but so far i dont
get it. I will try again though.

zaca...@gmail.com

unread,
Sep 11, 2007, 9:58:08 PM9/11/07
to
I have turned it all upside down over and over again without getting a
better understanding of it, im sorry for wasting your time here,
thanks for the help.

matt271...@yahoo.co.uk

unread,
Sep 11, 2007, 10:13:10 PM9/11/07
to

It shouldn't be too hard. In your first example, with hands of two
cards, we have n = 52 and k = 2. You know how to calculate C(n, k), so
that takes care of the first term.

Then, for each value of j from j = 1 to j = k (i.e. in this case, just
for j = 1 and j = 2), calculate C(n - x(j), k - j + 1), where x(1) is
the number of the first card in the hand (cards numbered 1 to 52, in
whatever way you choose), and x(2) is the number of the second card,
with x(1) < x(2).

Add all these terms (in this case just two of them) together, subtract
the sum from C(n, k), and you're done.

Good luck.

matt271...@yahoo.co.uk

unread,
Sep 11, 2007, 10:18:38 PM9/11/07
to

Oh, except that if you want the hands numbered from 0 to 1325 (rather
than 1 to 1326) you will need to subtract 1.

zaca...@gmail.com

unread,
Sep 11, 2007, 11:04:20 PM9/11/07
to
> than 1 to 1326) you will need to subtract 1.- Skjul tekst i anførselstegn -

>
> - Vis tekst i anførselstegn -

Thank you, just have to do something and then ill try it out.

zaca...@gmail.com

unread,
Sep 11, 2007, 11:49:11 PM9/11/07
to
> Thank you, just have to do something and then ill try it out.- Skjul tekst i anførselstegn -

>
> - Vis tekst i anførselstegn -

This is the result i arive at when using cards 52 and 51 as an
example, i do this because i expect to get 1326 as a result:

C(52,2) - C(52 - 51, 2 - 1 + 1) + C(52 - 52, 2 - 2 + 1)
(52*51 / 2!) - C(1, 2) + C(0, 1)
(52*51 / 2!) - (1*0 / 2!) + (0 / 1!)
1326 - 0 + 0
1326

seem right.

Doing it with the lowest possible values, 1 and 2, where i expect to
get the result 1:

C(52,2) - C(52 - 1, 2 - 1 + 1) + C(52 - 2, 2 - 2 + 1)
(52*51 / 2!) - C(51, 2) + C(50, 1)
(52*51 / 2!) - (51*50 / 2!) + (50 / 1!)
1326 - 1275 + 50
1

again it seems to work.

first i didnt see the "x(1) < x(2)" comment and did it wrong.

It is enoying that hte order of the values does matter, but you cant
get it all i supose.

Thank you for your help.

Chip Eastham

unread,
Sep 12, 2007, 1:25:44 AM9/12/07
to
On Sep 11, 6:18 pm, zacar...@gmail.com wrote:
> 1. Im sorry if i have posted in the wrong group.
> 2. English is not my native language and if i have trouble explaining
> my self im sorry for that too.
> 3. This is NOT homework. I have gotten that message alot and its
> simply enoying!
>
> It has to do with cards. A deck of cards has 52 cards and a single
> card can have 4 different suits and 13 different values.
> I drawing two cards, obiously they cant be exactly simular. Also im
> ignoring the order of the cards im drawing.
> e.g.
> 52*51 / 2! = 1326 different hands

Okay, we need to map all possible pairs of cards
to a number between 0 and 1325.

> A single card can be looked upon like this:
> {Suit, Value}
> fx.
> NB! im using ranges starting from zero fx. 0-3 instead of 1-4.
>
> {3,12} & {3,11}

The mapping from (Suit,Value) to a number between 0 and 51 is
Suit + Value*4 (assuming Suit is 0 to 3 & Value is 0 to 13).

> This hand would equal Ace King or Queen King in the same suit,
> dependent on Ace being assigned lowest or highest value, but it doesnt
> matter here.
>
> The goal is to somehow calculate this specific hands unique patter in
> the range of 0-1325.

[snip]

We have two distinct numbers, by the mapping above, between
0 and 51. Obviously one is bigger than the other, say m > n.

If n < 25, let m + n*52 represent the pair.

If n >= 25, let (51-m) + (50-n)*52 represent the pair.

It should be clear that the smallest value represented
here is 0 (from m = 51, n = 50). The largest value is
for n = 25 so that the coefficient of 52 is maximized,
and m = 26:

(51-26) + (50-25)*52 = 25 + 25*52 = 1325

The range of representations is 0 to 1325, as desired.

Such a formulation can be extended, albeit awkwardly,
to higher dimensions/larger card hands.

regards, chip

zaca...@gmail.com

unread,
Sep 12, 2007, 1:45:09 AM9/12/07
to
On 12 Sep., 07:25, Chip Eastham <hardm...@gmail.com> wrote:
> On Sep 11, 6:18 pm, zacar...@gmail.com wrote:
>
> > 1. Im sorry if i have posted in the wrong group.
> > 2. English is not my native language and if i have trouble explaining
> > my self im sorry for that too.
> > 3. This is NOT homework. I have gotten that message alot and its
> > simply enoying!
>
> > It has to do with cards. A deck of cards has 52 cards and a single
> > card can have 4 different suits and 13 different values.
> > I drawing two cards, obiously they cant be exactly simular. Also im
> > ignoring the order of the cards im drawing.
> > e.g.
> > 52*51 / 2! = 1326 different hands
>
> Okay, we need to map all possible pairs of cards
> to a number between 0 and 1325.
>
> > A single card can be looked upon like this:
> > {Suit, Value}
> > fx.
> > NB! im using ranges starting from zero fx. 0-3 instead of 1-4.
>
> > {3,12} & {3,11}
>
> The mapping from (Suit,Value) to a number between 0 and 51 is
> Suit + Value*4 (assuming Suit is 0 to 3 & Value is 0 to 13).
this is actually very usefull. Simple as it may be i just could find
the solution.

>
> > This hand would equal Ace King or Queen King in the same suit,
> > dependent on Ace being assigned lowest or highest value, but it doesnt
> > matter here.
>
> > The goal is to somehow calculate this specific hands unique patter in
> > the range of 0-1325.
>
> [snip]
>
> We have two distinct numbers, by the mapping above, between
> 0 and 51. Obviously one is bigger than the other, say m > n.
>
> If n < 25, let m + n*52 represent the pair.
>
> If n >= 25, let (51-m) + (50-n)*52 represent the pair.
>
generel i dont like conditional statements in a formula, but as it is
to be used in a computer program anyway, it doesnt matter much.

> It should be clear that the smallest value represented
> here is 0 (from m = 51, n = 50). The largest value is
> for n = 25 so that the coefficient of 52 is maximized,
> and m = 26:
>
> (51-26) + (50-25)*52 = 25 + 25*52 = 1325
>
> The range of representations is 0 to 1325, as desired.
>
> Such a formulation can be extended, albeit awkwardly,
> to higher dimensions/larger card hands.
>
This may be usefull as it is somewhat simpler than what matt
suggested, but i need to think it over.
> regards, chip

thanks

Peter Webb

unread,
Sep 12, 2007, 12:22:17 PM9/12/07
to

<zaca...@gmail.com> wrote in message
news:1189549098.4...@r34g2000hsd.googlegroups.com...

Do you want an ordering of them which knows about the rules of poker? So
four example a pair of two's is higher than a King and Jack of different
suits?

If so, you are going to have to do this the hard way.

Find all the straight flushes (there are 48 of them), and number them from
1325 down.
From the remaining combinations, find all the straights, and number them
from 1277 down
From all the remaining combinations, find all the straights and number them
down
From the remaining combinations, find all the pairs and number them down
With the remaining combinations (of two unrelated cards), number them down
(to zero, hopefully).

Alternatively, you could bubble sort a list of all 1326 combinations using
the rules of poker to decide which of the two pairs is higher.


Michael Stemper

unread,
Sep 12, 2007, 1:07:45 PM9/12/07
to
In article <1189549098.4...@r34g2000hsd.googlegroups.com>, zacariaz writes:

>It has to do with cards. A deck of cards has 52 cards and a single
>card can have 4 different suits and 13 different values.

>A single card can be looked upon like this:
>{Suit, Value}

So far you're okay. Every card will be represented by a unique set.

>NB! im using ranges starting from zero fx. 0-3 instead of 1-4.

Right here, though, by mapping suits and values to numbers, you've
caused yourself a problem. (Technically, it's because you've chosen
overlapping ranges of integers.)

Since there's no difference between the set {2,3} and the set {3,2},
you have a bit of a problem with this representation. I'd suggest
that, if you need to map suits and values to integers, you should
use ordered pairs rather than sets.

--
Michael F. Stemper
#include <Standard_Disclaimer>
Outside of a dog, a book is man's best friend.
Inside of a dog, it's too dark to read.

matt271...@yahoo.co.uk

unread,
Sep 12, 2007, 1:38:27 PM9/12/07
to

As an afterthought... the formula I referred you to from the other
thread was constructed specifically so as to number the combinations
(in your case hands) in ascending order. I kind of forgot that wasn't
necessarily a requirement for you. If that requirement is dropped I
think the formula can be simplified to just

sum_j=1^k C(x(j) - 1, j)

with the all the symbols having the same meaning as before.

You get a unique number in the correct range for each hand but they
aren't ordered in any especially helpful way (kind of "reverse
reverse" order). Again this works for any k, not just k = 2.

0 new messages