For this problem, you will be given a range of single digits R, and a separate number K. You job is to calculate the mean of all K digit numbers that contain only distinct digits from the range R.
For example, if R=1:4 and K=2, you should calculate the mean of 12, 13, 14, 21, 23, 24, 31, 32, 34, 41, 42, and 43, as these are all of the two digit numbers that contain two distinct numbers from the range 1:4. The numbers 11, 22, 33 and 44 are not included, as they contain multiple copies of the same digit.
If 0 is included in R, it should not be a leading digit for any of the numbers, so an R of 0:2 and K=3 would include:
but not 012 or 021 for the purposes of this calculation.
You can assume that R will always have at least K digits, and there will be no repeating digits in R.
It's very sad that there is no matlab function "npermsk".
Not work for R is long, and k is small.
For example, R = 1:100, k = 2.
@li haitao, the max digital is 9. If length of R great than 10, it is another problem. I think you can submit a problem like this but larger R.
@ Binbin Qi, You're right.
547 Solvers
Create a cell array out of a struct
188 Solvers
Replace all zeros and NaNs in a matrix with the string 'error'
76 Solvers
2956 Solvers
Matrix of almost all zeros, except for main diagonal
121 Solvers