Problem 44779. Don't be mean. Be nice!
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:
- 120
- 210
- 201
- 102
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.
Solution Stats
Problem Comments
-
1 Comment
It's very sad that there is no matlab function "npermsk".
Solution Comments
Show commentsGroup

Magic Numbers IV
- 20 Problems
- 24 Finishers
- Bouncy numbers
- It's going down. We're finding simbers!
- Euler–Mascheroni constant
- Hilbert numbers
- Pseudo Square Root (Inspired by Project Euler 266)
- Counting the Grand Primes
- Nth roots of unity
- Find Pseudo-Cyclic Number
- Lah Numbers
- Polar Form Complex Number Entry
- Give me Hamming on five, hold the mayo
- calculate PI without using pi function
- How brilliant are you?
- I'm going to enjoy watching you calculate, Mr Anderson
- Find two triangular numbers whose sum is input.
- Consecutive Powers
- Goldbach's marginal conjecture - Write integer as sum of three primes
- How many unique Pythagorean triples?
- Approximate e
- Amicable numbers
Problem Recent Solvers31
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!