[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] Deck of cards



Here is a problem that my son was asked to solve.
He quickly solved it using paper and pencil and I asked
if he could write a program that would solve it using
any number of cards. 

You are given N number of cards.
You are to order the cards in such a way that when you
deal the cards according to the RULES all of the cards
on the table are in sequel order.

The RULES:
	Take the top card and place it face up on the table.
	Take the next card from the top of the deck and place it
	on the bottom of the deck.
	Deal the next card face up and place it on the table next to the first.
	Take the next card from the top of the deck and place it
	on the bottom of the deck.
	Repeat this until there are no more cards to deal.
 
Before I give his solution I thought this group would like to have
a chance to have as much fun as we did in solving it.
 
-- 
Tim Allwine
IX Development Laboratories

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe