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 7833329
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:39:35+00:00 2026-06-02T12:39:35+00:00

I am trying to solve project euler problem 18 . http://projecteuler.net/problem=18 I tried a

  • 0

I am trying to solve project euler problem 18.
http://projecteuler.net/problem=18
I tried a greedy algorithm with python working from the bottom of the triangle.
THen I move up one row and find the biggest route with a greedy algorithm and try to connect the biggest route but it doesn’t work. DO you have any hints that would put me on the right track without giving the solution of the problem away.

here is the function:

def greedy(i):
    if i%15==0:
        a=[(b[i-15],i-15),(b[i-14],i-14)]
        a=sorted(a)
        a=a[-1]
    else:
        a=[(b[i-15],i-15),(b[i-16],i-16),(b[i-14],i-14)]
        a=sorted(a)
        a=a[-1]
    return a

Cheers

  • 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-02T12:39:36+00:00Added an answer on June 2, 2026 at 12:39 pm

    Have you ever heard of Dynamic Programming?

    Consider this problem. What makes a route the best? Is there any relation between the last step and the previous ones? Also, look at this triangle where the greedy algorithm doesn’t give you the right answer:

          1
        2   3
      9   1   2
    1   1   2   4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to solve Project Euler #9, which is http://projecteuler.net/index.php?section=problems&id=9 . I've looked through
I was trying to solve Project Euler problem 10 using python, but my program
I'm trying to solve Problem 13 of project euler, which involves the sum of
I am trying to solve Project Euler Problem 88 , and I did it
I'm trying to solve Project Euler Problem 14 in a lazy way. Unfortunately, I
I have been trying to solve Project Euler's problem #59 for a while, and
I'm trying to solve problem 50 on Project Euler . Don't give me the
I'm trying to solve Problem #5 in Project Euler. The code works for the
I'm trying to solve problem 14 on project euler, and my initial brute force
I am trying to solve Project Euler problem #12: The sequence of triangle numbers

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.