Sunday, August 15, 2010

SIZECON

This is a challenge task in spoj. Link to the problem SIZECON
The best i could manage is 48 in python. Here's the source code:


q=0
w=input()
while w:
w-=1
a=input()
if a>0:q+=a
print q

if anyone has done better please share your approach :)

3 comments:

  1. Use exec. ;-)
    And if You want more shortening tasks, visit:
    http://www.spoj.pl/SHORTEN

    ReplyDelete
  2. thanks, i think i can use that to reduce some more of my constructions,
    are there other reductions also to print and scan input in python ?

    ReplyDelete
  3. c=0
    i=input
    exec('b=i();c+=b*(b>0);'*i())
    print c

    ReplyDelete