Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- $data = file_get_contents("triangle.txt",TRUE);
- $rows = explode("\n", $data); //create array separate by new line
- $position = 0;
- for ($i=0; $i<count($rows); $i++)
- {
- $each = explode(' ', $rows[$i]);
- //determine the position of max value
- if ($each[$position] < $each[$position+1]){
- $position++;
- }
- //and put it together
- $summ = $summ + $each[$position];
- }
- echo $summ."@yodle.com";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment