Sorting dominoes
jepler at unpythonic.net
jepler at unpythonic.net
Sun Nov 13 22:02:57 EST 2005
So if you have the dominoes (1 2), (3 2) and (3 1) you must arrange them as
1|2|3
2|3|1
? If so, then it seems to me your algorithm is this:
1. pick an arbitrary domino to be first, and an arbitrary side to be the "top"
2a. until the dominoes are exhausted, pick the other domino with the same digit
as the "bottom" of the last domino picked, and put that digit on the top.
2b. If there is no domino with the same digit, then pick an arbitrary domino as
in step 1
Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20051113/88e8b96d/attachment.sig>
More information about the Python-list
mailing list