On Aug 12, 2010, at 10:51 PM, John Posner wrote:
On 8/12/2010 9:22 AM, Dave Angel wrote:
Now you have to find the largest number below 120, which you can
easily do with brute force
tgt = 120 # thanks, Dave Angel
Anytime, but I'm not Dave Angel.
My previous algorithm was more efficient, but for those who like one-
liners:
[x for x in range(120) if any(20*a+9*b+6*c == x for a in range(x/20)
for b in range(x/9) for c in range(x/6))][-1]
Cheers, Roald
--
http://mail.python.org/mailman/listinfo/python-list