This is the problem I am trying to solve: https://projecteuler.net/problem=15
I thought iteration would be the best choice and this is my function:
function [ ] = lattice( N, E )
global count n e
if N ~= n && E ~= e
elseif N ~= n
elseif E ~= e
count = count + 1;
So I start the function with lattice(0,0) and it returns the correct amount of possible ways in a 2x2 grid (n=2 and e=2) and it is fast but it quickly gets too slow for bigger n and e.
As far as I can imagine I am not counting any paths more than once so I am not sure why it is so slow. Any ideas on how I can improve this code?