Regarding Codechef Problems

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.

  1. Problem: http://www.codechef.com/problems/MARCHA4

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

Do you have multiple accounts? It seems so… Why?

Do not ask same questions! (http://discuss.codechef.com/questions/1509/please-check-my-code-why-codechef-giving-it-wrong)

I also removed code for SAD, you cannot ask for hints in live contest…