I would just reserve 13 places for cards on a table and drop each card
in its place by face value - done.
Now, what about shuffling a deck of cards. How about a means of randomizing
52 cards quickly?
The shuffled deck is in DECK, SHUFFLE is a string with the shuffle
Spades = 1:13
Clubs = 14:26
Diamonds=27:39
Hearts = 40:52
K DECK
F I=1:1:52 F S V=$R(1000000) I '$D(DECK(V)) S DECK(V)=I Q
S SHUFFLE="",I=""
F S I=$O(DECK(I)) Q:I="" S SHUFFLE=SHUFFLE_DECK(I)_":"
; Now to sort the shuffle
S (SORT,I)=""
F I=1:1:$L(SHUFFLE,":") S V=$P(SHUFFLE,":",I),$P(SORT,":",V)=V
; Big deal, SORT="1:2:3:4:5:6:7:8...51:52", but look at SHUFFLE
; Your actual values will vary widely for SHUFFLE
QUIT
; ===============
Do you have to hold them in your hand? If we are using a computer
analagy, then I think we should have to. I know that sorting is a fine
art among Mumps programmers ;-)
Actually, the only sort I can remember is the bubble-sort method (slow
and ineffecient)
Kevin
I would just reserve 13 places for cards on a table and drop each card
in its place by face value - done.
Is there an explicite order of suits? Are all Clubs bigger than Spades,
which are smaller than Diamonds, and Diamonds are smaller than Hearts? Are
Aces high or low? Then 13 slots won't do.
Now, what about shuffling a deck of cards. How about a means of randomizing
52 cards quickly?
The shuffled deck is in DECK, SHUFFLE is a string with the shuffle
Spades = 1:13
Clubs = 14:26
Diamonds=27:39
Hearts = 40:52
K DECK
F I=1:1:52 F S V=$R(1000000) I '$D(DECK(V)) S DECK(V)=I Q
S SHUFFLE="",I=""
F S I=$O(DECK(I)) Q:I="" S SHUFFLE=SHUFFLE_DECK(I)_":"
; Now to sort the shuffle
S (SORT,I)=""
F I=1:1:$L(SHUFFLE,":") S V=$P(SHUFFLE,":",I),$P(SORT,":",V)=V
; Big deal, SORT="1:2:3:4:5:6:7:8...51:52", but look at SHUFFLE
; Your actual values will vary widely for SHUFFLE
QUIT
; ===============
Do you have to hold them in your hand? If we are using a computer
analagy, then I think we should have to.
I know that sorting is a fine
art among Mumps programmers ;-)
Actually, the only sort I can remember is the bubble-sort method (slow
and ineffecient)
Kevin
kdt...@gmail.com wrote, on 10/20/2006 07:56 AM:
[KSB] <...snip...>
> Do you have to hold them in your hand? If we are using a computer
> analagy, then I think we should have to. I know that sorting is a fine
> art among Mumps programmers ;-)
[KSB] Sorting should not be an art among MUMPS programmers because the
MUMPS implementation keeps variables sorted at all times.
Regards
-- Bhaskar
Actually, the only sort I can remember is the bubble-sort method (slow
and ineffecient)
[KSB] Sorting should not be an art among MUMPS programmers because the
MUMPS implementation keeps variables sorted at all times.
If this is a trick question then I have an answer, simply purchase a deck of cards, pull them out of their container and presto, a completely sorted deck.
On the other hand, if this is not a trick question, I would have to say that patience sorting would be the key here.
From: Hard...@googlegroups.com [mailto:Hard...@googlegroups.com] On Behalf Of Gregory Woodhouse
Sent: Friday, October 20, 2006
8:42 AM
To: Hard...@googlegroups.com
Subject: [Hardhats] Re: Sorting
cards
On Oct 20, 2006, at 5:18 AM, K.S. Bhaskar wrote:
On the other hand, if this is not a trick question, I would have to say that patience sorting would be the key here.
Suffice it to say that by playing a game of solitaire you are effectively employing patience sorting.
Technically it is a non-recursive analog of the Robinson-Schensted-Knuth algorithm.
From: Hard...@googlegroups.com [mailto:Hard...@googlegroups.com] On Behalf Of Gregory Woodhouse
Sent: Friday, October 20, 2006
9:09 AM
To: Hard...@googlegroups.com
Subject: [Hardhats] Re: Sorting
cards
On Oct 20, 2006, at 6:04 AM, Gaber, Roy G. wrote:
tjh
_____
From: Hard...@googlegroups.com [mailto:Hard...@googlegroups.com] On
Behalf Of Gregory Woodhouse
Sent: Friday, October 20, 2006 8:01 AM
To: Hard...@googlegroups.com
Subject: [Hardhats] Re: Sorting cards
On Oct 19, 2006, at 9:59 PM, Jim Self wrote:
I would just reserve 13 places for cards on a table and drop
each card
in its place by face value - done.
Interesting. That's not quite the answer I had expected. Anyone else?
Gregory Woodhouse
gregory....@sbcglobal.net
"Mathematics is the science of patterns."
--Lynn Arthur Steen, 1988
--
Nancy Anthracite
What Jim was describing with his 13 piles was a prescribed bucket sort. He
know the kinds of cards he was going to come in contact with and have
predefined the domain that he was going to project the "population to be
sorted" into. Fine. But what would happen if he got a hold of a tarot deck
instead of a standard deck of Bicycle Cards (or whatever). Ok, the 15 of
swords, now where would that go?, the 17 of Goblets, the Joker, you get the
idea.
Now suppose there was a bucket sort that you did not have to pre-allocate.
We start with no buckets. We sample the population we wish to sort and get
a 20 of castles. OK, now we have a challenge, we can sort the cards on
their value or their suit, or both (but which one is primary) (this is why
we will still need people to make these decisions as to what is more useful
to our purpose). For this purpose, we will sort these on the value/suite
combination. So we pull out a nice new bucket and slap a label on it that
says 20 of Castles. This might be a Tarot Pinocle deck so we may find more
of these as time goes on. In that this is the first bucket, we can pretty
much put it anywhere. All subsequent additions will be either before or
after this bucket. We then get a 2 of wands and create another bucket and
put this one in front of the first bucket. Now we get the 5 of swords. Where
do we put this? Are we sorting them by the value of the card
[(2,"Wands"),(5,"Swords"), (20,"Castles")] or the character order, ("2 of
Wands", "20 of Castles", "5 of swords", judging from the first character to
the second character, and so on). Once we have made this decision, it gets
pretty simple to continue the sorting process, adding new buckets into their
proper slot and then putting duplicates into their already assigned buckets.
When the population of cards has been exhausted, and all members are
consigned to their buckets, the sort is over. One need only to walk down
this long line of buckets and tally up the members found in each bucket
however that population is to be reported. MUMPS works much this same way.
Once the population has been sampled, sorting is complete. MUMPS means that
you never have to say you are sorting.
===
Gregory Woodhouse
--
Nancy Anthracite
----- Original Message ----
From: Chris Richardson <r...@rcresearch.us>
To: Hard...@googlegroups.com
Sent: Friday, October 20, 2006 8:31:54 AM
Subject: [Hardhats] Re: Sorting cards
Yes, patience sorting is real and is probably, in my opinion, the easiest way of sorting the cards given a human is doing the sorting.
From: Hard...@googlegroups.com [mailto:Hard...@googlegroups.com] On Behalf Of gregory....@sbcglobal.net
Sent: Friday, October 20, 2006
11:19 AM
To: Hard...@googlegroups.com
Subject: [Hardhats] Re: Sorting
cards
----- Original Message ----
From: Nancy Anthracite <nanth...@verizon.net>
To: Hard...@googlegroups.com
Sent: Friday, October 20, 2006 8:38:14 AM
Subject: [Hardhats] Re: Sorting cards
Was that English?
The bucket sort is a real tool which is very driven by the data that it
encounters. When implemented in other computer languages, it is sensitive
to granularity and range and requires some absolute knowledge about the
environment that the model will run in. The way MUMPS applies this model is
much more human intuitive than the mechanistic method that most languages
use to handle the problem.
When you get done with MUMPS, you only have as many buckets as you have
species from the population to fill them. Suppose you have a smaller deck
of cards. Not all suits and not all numbers are represented in the
population you are dealing with. In another language, you would have to
still prepare for all possible species of card that you are likely to
encounter. In MUMPS, you would only have as many buckets as the number of
species that you encountered and no more. That in itself is valuable and
tells you a lot more about the population by just listing the buckets that
were created. A search for empty buckets needs to be done in other
languages. Ain't sparse matricies fun?
What are you two talking about?
----- Original Message -----
From: <gregory....@sbcglobal.net>
Permutations without long decreasing subsequences and random matrices
Authors: Piotr Sniady
Comments: 7 pages
Subj-class: Combinatorics; Probability
MSC-class: 05E10, 15A52, 60J65
We study the shape of the Young diagram \lambda associated via the
Robinson-Schensted-Knuth algorithm to a random permutation in S_n such that
the length of the longest decreasing subsequence is not bigger than a fixed
number d; in other words we study the restriction of the Plancherel measure
to Young diagrams with at most d rows. We prove that in the limit n\to\infty
the rows of \lambda behave like the eigenvalues of a certain random matrix
(traceless Gaussian Unitary Ensemble) with d rows and columns. In
particular, the length of the longest increasing subsequence of such a
random permutation behaves asymptotically like the largest eigenvalue of the
corresponding random matrix.
===
Gregory Woodhouse
--
Nancy Anthracite
Is there a different implied order in some other game? Hearts and Spades??
It has been a long time.
The last card game I learned was "Hands and Feet" or was it "Hand and Foot".
That was fun, but it takes a lot of decks of cards.
----- Original Message -----
From: "Mike Schrom" <mikes...@nycap.rr.com>
To: <Hard...@googlegroups.com>
OK, I guess you really want to know how I would do it as a human, with
not tricks.
I would fan out the cards as best I could, then start putting the low
numbers towards the start of the deck and the high numbers at the end
of the deck, trying to put them into rough numerical order. Then, as I
got the deck closer to being in order, I would fine tune the sort.
Kevin
I just alphabetized the consent forms on the 40 flu shots I gave this
afternoon. I made sorted groups of 10 because they were easy to hold, then I
picked them up in the correct order from the tops of the piles I made.
Cards I might separate the suits into 4 piles, then sort the 4 suits
individually while holding them fanned in my hand, then stack the piles.
Kevin
--
Nancy Anthracite
----- Original Message ----
From: Maury Pepper <mpe...@ieee.org>
To: Hard...@googlegroups.com
Sent: Friday, October 20, 2006 2:15:33 PM
Subject: [Hardhats] Re: Sorting cards
The original problem did not mention suit order. If it did, I would have
put the cards on the table in 4 rows by suit.
When I did have occasion to sort cards as a child many years ago, it was
generally to prove that we had a full deck or to separate a stack of 4
or more (possibly incomplete) decks into as many complete and undamaged
decks as possible as quickly as possible so that a dozen or more people
of various levels of maturity could play card games at the same time.
The solution was generally highly parallel with 3 or more people
grabbing a manageable handful of cards to toss into 13 or more stacks
by face value. Others would watch over the stacks to make sure that
cards landed in the right pile and they would start the process of
breaking them down into complete sets of 4 by card back and size.
Odd cards like the 15 of blueberries or the 20 of castles or the Jeckyl
of Hydes might be tossed in the first pass into one or more special
stacks and not sorted further.
Depending on the numbers and capabilities and interests of the card
players and the condition and prior groupings of the cards, we might
start by separating the cards into stacks by card back or size. Some
stacks, like the tarot cards that Chris mentioned, might be put aside at
that point.
The original problem did not mention suit order. If it did, I would have
put the cards on the table in 4 rows by suit.
When I did have occasion to sort cards as a child many years ago, it was
generally to prove that we had a full deck or to separate a stack of 4
or more (possibly incomplete) decks into as many complete and undamaged
decks as possible as quickly as possible so that a dozen or more people
of various levels of maturity could play card games at the same time.
The solution was generally highly parallel with 3 or more people
grabbing a manageable handful of cards to toss into 13 or more stacks
by face value. Others would watch over the stacks to make sure that
cards landed in the right pile and they would start the process of
breaking them down into complete sets of 4 by card back and size.
Odd cards like the 15 of blueberries or the 20 of castles or the Jeckyl
of Hydes might be tossed in the first pass into one or more special
stacks and not sorted further.
Depending on the numbers and capabilities and interests of the card
players and the condition and prior groupings of the cards, we might
start by separating the cards into stacks by card back or size. Some
stacks, like the tarot cards that Chris mentioned, might be put aside at
that point.
Thanks
Marc Aylesworth
RRC C3I Group
AFRL/IFSE
Systems and Information Interoperability Branch
525 Brooks Rd
Rome, NY 13441-4505
Tel:315.330.2422
Fax:315.330.7009
Email: Marc.Ay...@rl.af.mil
-----Original Message-----
From: Hard...@googlegroups.com [mailto:Hard...@googlegroups.com] On Behalf
Not a very scalable technique, but the fastest for a single deck of
cards, since it is easy to preassign a spot for each of 52 cards on a
kitchen table.
-- Bhaskar
That (13 piles) was just for brevity of description of the solution to
the original problem.
The actual process I was thinking of was two parts.
1) Separate the cards into stacks by value.
2) reassemble the deck by picking up the stacks in order.
Knowing that playing cards have 13 values means that you can preassign
the location of the stacks in numerical order, so the process can be a
little quicker, but the layout of the stacks can be random and sorting
doesn't have to occur until the final step.