fork download
  1. function step($paths, $pathDone, $point, $target, $time, $i, $pointNames, $transportName){
  2. var_dump($point);
  3. if ($i==0){echo "Начальная точка: $pointNames[$point]<br>";}
  4. $i++;
  5. $pathDone[$i] = $point;
  6. $pointStation = $paths[$point];
  7. foreach ($pointStation as $station => $times){
  8. $canGet[$station] = $times['time'];
  9. }
  10. asort($canGet);
  11. if (array_key_exists($target, $paths[$point]) == True){
  12. echo "В итоге ты попадешь в точку $pointNames[$target] за $time мин.<br>";
  13. echo "<br>Exit was found in " . count($pathDone)." steps!<br>";
  14. exit();
  15. } else {
  16. foreach ($canGet as $station => $times){
  17. if (in_array($station, $pathDone) != True ){
  18. $info = $pointStation[$station];
  19. $by = $info["by"];
  20. if ($i==1){echo "Из нее $transportName[$by] до точки $pointNames[$station]: $times мин.<br>";}
  21. $time += $times;
  22. $point = $station;
  23. step($paths, $pathDone, $point, $target, $time, $i, $pointNames, $transportName);
  24. echo "Из нее $transportName[$by] до точки $pointNames[$station]: $times мин.<br>";
  25. }
  26. }
  27. /*foreach ($paths[$point] as $station => $times){
  28. if (in_array($station, $pathDone) != True ){
  29. $canGet = $paths[$point][$station];
  30. echo "Ехать $canGet[time] минут посредством $canGet[by] <br>";
  31. $point = $station;
  32. step($paths, $pathDone, $point, $target, $time, $i, $pointNames, $transportName);
  33.  
  34. }
  35. }*/
  36.  
  37. }
  38. }
  39. }
Success #stdin #stdout 0s 82560KB
stdin
Standard input is empty
stdout
function step($paths, $pathDone, $point, $target, $time, $i, $pointNames, $transportName){
	var_dump($point);
	if ($i==0){echo "Начальная точка: $pointNames[$point]<br>";}
	$i++;
	$pathDone[$i] = $point;
	$pointStation = $paths[$point];
	foreach ($pointStation as $station => $times){
		$canGet[$station] = $times['time'];
	}
	asort($canGet);
	if (array_key_exists($target, $paths[$point]) == True){
		echo "В итоге ты попадешь в точку $pointNames[$target] за $time мин.<br>";
		echo "<br>Exit was found in " . count($pathDone)." steps!<br>";
		exit();
	} else {
		foreach ($canGet as $station => $times){
			if (in_array($station, $pathDone) != True ){
				$info = $pointStation[$station];
				$by = $info["by"];
				if ($i==1){echo "Из нее $transportName[$by] до точки $pointNames[$station]: $times мин.<br>";}
				$time += $times;
				$point = $station;
				step($paths, $pathDone, $point, $target, $time, $i, $pointNames, $transportName);
				echo "Из нее $transportName[$by] до точки $pointNames[$station]: $times мин.<br>";
			}
		}
		/*foreach ($paths[$point] as $station => $times){
			if (in_array($station, $pathDone) != True ){
				$canGet = $paths[$point][$station];
				echo "Ехать $canGet[time] минут посредством $canGet[by] <br>";
				$point = $station;
				step($paths, $pathDone, $point, $target, $time, $i, $pointNames, $transportName);
				
			}
		}*/
	
	}
}
}