I read this question and thought it would make a nice challenge.
Task
Give an input 0<n<10
generate a random number with
- exactly n digits
- the first not a
0
- so
f(n)>10**(n-1)-1
- so
- distinct digits
Winning criteria
This is code-golf so shortest code wins.
Random
I mean evenly distributed random. So from the view of the program each possible number has the same chance. If the language you're writing in has a weird random number generator, it's okay to use that one.
Example
The list of values to randomly select from for n=2
is:
[10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98]
n=0
. In the Task section it says0<n<10
. no0
isn't a valid output forn=1
since10**(1-1)-1=0
and0
is not greater than0
\$\endgroup\$ – Roman Gräf Apr 25 '17 at 14:45