Largest Product in a Grid — Project Euler (Problem 11)

I started solving Project Euler problems this month. Check out the Project Euler tab of this blog for a list of the problems I’ve solved (with solutions) till date. Here’s a problem you might find interesting:

ProjectEuler11

Here’s my solution using Python (I basically search through the entire matrix which is of O() complexity):

I first copy the maxtrix into a text file euler11.txt so that it can be later read into Python

I then execute the following code from the same working directory as euler11.txt

Answer: 70600674

Advertisements

One thought on “Largest Product in a Grid — Project Euler (Problem 11)

  1. This is a little bit late, but I just found this and think the loop sequence is very clean, but I was wondering why you wouldn’t substitute all your top lines for this:
    problemMatrix = np.loadtxt(“euler11.txt”)

    Is there some benefit to your method?
    Really like the blog btw

    Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s