Skip to content

Instantly share code, notes, and snippets.

@eroltutumlu
Created February 8, 2015 12:06
Show Gist options
  • Select an option

  • Save eroltutumlu/8172f85b0fb542d90a81 to your computer and use it in GitHub Desktop.

Select an option

Save eroltutumlu/8172f85b0fb542d90a81 to your computer and use it in GitHub Desktop.
Lattice paths // Project Euler 15
#include <stdio.h>
#define SIZE 20
//http://www.robertdickau.com/lattices.html must be known for solution.
int main(void) {
int i,j;
long long int grid[SIZE+1][SIZE+1];
long long sum = 0;
for(i=0;i<SIZE;i++)
{
grid[i][SIZE] = 1;
grid[SIZE][i] = 1;
}
for(i=SIZE-1;i>=0;i--)
{
for(j=SIZE-1;j>=0;j--)
{
grid[i][j] =grid[i+1][j]+grid[i][j+1];
sum = grid[i][j];
}
}
printf("%lld",sum);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment