Based on a lottery winning you are required to create a pseudo code on the follo
ID: 3859727 • Letter: B
Question
Based on a lottery winning you are required to create a pseudo code on the following criteria:
Assumption there is 1 million dollars to be won and will be split as
There are 3 tickets
6 numbers - wins jackpot, this could be shared amongst the 3 tickets
5 numbers - 40% of the winning, if there was no jackpot, and can also be shared amongst winning tickets
4 numbers 20% of 1 million, if there was no jackpot, and can also be shared amongst winning tickets
3 numbers get a free ticket for next time lottery is played.
You are required to share your pseudo code and critic and or under stand submissions, and why such approaches were taken.
Explanation / Answer
//algorithm
As per your question I am considering there are four type of tickets
1. 3 length : for these all we will issue tickets free next time they played
2. 4 length : for these all if any one wins jackpot he can win $20,000
3. 5 length : for these all if any one wins jackpot he can win $40,000
4. 6 length : for these all if any one wins jackpot he can win the remaining amount of 1M.
we can create 4 queue for this and then check if any one is winning or not. first queue is foe 3 length tickets , second for 4 length so on....
amount -> 1000000
tickets[n]
vector<int> T[4]
for all tickets i -> 1 to n
if tickets[i] length is equal to 3
T[0] add this
if tickets[i] length is equal to 4
T[1] add this
if tickets[i] length is equal to 5
T[2] add this
if tickets[i] length is equal to 6
T[3] add this
//now we need to calculate winning amount
//for all tickets in first list will eligible for free tickets next time they played
for i-> 0 to tickets[1].size()
if tickets[0][i] wins jackpot then
amount = amount - 2000000
for i-> 0 to tickets[2].size()
if tickets[0][i] wins jackpot then
amount = amount - 4000000
for i-> 0 to tickets[3].size()
if(tickets[0][i] wins jackpot then
remaining amount is wins by this user.
I used above approach as we have to find out the amount won in jackpot. for before calculating jackpot amount for 6 length tickets user we need to find out if any tickets of length 4 or 5 wins jackpot if they wins then we need to subtract that amount from jackpot amount and reaming amount will be won by 6 length ticket in jackpot.
if you find above approach helpful then thumbs up this one or let me now in comment for any understanding.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.