You are viewing a single comment's thread. Return to all comments →
Can you guy help me with my PHP code? I got timeout with this one.
<?php $handle = fopen ("php://stdin","r"); fscanf($handle,"%d %d %d",$n1,$n2,$n3); $h1_temp = fgets($handle); $h1 = explode(" ",$h1_temp); array_walk($h1,'intval'); $h2_temp = fgets($handle); $h2 = explode(" ",$h2_temp); array_walk($h2,'intval'); $h3_temp = fgets($handle); $h3 = explode(" ",$h3_temp); array_walk($h3,'intval'); // My code start here $sum = array(array_sum($h1), array_sum($h2), array_sum($h3)); $arr = array($h1, $h2, $h3); while( $sum[0] !== $sum[1] || $sum[0] !== $sum[2]){ $max = array_search(max($sum),$sum); $sum[$max] -= array_shift($arr[$max]); } echo $sum[0]; ?>
Seems like cookies are disabled on this browser, please enable them to open this website
Equal Stacks
You are viewing a single comment's thread. Return to all comments →
Can you guy help me with my PHP code? I got timeout with this one.