0
$\begingroup$

In Russia (at least in my town) we have bus tickets with 6 digits from 0 to 9. A ticket is considered "lucky" if the sum of its first 3 digits is equal to the sum of the last 3.

Is there any formula to calculate the amount of lucky tickets? I know I can just use brute force and calculate it on a computer with a for-loop, but I want more elegant solution.

  • 0
    given n, If you know how to calculate the number of solutions of x1+x2+x3=n with x_i in nonnegative integers then you will be able to solve this, I guess.2017-02-02
  • 0
    Can the first digit be a 0?2017-02-02
  • 0
    @mathreadler, yes, from 000000 to 9999992017-02-02
  • 0
    You can check up on integer compositions, they may be helpful : https://en.wikipedia.org/wiki/Composition_(combinatorics)2017-02-02

1 Answers 1

1

One simplification is to compute the number of three digit combinations that have each sum. There is one combination that sums to $0$ (assuming leading zeros are allowed), three that sum to $1$, and so on. This is easy to do with a spreadsheet. It takes advantage of the fact that the sum of $258$ is the same as $456$ and so on. There are $75$ ways to sum to $13$ The number of lucky tickets is the sum of the squares of these numbers because there are $3^2=9$ tickets that have both the first and last sums $1$ and $75^2=5625$ tickets that have both the first and last sums $13$. I find a total of $55252$ lucky tickets.

  • 0
    Thank you for explanation. Brute force way gives the same result :)2017-02-02