<?php
$CntArr = [ '0' => 6,
'1' => 2,
'2' => 5,
'3' => 5,
'4' => 4,
'5' => 5,
'6' => 6,
'7' => 3,
'8' => 7,
'9' => 6];
$AnswerArr = array();
for($LoopH = 0 ; $LoopH <= 23 ; $LoopH++){
for($LoopM = 0 ; $LoopM <= 59 ; $LoopM++){
for($LoopS= 0 ; $LoopS <= 59 ; $LoopS++){
$TimeStr = sprintf("%02d%02d%02d" , $LoopH , $LoopM , $LoopS);
$SumCnt = 0;
foreach(Str_Split($TimeStr) as $EachStr){
$SumCnt += $CntArr[$EachStr];
}
if (array_key_exists($SumCnt , $AnswerArr))
$AnswerArr[$SumCnt]++;
else $AnswerArr[$SumCnt] = 1;
}
}
}
printf("27箇所が点灯するのは、%d通り\n" , $AnswerArr[27]);
printf("30箇所が点灯するのは、%d通り\n" , $AnswerArr[30]);