1
$\begingroup$

I want to find an algorithm such that

  1. takes 10 inputs as natural number
  2. returns 1 output as natural number between 1 and 10. (including 1 and 10)

It means it should be a function

f($x_0$, $x_1$, $x_2$, $x_3$, $x_4$, $x_5$, $x_6$, $x_7$, $x_8$, $x_9$)= n

However, the time of computation of the function should be very long. It should take about 10 minutes by modern computer. And nobody can predict the return value in short time.

Can you recommended me a good algorithm which satisfies above condition?

$\endgroup$
11
  • 1
    $\begingroup$ For $i = 1$ until $10^{10}$, do stuff, end, output sample(uniform(1,10)). $\endgroup$
    – Ritz
    Oct 30 '14 at 12:32
  • $\begingroup$ I said, nobody can predict the result in short time. $\endgroup$
    – martian03
    Oct 30 '14 at 12:35
  • $\begingroup$ I edited my previous comment. $\endgroup$
    – Ritz
    Oct 30 '14 at 12:36
  • 1
    $\begingroup$ @WildChan Sorry. Can you help me make the question more precise? I want to say that it should be a "function". It means, for same inputs, the output should be same. $\endgroup$
    – martian03
    Oct 30 '14 at 12:38
  • 5
    $\begingroup$ Write the input numbers in base 7, concatenate. Run a couple of million iterations of SHA-2 or whatnot on it. Interpret the hash as a hexadecimal number, take the remainder modulo $10$, add $1$. $\endgroup$ Oct 30 '14 at 12:44
2
$\begingroup$

Convert the $x_i$ to strings, separated by ",". Then compute a good hash (for example, SHA-2) of the string and replace the first few characters by the hash. Repeat the latter very often, where the repeat count is adjusted to meet your 10 minute requirement. Then return $1+$ the hash modulo $10$.

$\endgroup$
2
  • $\begingroup$ Oh, I see that Daniel essentially posted the same solution as a comment $\endgroup$ Oct 30 '14 at 12:52
  • $\begingroup$ And I posted the same idea simultaneously, too :). Well, it's an obvious idea... $\endgroup$ Oct 30 '14 at 12:54
1
$\begingroup$

(Daniel Fischer wrote a comment with the same idea while I was typing this...)

Quick and dirty: Turn the list of numbers into a string and hash it with a cryptographic hash function (such as SHA-2). Then hash the result again. Repeat this $n$ times. Use the result hash to create a number between $1$ and $10$, e.g. with something like a checksum. Do some test runs to find a good $n$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.