Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string filename = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\input.txt";
- int[,] inputTriangle = readInput(filename);
- int posSolutions = (int)Math.Pow(2, inputTriangle.GetLength(0) - 1);
- int largestSum = 0;
- int tempSum, index;
- for (int i = 0; i <= posSolutions; i++) {
- tempSum = inputTriangle[0, 0];
- index = 0;
- for (int j = 0; j < inputTriangle.GetLength(0) - 1; j++) { index = index + (i >> j & 1);
- tempSum += inputTriangle[j + 1, index];
- }
- if (tempSum > largestSum) {
- largestSum = tempSum;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement