Minimum length of the shortest path of a triangle | function to get the minimum length of the shorter side of the triangle ; traversing through each points on the plane ; if sum of a points is greater than the previous one , the maximum gets replaced ; print the length ; initialize the number of points ; points on the plane
< ? php function shortestLength ( $ n , & $ x , & $ y ) { $ answer = 0 ; $ i = 0 ; while ( $ n -- ) { if ( $ x [ $ i ] + $ y [ $ i ] > $ answer ) $ answer = $ x [ $ i ] + $ y [ $ i ] ; $ i ++ ; } echo " Length ▁ - > ▁ " . $ answer . " STRNEWLINE " ; echo " Path ▁ - > ▁ " . " ( 1 , " ▁ . $ answer ▁ . " ) " . STRNEWLINE TABSYMBOL TABSYMBOL " and ( " ▁ . $ answer ▁ . ▁ " , 1 ) " ; } $ n = 4 ; $ x = array ( 1 , 4 , 2 , 1 ) ; $ y = array ( 4 , 1 , 1 , 2 ) ; shortestLength ( $ n , $ x , $ y ) ; ? >