7 kyu
Self-Descriptive Numbers
435 of 849RichAWarren
Description:
A number is self-descriptive when the n'th digit describes the amount n appears in the number.
Example:
For the number 21200:
- There are two 0's in the number, so the first digit is 2.
- There is one 1 in the number, so the second digit is 1.
- There are two 2's in the number, so the third digit is 2.
- There are no 3's in the number, so the fourth digit is 0.
- There are no 4's in the number, so the fifth digit is 0.
Numbers can be of any length up to 9 digits and are only full integers. For a given number, derive a function that returns:
True
if the number is self-descriptiveFalse
if the number is not.
Fundamentals
Mathematics
Number Theory
Similar Kata:
Stats:
Created | Jan 25, 2016 |
Published | Jan 25, 2016 |
Warriors Trained | 1394 |
Total Skips | 55 |
Total Code Submissions | 2490 |
Total Times Completed | 849 |
JavaScript Completions | 307 |
Ruby Completions | 113 |
Python Completions | 435 |
Clojure Completions | 39 |
Total Stars | 25 |
% of votes with a positive feedback rating | 91% of 168 |
Total "Very Satisfied" Votes | 142 |
Total "Somewhat Satisfied" Votes | 23 |
Total "Not Satisfied" Votes | 3 |