On Dec 21, 7:24 am, Pubkeybreaker <pubkeybrea...@aol.com> wrote: > On Dec 21, 6:16 am, John <iamach...@gmail.com> wrote: > > > Given a function that returns a random number between 1-5, write one > > that returns a random number between 1-7 for the case when it should > > be integer and for the case it can be real. > > Impossible to do without more information. Anyone who > claims otherwise does not understand the question. > > Why is it impossible? Because you have failed to specify > a *distribution* for either your original function or your > new function. If you mean *uniformly* at random, you have failed > to state it. What if "at random" meant "drawn at random from a > truncated normal pdf"???
The OP also failed to state any constraints on running time or memory consumption. Do such omissions make a solution impossible as well?
That he didn't specify a distribution doesn't make a solution impossible. It just means that, *if* the the OP has a specific distribution in mind, then *since* he didn't state what it is, then any possible solution *may not* have the distribution the OP had in mind. By the same token, it very well might, also.
Of course, I suppose your real point was that it is extremely unlikely that any real world application will be indifferent to distribution, and so the question as asked is pretty crappy. To which I would agree.