Check whether a number is valid in a given numeral system
Description:
A numeral system is a way of writing numbers using a specific set of digits: for example, the decimal system (also called base-10), which is the most commonly used numeral system worldwide, uses the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 to represent numbers. There is also the binary system (also called base-2), which uses the digits 0 and 1.
For digits that are bigger than 9, the English alphabet is used: 'A' is used for the number 10 in bases higher than 10. This goes all the way to 'Z' in base-36.
The largest digit allowed in a certain base is always 1 smaller than this base.
You need to write a function that checks whether all of the digits of a non-negative integer number are a part of the specified base: for example, the number 17253 is valid for base-8, because this base contains the digits 0, 1, 2, 3, 4, 5, 6, 7, but the number 19823 is not valid for this base, because it contains the digits 9 and 8 which are not a part of base-8.
Note: numbers will be checked against bases from 2 to 36. For digits > 9 (A, B, etc.) such digits will always be uppercase. The function should return a boolean: true
for numbers that are valid for a specified numeral system and false
otherwise.
Similar Kata:
Stats:
Created | Jan 1, 2025 |
Published | Jan 2, 2025 |
Warriors Trained | 2088 |
Total Skips | 36 |
Total Code Submissions | 2643 |
Total Times Completed | 956 |
JavaScript Completions | 294 |
Python Completions | 408 |
C Completions | 88 |
Scala Completions | 14 |
OCaml Completions | 8 |
Java Completions | 112 |
C# Completions | 50 |
TypeScript Completions | 43 |
PHP Completions | 25 |
C++ Completions | 22 |
Total Stars | 14 |
% of votes with a positive feedback rating | 94% of 125 |
Total "Very Satisfied" Votes | 111 |
Total "Somewhat Satisfied" Votes | 13 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 17 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 8 kyu |