Hello, I'm newbie to this site.
I have been solving the problem: 400. To and Fro (https://www.spoj.pl/problems/TOANDFRO/).
And I have tested it self - it's working. But there ( at spoj.pl ) i've got runtime error (NZEC).
Somebody can help me? Thanks.
<?php
for($j=0;;$j++){ // Input
$eil_Ilgis[$j] = fgets(STDIN, 20); // Columns (int)
if($eil_Ilgis[$j]==0){
break;
}else{
$tekstas[$j] = fgets(STDIN, 200); // Encrypted text (string)
$arr_chu = array_chunk(str_split($tekstas[$j]), $eil_Ilgis[$j]);
for($x=0,$s=0; $x<count($arr_chu); $x++,$s++){
$s=($s==2)?0:$s;
if($s==1){
$bla=array_reverse($arr_chu[$x]);
for($i=0,$a=0;$i<$eil_Ilgis[$j]; $i++,$a+=((count(str_split($tekstas[$j]))/$eil_Ilgis[$j])-1)){
$new_arr[$j][($x+$i+$a)]=$bla[$i];
}
}else{
for($i=0,$a=0; $i<$eil_Ilgis[$j]; $i++,$a+=((count(str_split($tekstas[$j]))/$eil_Ilgis[$j])-1)){
$new_arr[$j][($x+$i+$a)]=$arr_chu[$x][$i];
}
}
}
}
}
for($j=0; $j<count($eil_Ilgis); $j++){ // Output
for($d=0; $d<count(str_split($tekstas[$j])); $d++){
echo $new_arr[$j][$d];
}
echo "<br />";
}
?>