Here is one of possible initial algorithms:

You need numbers between 0 and M (max value), need C cards.
So generate X(0) = 0,  X(i) = X(i-1) + rand(0 .. 2*M/C)  (can overflow M -
so check against first generated numbers in O(1)).

For a rand make sure to use strong random numbers generator (like one's used
for crypto algos or hardware based one).

That's all.

P.S.> Regarding database - then you are going to consume them - you will
need to lookup if it was used or not. As result you will need indexes in DB.
If you have indexes - this mean for generating more numbers - you can simply
attempt in insert new values and let DB to check if it's unique or not.



On Sat, Sep 25, 2010 at 3:37 PM, Erick Njenga <[email protected]> wrote:

> I'm creating an application that involves scratch-cards and would like to
> know what solutions are available for generating the numbers. Any hash
> function suggestions?
>
> --
>
> Thanks and Regards,
> Erick Njenga Nyachwaya,
> M: +254-725-008-790
>
>  <http://www.facebook.com/ErickNjenga><http://www.twitter.com/ErickNjenga>
>
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "google-codejam" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-code%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-code?hl=en.
>



-- 
--
Andriy G. Tereshchenko
Odessa, Ukraine

-- 
You received this message because you are subscribed to the Google Groups 
"google-codejam" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-code?hl=en.

Reply via email to