On 8/12/2010 6:31 PM, News123 wrote:

     candidate_box_counts = product(
         xrange(target/box_sizes[0] + 1),
         xrange(target/box_sizes[1] + 1),
         xrange(target/box_sizes[2] + 1),
     )

Couldn't this be rewritten as:
     candidate_box_counts = product(
         * [ xrange(target/sizes + 1) for size in box_sizes ]
      )


Sure (except for the typo: "sizes" should be "size").

You could even use a generator expression instead of a list comprehension:

      candidate_box_counts = product(
         * ( xrange(target/size + 1) for size in box_sizes )
       )

-John
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to