Commit 7b137f3e authored by Alexandr Sitchenko's avatar Alexandr Sitchenko

delay

parent 5a6b49ee
......@@ -17,32 +17,41 @@ if (!ctype_digit($_GET['first']) || !ctype_digit($_GET['end'])) {
if (strlen($_GET['first']) !== 6 || strlen($_GET['end']) !== 6) {
exit('You must enter parameters in format 000XXX!!');
}
if (((int)$_GET['end'] - (int)$_GET['first']) <= 0) {
exit('The first parameter must be less than the second!');
}
$current = (int)$_GET['first'];
$num = $current;
$ticketsHappy = 0;
do {
$sum1 = 0;
$sum2 = 0;
$current = $num;
while ($current > 999) {
$sum1 += $current % 10;
$current = (int)$current / 10;
}
while ($current > 0) {
$sum2 += $current % 10;
$current = (int)$current / 10;
/*$sum1 = 0;
$sum2 = 0;*/
$num = $current;
$numbers []= intdiv($current, 1000);
$numbers []= $current%1000;
$sum = [];
foreach($numbers as $key => $num) {
$sumCurrent = 0;
while ($num > 0) {
$sumCurrent += $num % 10;
$num = intdiv($num,10);
}
if ($sumCurrent > 9) {
$sumCurrent = ($sumCurrent % 10) + intdiv($sumCurrent,10);
}
$sum []= $sumCurrent;
}
if ($sum1 === $sum2) {
if ($sum[0] === $sum[1]) {
//echo($current.'<br/>');
++$ticketsHappy;
}
unset($numbers,$sum,$sumCurrent);
//$happy($current);
$stopLoop = ((int)$_GET['end'] - $num);
++$num;
$stopLoop = ($_GET['end'] - $current);
++$current;
} while ($stopLoop);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment