Z
Z
ZzZero2014-05-20 22:23:36
random numbers
ZzZero, 2014-05-20 22:23:36

How to generate a pseudo-random number depending on the input data?

It is necessary to generate a non-negative number, range 0...arg1, moreover, the number must also depend on the input string.
sample signature
int pseudo_rand(int arg1, string dependingString);
for arg1=30000 and the string dependingString="hello_world" - the pseudo-random number generator should return the same number (no matter how many times this function is called with these arguments), but as soon as we change the range (arg1) OR the string itself - a new one is needed , random for this combination of arguments, a number.
Any ideas?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander N++, 2014-05-20
@sanchezzzhak

Write the result to a hash, build the hash based on the first and second parameters.
Hash is a static variable

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question