Tuples

Rob W. W. Hooft rob at hooft.net
Fri Feb 11 08:50:56 EST 2000


>>>>> "RG" == Remco Gerlich <scarblac-spamtrap at pino.selwerd.nl> writes:

 RG> I was making some functions for a chess program earlier. For a
 RG> few minutes, the idea was to represent the board by a 64-tuple.

 RG> But that's not very smart, is it?

 RG> Given 64-tuple x, is there an easy way to get the tuple with
 RG> values x[6] and x[21] swapped, for instance?

Python 1.5.2b1 (#9, Apr  9 1999, 16:51:07)  [GCC 2.7.2.3] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> T=tuple(range(64))
>>> T=T[:6]+T[21:22]+T[7:21]+T[6:7]+T[22:]
>>> T
(0, 1, 2, 3, 4, 5, 21, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 6, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63)

Regards,
-- 
=====   rob at hooft.net          http://www.xs4all.nl/~hooft/rob/  =====
=====   R&D, Nonius BV, Delft  http://www.nonius.nl/             =====
===== PGPid 0xFA19277D ========================== Use Linux! =========



More information about the Python-list mailing list