viewing paste 21 | Python

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
c.
fil = ''
with open('d.in','r') as file:
    fil = file.read()
numbers = fil.split('\n')[1:]
goodN = []
 
for number in numbers:
    if number not in goodN:
        goodN.append(number)
ans_string = ''
for n in goodN:
    ans_string+= n + '\n'
open('d.out','w').write(ans_string)
 
a.
 
with open('matrix.in','r') as file:
    a = file.read().split('\n')[1:]
    for line in a:
        temp = 0
        for digit in line:
            temp += int(digit)
        open('matrix.out','a').write(str(temp)+'\n')
Viewed 138 times, submitted by denborg.