Ludvig Learns Python

Ludvig Learns Python is about me, Ludvig, who got interested in Python programming after being introduced to Quantopian (algorithm trading) which is built on Python programming. The scope of this blog is to document my learning process and see if it becomes more effective when I need to explain what I'm doing instead of just clicking around.

Showing posts with label problem 18. Show all posts
Showing posts with label problem 18. Show all posts

2017-06-21

Project Euler Problem 18

with open('pe18.txt', 'r') as file:
    numbers = [[int(num) for num in line.split()] for line in file]

numbersRev = reversed(numbers)


for line in numbersRev:
    for item in range(0, len(line)):
        if item < len(line) - 1:
            a = line[item]
            b = line[item + 1]
            c = max(a, b)
            numbers[numbers.index(line) - 1][item] += c

print(numbers[0][0])
Posted by L at 00:33 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Labels: problem 18, project euler
Older Posts Home
Subscribe to: Posts (Atom)

Blog Archive

  • ▼  2017 (30)
    • ▼  June (25)
      • Stock Screener Update 1
      • Stock Screener Programming 2
      • Stock Screener Programming 1
      • Stock Screener from PDF Data Sheet
      • Project Euler Problem 67
      • Project Euler Problem 18
      • Project Euler Problem 17
      • Project Euler Problem 16
      • Project Euler Problem 15
      • Project Euler Problem 14
      • Project Euler Problem 13
      • Project Euler Problem 12
      • Project Euler Problem 11
      • Project Euler Problem 10
      • Project Euler Problem 9
      • Project Euler Problem 8
      • Project Euler Problem 7
      • Project Euler Problem 6
      • Project Euler Problem 5
      • Project Euler Problem 4
      • Project Euler Problem 3
      • Project Euler Problem 2
      • Project Euler Problem 1
      • More Configuration and Project Euler
      • Hello World
    • ►  May (5)
Awesome Inc. theme. Powered by Blogger.