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
pgp3e5SVRjwKK.pgp
Description: PGP signature
-- http://mail.python.org/mailman/listinfo/python-list