Computa' shit

Harbinger said:
Oh shit. I just realized I won some kind of geek award. And said it was cool. I'm so embarrassed. You tricked me.:eek:
dont worry... it wont hurt too bad...

-popping open bottle of lube-

just relax...
:D
 
OK

Next problem.

YOu are going to write a little program to deliver three numbers between 1 and 50 inclusive. There can be no duplication.

The purpose is to generate, randomly, based on a 'lucky' number that the user provides six number that can be used to play the lottery.

So give me a brief description of your approach.

No matter what language you want ot work in, there is a randome numer generator available to you. This generator requires a 'seed' number, and if you use the same 'seed', you will always get the same sequence of random numbers.

Have fun. :D

Ishmael
 
Ish, hope you don't mind us hijacking this thread.

This computer shit on a Friday night just gotsta go!
 
I pop in for a hot second and look what I find. Okay, I like this stuff. :)

First, define the set of all natural numbers between 1 and 50 inclusive.

Second, prompt the user to input one number inside the set.

Third, the generator makes a call to the random number generator which produces one number. That number is displayed for the user and also becomes the new seed which produces a second random number, and so on until all six numbers are produced.

How's that?
 
ProofreadManx said:
Ish, hope you don't mind us hijacking this thread.

This computer shit on a Friday night just gotsta go!

Not a prob. PRM. I was just trolling anyway. :D

Ishmael
 
Ishmael said:
OK

Next problem.

YOu are going to write a little program to deliver three numbers between 1 and 50 inclusive. There can be no duplication.

The purpose is to generate, randomly, based on a 'lucky' number that the user provides six number that can be used to play the lottery.

So give me a brief description of your approach.

No matter what language you want ot work in, there is a randome numer generator available to you. This generator requires a 'seed' number, and if you use the same 'seed', you will always get the same sequence of random numbers.

Have fun. :D

Ishmael

Not nearly as coherent as the calendar problem. Am I generating the string of six numbers or is the user inputting those six numbers?

/* assume function that returns int and takes seed, like rand(seed) */

int try_once ( int seed, int MAX){
return rand(seed) % MAX + 1;
}

void do_everything_else(){

int seed = 0;
const int BALLS = 6;
const int MAX = 50;
int used[BALLS];
int maybe = 0;

for ( int i = 0; i < BALLS; i++) {
cout << "\nEnter your request for ball" << i+1 << ": "
cin >> seed;
boolean new_num_good = true;
do {
maybe = try_once(seed, MAX);
for (int j = 0; j < i; j++){
if ( maybe == used[j] ){
new_num_good = false;
seed = (seed +17) % MAX + 1;}}}(!new_num_good)
used = maybe;}
cout << "Your winners are: "
for ( int k = 0; k < BALLS; k++ )
cout << used[k] << " ";
}
 
Last edited:
ish-darling... you are slippin'...

these fine folks are looking for their geek-prize o'the night...

-tapping foot-
 
Watch out, Schleicher! It seems the prize is some kind of ass fucking. You should leave the thread will you still can.
 
Harbinger said:
Watch out, Schleicher! It seems the prize is some kind of ass fucking. You should leave the thread will you still can.
_____

You say that as if it was a bad thing, Harbinger.

Goahead, strap on a dildo and demonstrate on the newbie.
 
Schleicher said:
Not nearly as coherent as the calendar problem. Am I generating the string of six numbers or is the user inputting those six numbers?

/* assume function that returns int and takes seed, like rand(seed) */

int try_once ( int seed, int MAX){
return rand(seed) % MAX + 1;
}

void do_everything_else(){

int seed = 0;
const int BALLS = 6;
const int MAX = 50;
int used[BALLS];
int maybe = 0;

for ( int i = 0; i < BALLS; i++) {
cout << "\nEnter your request for ball" << i+1 << ": "
cin >> seed;
boolean new_num_good = true;
do {
maybe = try_once(seed, MAX);
for (int j = 0; j < i; j++){
if ( maybe == used[j] ){
new_num_good = false;
seed = (seed +17) % MAX + 1;}}}(!new_num_good)
used = maybe;}
cout << "Your winners are: "
for ( int k = 0; k < BALLS; k++ )
cout << used[k] << " ";
}


There ya go schlei. I'm going to give it to you for the effort.

I would suggest one thing. All random number gens. will come up with the same sequence given the same seed. Most folks will tend to pick the same 'lucky' numbers. So, to prevent repetitive sequences you might try seeding the generator with the miilisecond number from the system clock for the first seed. ;)

Next prob in the AM.

Ishmael
 
Ishmael said:
There ya go schlei. I'm going to give it to you for the effort.

I would suggest one thing. All random number gens. will come up with the same sequence given the same seed. Most folks will tend to pick the same 'lucky' numbers. So, to prevent repetitive sequences you might try seeding the generator with the miilisecond number from the system clock for the first seed. ;)

Ishmael

Yay for me. I didn't know Schleicher could get shorter. LOL:D
 
I've programmed that first one before...

The second one has stated could be written

Begin
WRITELINE("1")
WRITELINE("10")
WRITELINE("11")
End

"YOu are going to write a little program to deliver three numbers between 1 and 50 inclusive. There can be no duplication. "


:D

I wanna see your first one without If's because, if we're talking math, that's not a Calculation. That's a comparison with a yes/no decision...

2+2 = 3+1 y/n ...
 
Using the millisecond number as the seed is not enough. Let's say that you are doing a Monte Carlo simulation, that requires you to run 10,000 "random" paths. Using just the millisecond number effectively reduces you to only ten paths.

For a better random number generator, you would pull out multiple numbers for your formula for the generation, which interact in a nonlinear fashion, so that each time the iteration was run, there would be a unique combination.

Such as seed number Z = milliseconds;
Raised to X (hundredths of a second);
Dived by Y (thousands of a second);
Raised to 1/D (date number including days, months years and seconds).

Thereby giving you a truly unique starting point and calculation formula for each possible path.
 
takingchances42 said:
Using the millisecond number as the seed is not enough. Let's say that you are doing a Monte Carlo simulation, that requires you to run 10,000 "random" paths. Using just the millisecond number effectively reduces you to only ten paths.

For a better random number generator, you would pull out multiple numbers for your formula for the generation, which interact in a nonlinear fashion, so that each time the iteration was run, there would be a unique combination.

Such as seed number Z = milliseconds;
Raised to X (hundredths of a second);
Dived by Y (thousands of a second);
Raised to 1/D (date number including days, months years and seconds).

Thereby giving you a truly unique starting point and calculation formula for each possible path.

True enough TC42, but we're only interested in picking up an initial seed for a 6 number sequence. Then you re-seed with the 'lucky' number.

Monte Carlo can get quite involved.

But you have given me a good morning prob.

Ishmael
 
Just use Mandelbrot's basic iteration using the time to seed both initial variables [or iteration count]. It cannot be truly random lest it become a specific randomness, thus violating the rule. (Your whole number could be on which count you hit infinity...)

A psudo-random number is closer to truth than a random number...
 
TC42 brought up Monte Carlo theory.

For a quick morning question. Where was it invented and why?

Ishmael
 
Last edited:
Begin
WRITELINE('Good morning World')
WRITELINE(':D ')
REM second line for extra credit
REM documentation for classroom only
REM the programmer is a fucktard waiting for promotion to systems analysist
end
 
Back
Top