Олимпиадный тренинг

Задача 39829. Number of lucky six digits


Determine the number of six-digit "happy" numbers. "Happy" we will call such a six-digit number, in which the sum of its first three digits is equal to the sum of its last three digits. 
Fill in the gaps in the program.

The  sum3(n) function calculates the sum of the digits of a three-digit number.
The happy(n) function determines whether the number n is happy. The happy(n) function uses the sum3(n) function to do its job.
Запрещенные операторы:str