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-descriptive
  • False if the number is not.
Fundamentals
Mathematics
Number Theory

Stats:

CreatedJan 25, 2016
PublishedJan 25, 2016
Warriors Trained1394
Total Skips55
Total Code Submissions2490
Total Times Completed849
JavaScript Completions307
Ruby Completions113
Python Completions435
Clojure Completions39
Total Stars25
% of votes with a positive feedback rating91% of 168
Total "Very Satisfied" Votes142
Total "Somewhat Satisfied" Votes23
Total "Not Satisfied" Votes3
Ad
Contributors
  • RichAWarren Avatar
  • GiacomoSorbi Avatar
  • czterystaczwarty Avatar
  • FArekkusu Avatar
  • Just4FunCoder Avatar
  • farhanaditya Avatar
  • saudiGuy Avatar
Ad