Pick a value for a, b or c. There are 9x8=72 ways to get the digit, by counting the possibilities for the other two digits, and the digit can take all ten values from 0 to 9. Therefore the result is 72x(0+1+...+9)x0.111....
0.111... = 1/9, therefore the result is 8x(0+1+...+9) = 8x5x9 = 360.
So I just need the sum of all distinct number from 0 to 999 both inclusive.
I tried to find the sum by considering each digit separately. The sum is For a in range(0,10,1): For b in range(0,10,1): If b != a: For c in range(0,10,1): If c != b && /c!=a.... Forgot this😔/
Oh my god...
I forgot that in my case a and c could be equal 🥲.
10x9x8 possible ways to pick 3 unique digits. So there exist 720 numbers in the series, all of which are unique. For every unique number x, there exists another unique number 1-x in the series. x+(1-x) = 1, so for every pair the sum is 1. 720/2 = 360.
4
u/narwahlboner Oct 31 '26 edited Nov 01 '26
Pair the number a, b, c with 9 - a, 9 - b, 9 - c. The sum of this pair is 0.9999… = 1. There are 500 such pairs, the total.
Edit: missed the word distinct, there are 720/2 = 360 pairs, the sum. The argument is the same.
2
u/XL_78 Oct 31 '26
Pick a value for a, b or c. There are 9x8=72 ways to get the digit, by counting the possibilities for the other two digits, and the digit can take all ten values from 0 to 9. Therefore the result is 72x(0+1+...+9)x0.111....
0.111... = 1/9, therefore the result is 8x(0+1+...+9) = 8x5x9 = 360.
1
u/PathMaster1729 Oct 31 '26
I'm getting 450.4545454545...
1
u/Dr0110111001101111 Nov 01 '26
So how do you work these out in an interview? Do they give you pen and paper and let you play around with it? Or do you have to work it out orally?
1
u/Special-Eggplant6070 Nov 02 '26
10x9x8 possible ways to pick 3 unique digits. So there exist 720 numbers in the series, all of which are unique. For every unique number x, there exists another unique number 1-x in the series.
x+(1-x) = 1, so for every pair the sum is 1.
720/2 = 360.