Sonny
BAN USER
- 1of 1 vote
AnswersI have a lottery ticket. Each of these lottery tickets has a 6 digit number on it. The winning lottery tickets are those whose sum of the first three digits is equal to the sum of the last three digits. How many possible winning tickets are there?
- Sonny
Note: Leading ‘ZEROES’ are counted. So a number like 004103 is a valid winning ticket since 0+0+4 = 1+0+3.| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer Brain Teasers
Hi Everyone,
I came up with the following solution to the above problem. The combinations form a very weird series. Below is the code for it. Let me know if this can be done in a more efficient time.
#include<stdio.h>
#include<stdlib.h>
#define MAX_SUM 27
#define NDIGIT 3
#define C0 1
int main(){
register int TOTAL = 0;
int mid = MAX_SUM/2;
int curr;
int prev_val[2] = {C0, NDIGIT};
for(int sum=2; sum<=mid; sum++){
curr = (prev_val[1] - prev_val[0]) + 1 + prev_val[1];
TOTAL += 2*(prev_val[0]*prev_val[0]);
prev_val[0] = prev_val[1];
prev_val[1] = curr;
}
TOTAL += 2*(prev_val[0]*prev_val[0]) + 2*(prev_val[1]*prev_val[1]);
printf("Winning Tickets = %d\n", TOTAL);
return 0;
}
Repchristinetcollazoc, Software Analyst
I am a pediatric nurse.I administer directly procedures and medicines to children according to prescribed I also continually assess ...
Repkaylafgioia, Cloud Support Associate at Absolute Softech Ltd
Hi, I am Kayla from Elkins USA. I am working as Project management and I have professional 3-year experience in ...
RepEvieBBlack, AT&T Customer service email at ASAPInfosystemsPvtLtd
I am Evie from Santa Fe Springs USA, I am working as a manager in a worldwide company. I also ...
RepI am Susan From Wasilla USA. and my strong interest in yoga and reading historical books. I have a large ...
Repmanueladturner, Associate at Accenture
I am a content writer with years of successful track record of writing concise and fact-filled content on different topics ...
Repmadan@kukooo.in, Analyst at Absolute Softech Ltd
I am a content writer with years of successful track record of writing concise and fact-filled content on different topics ...
RepMaryLopal, Applications Developer at Coupondesh
I am a 41 year old dermatologist in Saginaw USA. I do like to face the challenges . I'm active ...
RepSpent 2001-2007 promoting augmented reality integrated through social media in West Palm Beach, FL. Won several awards for merchandising Roombas ...
- Sonny July 09, 2012