Project Euler Solutions by Ross Marks

<?php
/*****************************
 * ProjectEuler - Problem 18
 * By Ross Marks
 *****************************
 * By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23.
 * 
 * 3
 * 7 4
 * 2 4 6
 * 8 5 9 3
 * 
 * That is, 3 + 7 + 4 + 9 = 23.
 * 
 * Find the maximum total from top to bottom of the triangle below:
 * 
 * 75
 * 95 64
 * 17 47 82
 * 18 35 87 10
 * 20 04 82 47 65
 * 19 01 23 75 03 34
 * 88 02 77 73 07 63 67
 * 99 65 04 28 06 16 70 92
 * 41 41 26 56 83 40 80 70 33
 * 41 48 72 33 47 32 37 16 94 29
 * 53 71 44 65 25 43 91 52 97 51 14
 * 70 11 33 28 77 73 17 78 39 68 17 57
 * 91 71 52 38 17 14 91 43 58 50 27 29 48
 * 63 66 04 68 89 53 67 30 73 16 69 87 40 31
 * 04 62 98 27 23 09 70 98 73 93 38 53 60 04 23
 * 
 * NOTE: As there are only 16384 routes, it is possible to solve this problem by trying every route. However, Problem 67, is the same challenge with a triangle containing one-hundred rows; it cannot be solved by brute force, and requires a clever method! ;o)
 ****************************/

$t1[0] = array(3);
$t1[1] = array(74);
$t1[2] = array(246);
$t1[3] = array(8593);


$t1[0] = array(75);
$t1[1] = array(9564);
$t1[2] = array(174782);
$t1[3] = array(18358710);
$t1[4] = array(2004824765);
$t1[5] = array(190123750334);
$t1[6] = array(88027773076367);
$t1[7] = array(9965042806167092);
$t1[8] = array(414126568340807033);
$t1[9] = array(41487233473237169429);
$t1[10] = array(5371446525439152975114);
$t1[11] = array(701133287773177839681757);
$t1[12] = array(91715238171491435850272948);
$t1[13] = array(6366046889536730731669874031);
$t1[14] = array(046298272309709873933853600423);

for (
$y count($t1) - 1$y >= 0$y--) {
   for (
$x 0$x count($t1[$y]); $x++) {
      @
$t1[$y][$x] += max($t1[$y 1][$x], $t1[$y 1][$x 1]);
   }
}

echo 
"Awnser: ".$t1[0][0];

/**
For each ELEMENT in particular ROW and COLUMN{
  If ( ELEMENT is FIRST ELEMENT  of ROW){
    MAX_SUM[ROW][COLUMN] = ELEMENT + FIRST element of (ROW-1)
  }
  Else If (ELEMENT is LAST ELEMENT of ROW){
    MAX_SUM[ROW][COLUMN] = ELEMENT + LAST element of (ROW-1)
  }Else{
    MAX_SUM[ROW][COLUMN] = ELEMENT + maximum( element at [ROW-1][COLUMN-1], element at [ROW-1][COLUMN])
  //recursive formula calculating max_sum at each point from all possible paths till that point
  }
}

start at 1 above bottom going up, work out best from above 2 and add to self
keep going up, top will be high-score
*/
?>