An algorithm which takes long time to halt

207 Views Asked by At

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?

2

There are 2 best solutions below

2
On BEST ANSWER

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$.

0
On

(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$.