top of page

Problem 11

This is a C++ solution to Project Euler problem 11 found at: https://projecteuler.net/problem=11

My Algorithm

For this problem, we are asked to find the largest product of four adjacents numbers in the same direction in the large grid of numbers. To do this, we will scan the matrix into a 2-dimensional array. Then, using this array, we can loop through every index in the array and check if there exist a value three numbers away in any of the allowed directions. If any case is true, we will manually multiply the current number and the next three in whatever direction we are working in. For example, if we were at position (0, 0), we would check the right by multiplying the value at (0, 0) by the value at (0, 1), (0, 2), and (0, 3). If any of these products are greater than the current greatest product, we set it equal to the current greatest product. Using this algorithm results in the final answer of 70600674.

Full Solution on GitHub

© 2023 by Matthew Woodring

    bottom of page