top of page

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

Sep 9, 2025

1 min read

0

6

0


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.


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



Use the numpy array to format it as a grid:



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



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


Sep 9, 2025

1 min read

0

6

0

Related Posts

Comments

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