6 kyu

Product of Adjacent Grid Numbers

81 of 120ThomasL

Description:

A grid of numbers with an equal height and width is given and your task is to find the largest possible product between four adjacent numbers in the same direction. The directions can be horizontal, vertical or diagonal.

Some example grids are shown below.

04 04 04 04 01 01  |  04*04*04*04 = 256
01 01 01 01 01 01  |
01 01 01 01 01 01  |
01 01 01 01 01 01  |
01 01 01 01 01 01  |
01 01 01 01 01 01  |

01 01 01 01 01 04  |  04*04*04*04 = 256
01 01 01 01 01 04  |
01 01 01 01 01 04  |
01 01 01 01 01 04  |
01 01 01 01 01 01  |
01 01 01 01 01 01  |

04 01 01 01 01 01  |  04*04*04*04 = 256
01 04 01 01 01 01  |
01 01 04 01 01 01  |
01 01 01 04 01 01  |
01 01 01 01 01 01  |
01 01 01 01 01 01  |

01 01 01 04 01 01  |  04*04*04*04 = 256
01 01 04 01 01 01  |
01 04 01 01 01 01  |
04 01 01 01 01 01  |
01 01 01 01 01 01  |
01 01 01 01 01 01  |

The smallest grid that can be given is 4x4 and the contained numbers will have a minimum value of 1 and a maximum value of 99.

A solution should be created to test all combinations of vertical, horizontal and diagonal lines.

Adapted from Project Euler.

Algorithms

More By Author:

Check out these other kata created by ThomasL

Stats:

CreatedOct 18, 2016
PublishedOct 18, 2016
Warriors Trained451
Total Skips63
Total Code Submissions1608
Total Times Completed120
JavaScript Completions81
PHP Completions43
Total Stars17
% of votes with a positive feedback rating90% of 41
Total "Very Satisfied" Votes35
Total "Somewhat Satisfied" Votes4
Total "Not Satisfied" Votes2
Total Rank Assessments8
Average Assessed Rank
6 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • ThomasL Avatar
  • ryancastle Avatar
  • Voile Avatar
  • hobovsky Avatar
Ad