I really hope they just wanted you to argue that the task is impossible.
I really hope they just wanted you to argue that the task is impossible.
Will the interviewee push back when asked to do something impossible?
Will they then demonstrate that they can do some simpler case (which will minimize mental switching costs for both the interviewee and interviewer)?
Pretty dumb fucking thing to ask a front end engineer to do, if you ask me.
An example algorithm could determine if a run of integers represents a random sequence with some probability 'p'.
But you can't prove that a sequence is indeed random: the sequence [sha256(1), sha256(2), sha256(3), ...] passes the usual tests and isn't even clever. For any set of tests you can write a pseudo random generator that passes them
If the output was plotted (from the minimum possible output to the maximum) and run a sufficient number of times, I would expect the chart of the output to have a very good distribution, and not have any serious hotspots.
To prove this, my solution would probably go something like: Probability of number N being output = 1 / MaxPossibleNumber
Then I would run a test a sufficient number of times (depends on what MaxPossibleNumber is) such that as the amount of numbers generated approaches infinity, the percentage of times any particular number is output approaches 1/MaxNumber.
The harder part would be making sure sequences of numbers don't repeat. In addition to looking at the total distribution, I think I would also want to log the order in which the numbers were generated and then run an algorithm that looks for sequence repeats.
I am NOT familiar with how random number generators work, so this is a naive solution off the top of my head and could be completely wrong, but w/e.
1 when n = number, 0 everywhere else