Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8397439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:47:28+00:00 2026-06-09T20:47:28+00:00

I solved Project Euler’s Problem 67 a few months back with a wildly inefficient

  • 0

I solved Project Euler’s Problem 67 a few months back with a wildly inefficient algorithm. Today, I realized how this could have been done better, and while trying to make a more efficient algorithm, I ran into some problems.

The code is this:

r_prev = [59,0,0]
r_load = [73,41,0]
r = [0,0,0]
zero_r = [0,0,0]
rows = 3
while rows != 0:
    position = 0
    for x in r_load:
        try:
            if r_prev[position] > r_prev[position-1]:
                r[position] = r_prev[position] + r_load[position]
            else:
                r[position] = r_prev[position-1] + r_load[position]
        except IndexError:
            r[position] = r_prev[position] + r_load[position]
        position += 1
    print r
    rows -= 1
    r_load = input("Enter next row")
    r_prev = r
    r_prev.append(0)
    zero_r.append(0)
    r = zero_r

It works by keeping only the sum of the highest path to get to a point. I am feeding it input manually at this point (via the console). When fed the first line, it performs as expect, but when fed the second line, it considers r_prev and r as the same thing, and every operation that is performed on r_prev is also performed on r.

How do I solve this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:47:30+00:00Added an answer on June 9, 2026 at 8:47 pm

    When you do r_prev = r you are not copying the list. You are giving the same list an additional name. To make a copy, do r_prev = list(r).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have solved the project Euler problem 16 but discovered this rather novel approach
I solved Problem 10 of Project Euler with the following code, which works through
I just solved the first problem from Project Euler in JavaFX for the fun
As some of you may notice this question is problem 16 from Project Euler
I am attempting to make an algorithm to solve Project Euler Problem 255 I
I solved a problem on Project Euler but it took about 4 minutes to
I'm currently working on project euler problem 14 . I solved it using a
I decided to try project euler problem 17 today, and I quickly wrote a
Beginner Haskell learner here. I've solved Project Euler Problem 1, sum of multiples of
NOTE: This is a solution for Project Euler Problem 14 . If you still

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.