Return to Snippet

Revision: 27077
at May 21, 2010 10:43 by chroto


Initial Code
#!/usr/bin/python

# Project Euler - Problem 13
print "\nProject Euler - Problem 13"
print "Find the first ten digits of the sum"
print "of a set of one-hundred 50-digit numbers."

# Read in first 50-digit number

f = open('problem13.num', 'r')

x = [None]*50
p = [None]*100
sum = 0

for n in range(0,100):
    for i in range(0,50):
        x[i] = (f.read(1))
        if (x[i] == '\n'):
            x[i] = f.read(1)
    s = ''.join(map(str, x))
    sum += int(s)
print sum

Initial URL


Initial Description


Initial Title
Project Euler - Problem 13

Initial Tags


Initial Language
Python