jones wrote:I have the idea written with words but I really don't know how to put it in code.
I'll show you on a simple example how it should be solved (it is similar to Kadane's 2D algorithm), I just need to put it into code but I don't have the idea how to (time complexity should be 0(n^3)).
Hey jones, you should definitely check out some tutorials about python programming (there's a couple in the tutorial section) . It wouldn't help you at all if we wrote the code that solved this and as setrofim told you "We will not do your homework for you".
The users here are really helpful when they see that you put some effort to code the solution (doesn't matter if it's ugly). So, try your best to translate what your idea is to python code.
Ubuntu 13.04, Archlinux and Windows 7.