Happy tickets!

A bus ticket form a 1 a 2 a 3 a 4 a 5 a 6 \overline{a_{1}a_{2}a_{3}a_{4}a_{5}a_{6}} in which 0 a i 9 0 \leqslant a_{i} \leqslant 9 .Tickets a 1 a 2 a 3 a 4 a 5 a 6 \overline{a_{1}a_{2}a_{3}a_{4}a_{5}a_{6}} are called happy ticket if a 1 + a 2 + a 3 = a 4 + a 5 + a 6 a_{1} + a_{2} + a_{3} = a_{4} + a_{5} + a_{6} .

Find how many happy tickets from 000000 to 999999?


The answer is 55252.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Kyle T
Mar 7, 2019

<?php
$arr = range(0,9);
do{
$newarr = array();
foreach($arr as $a){
for($i=0;$i<=9;$i++){
$newarr[] = $a.$i;
}
}
$arr = $newarr;
} while(strlen($arr[0])<6);
$c=0;
foreach($arr as $a){
if($a[0]+$a[1]+$a[2]==$a[3]+$a[4]+$a[5]){
$c++;
}
}
echo $c; //55252
?>


0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...