top of page

Finding the largest product of 4 adjacent numbers in a Grid - Project Euler Problem 24

Sep 9

1 min read

0

5

0

ree

Given a grid 20 x 20 could you print the greatest product of 4 adjacent numbers.

This is precisely what Project Euler has tasked us with doing. This problem requires thinking about index boundaries, looping in a two-dimensional manner and conditionally updating variables.

ree

The first thing to do is to read the grid into a variable:


ree

Use the numpy array to format it as a grid:


ree

Loop through the grid in the four directions and print the result of the maximum product:


ree

There you have it, Project Euler Problem 24 broken down and simplified.


Sep 9

1 min read

0

5

0

Related Posts

Comments

Share Your ThoughtsBe the first to write a comment.
bottom of page