Question

This question relates to pseudo random number generators. You will write a c program that pulls...

This question relates to pseudo random number generators. You will write a c program that pulls the Powerball numbers. You will demonstrate how a deterministic number generator works.   In Powerball there are 5 white numbered balls that are pulled out of a drum containing 69 balls numbered 1-69. You cannot pull the same number twice. Additionally one red ball is numbered 1 to 26. You don’t have to worry about the PowerPlay option.

A) Write a c program that simulates a single Powerball drawing (5 white numbers and a single red number) and show how it might work over a period of 10 different drawing dates. In other words, use your seed to draw 5 white numbers and 1 red number for week 1. Then, use a new seed for to draw 5 white numbers and 1 red number to simulate week 2. And, yes, I know Powerball gets drawn twice weekly. I am trying to simplify the instructions. Take a screenshot of the output for all 10 weeks.

B) Explain how knowing the seeding of that PRNG will let you buy the winning ticket for any particular week. In other words, how could you rig the selection of the Powerball numbers similar to how Edward Tipton rigged the Hot Lotto?

C) Explain a better way to get the seeding that would introduce more entropy in your program (or maybe in the multi-state lottery system) that would solve this deterministic pattern.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below:::

#include <stdio.h>

#include <stdlib.h>

void printSeed(int *whiteBalls,int redBall){

printf("Seed set is -> ");

int i;

for(i=0;i<5;i++){

printf("%d ",whiteBalls[i]);

}

printf(":: %d\n",redBall);

}

void getPowerSeed(){

int whiteBalls[5];

int redBall=0;

int i,j;

int duplicate=0;

for(i=0;i<5;i++){

do{

whiteBalls[i] = rand()%69+1;

duplicate=0;

for(j=0;j<i;j++){

if(whiteBalls[j]==whiteBalls[i]){

duplicate=1;

}

}

}while(duplicate==1);

}

do{

redBall = rand()%25+1;

duplicate=0;

for(j=0;j<5;j++){

if(whiteBalls[j]==redBall){

duplicate=1;

}

}

}while(duplicate==1);

printSeed(whiteBalls,redBall);

}

int main()

{

int i;

for(i=1;i<=10;i++){

printf("Draw for week %d\n",i);

printf("First Draw ");

getPowerSeed();

printf("Second Draw ");

getPowerSeed();

printf("\n");

}

return 0;

}

output:

CAUsers Mohammad Shahrukh\Desktoplc_language_workspace\C1sdf.exe Draw for week 1 First Draw Seed set is -42 45 56 5 57:: 25 Second Draw Seed set is -> 25 34 53 39 48: 21 Draw for week 2 First Draw Seed set is -29 61 26 9 6 :: 3 Second Draw Seed set is -> 55 31 46 39 16:: 18 Draw for week 3 First Draw Seed set is ->32 34 18 54 24 23 Second Draw Seed set is -> 61 6 16 7 41 :: 18 Draw for week 4 First Draw Seed set is - 11 62 28 69 7::23 Second Draw Seed set is -> 43 10 42 31 53: 4 Draw for week 5 First Draw Seed set is ->38 18 45 26 52 1 Second Draw Seed set is -> 26 30 13 68 20:: 17 Draw for week 6 First Draw Seed set is ->69 42 49 13 23 16 Second Draw Seed set is -> 42 14 17 54 1:: 16 Draw for week 7 First Draw Seed set is -37 14 33 34 52 19 Second Draw Seed set is -> 30 34 66 4 14:: 7 Draw for week 8 First Draw Seed set is ->42 68 63 20 40: 15 Second Draw Seed set is -> 63 8 18 11 42:: 5 Draw for week 9 First Draw Seed set is ->51 4 66 17 58:: 5 Second Draw Seed set is -64 40 30 3 31:: 22 Draw for week 10 First Draw Seed set is -42 15 29 61 34 3 Second Draw Seed set is - 49 61 22 44 43: 12 Process exited after 0.1233 seconds with return value0 Press any key to continue .

Add a comment
Know the answer?
Add Answer to:
This question relates to pseudo random number generators. You will write a c program that pulls...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT