PDA

View Full Version : Blocks contest (challenge #101 from http://acm.uva.es/problemset)


ChefNinja
07-23-2003, 07:53 AM
Here's my solution:

robotarm.py (http://home.comcast.net/~kevinherron/python/robotarm.py)

Was fun :)

Strike
07-23-2003, 06:12 PM
Originally posted by ChefNinja
Here's my solution:

robotarm.py (http://home.comcast.net/~kevinherron/python/robotarm.py)

Was fun :)

Here's some commentary (without even running it, so take it with a grain of salt, this is more style and/or simplifications).


self.blocks = [[0], [1], [2], [3], [4], [5], [6], [7], [8], [9]]


can be:


self.blocks = [[x] for x in range(10)]



ax = self.FindBlock(a)[0]
ay = self.FindBlock(a)[1]
bx = self.FindBlock(b)[0]
by = self.FindBlock(b)[1]


can be:


(ax, ay) = self.FindBlock(a)
(bx, by) = self.FindBlock(b)


(in many places)

Other than that, your patterns look pretty good. Haven't had time to look at the problem and your actual process/algorithms though.

ChefNinja
07-24-2003, 03:18 AM
thanks for the reply :)

i took your suggestions and modified the code, but haven't had a chance to re-upload it.