Hi Admin,
I tried to solve below problems and I have written cod in PHP. Can you tell me why it is giving me wrong answer. I want to know where I am being wrong or what I am doing wrong.
- Problem: MARCHA4 Problem - CodeChef
My Submitted Code for above problem in PHP as below.
//Suppose below are my posted array
$nTimeMul = array(4,9);
$nToAppear = array(2,3);
function getDezireOutput($nTimeMul = array(), $nToAppear = array()) {
$i = 0;
foreach ($nTimeMul as $num) {
$tempNum = 1;
for ($t=0; $t < $num; $t++) {
$tempNum = $tempNum * $num;
}
echo substr ($tempNum, 0, $nToAppear[$i]).' '.substr ($tempNum, -$nToAppear[$i]).'
';
$i++;
}
}
getDezireOutput ($nTimeMul, $nToAppear);
Please have look into above problem and let me know the problems with above code so, I can figure it out.
Waiting for your reply.
Regards,
Jimit Shah