Daily Problem
Today I solved the 11th problem at ProjectEuler https://projecteuler.net/problem=11
I thought it would go fast yet it did not and in the end I had to push it to finish it.
They gave you a grid and ask you to find the largest product of 4 adjacent numbers in it. These types of problems (grid iteration) is tedious to me because it is just index handling.
I choose to do it in python and use numpy library. I brute-forced my way through it. Essentially, do the horizonal, vertical and diagonal separately.
Reason it took long was this process, prepare the string (python does not like leading zeros so I had to remove them), then iterate the matrix and do slicing (had to learn it too).
I managed to solve it using this monstrosity of a code, but hey it works :D
Comments
Post a Comment