List of integers & L.I.S. (SPOILER)

Bryan Olson fakeaddress at nowhere.org
Fri Sep 9 13:29:29 EDT 2005


n00m wrote:
 > Oh!
 > Seems you misunderstand me!
 > See how the last block in your code should look:
 >
 > for tc in range(10):
 >     _ = stdin.readline()
 >     sequence = [int(ch) for ch in stdin.readline().split()]
 >     supers = supernumbers(sequence)
 >     print len(supers)
 >     for i in supers:
 >          print i,

Ah, I misunderstood the input. I thought they'd run it once for
each of their test cases. Handling exactly ten inputs sucks, so
how about:

while True:
     if not stdin.readline().strip():
         break
     sequence = [int(ch) for ch in stdin.readline().split()]
     supers = supernumbers(sequence)
     print len(supers)
     for i in supers:
         print i,
     print


-- 
--Bryan



More information about the Python-list mailing list