1 kyu
Regular Expression for Binary Numbers Divisible by n
599 of 1,214hufftheweevil
Description:
Regular Expression for Binary Numbers Divisible by n
Create a function that will return a regular expression string that is capable of evaluating binary strings (which consist of only 1
s and 0
s) and determining whether the given string represents a number divisible by n
.
Tests
Inputs 1 <= n <= 18
will be tested
Each n
will be tested against random invalid tests and random valid tests (which may or may not pass the regex test itself, accordingly).
Notes
- Strings that are not binary numbers should be rejected.
- Keep your solution under 5000 characters. This means you can't hard-code the answers.
- Only these characters may be included in your returned string:
01?:*+^$()[]|
Javascript Notes
- Do not include the regex caps
/.../
. Your string will be used as such:RegExp(regexDivisibleBy(3))
in the tests. - No funny business! There should be no need for prototyping, so don't even think about it.
Algorithms
Puzzles
Regular Expressions
Strings
Similar Kata:
Stats:
Created | Aug 16, 2017 |
Published | Aug 17, 2017 |
Warriors Trained | 18845 |
Total Skips | 1527 |
Total Code Submissions | 38870 |
Total Times Completed | 1214 |
JavaScript Completions | 599 |
Python Completions | 456 |
Java Completions | 119 |
Kotlin Completions | 19 |
Groovy Completions | 5 |
Scala Completions | 23 |
F# Completions | 5 |
Ruby Completions | 21 |
C Completions | 25 |
Rust Completions | 24 |
C++ Completions | 10 |
Total Stars | 485 |
% of votes with a positive feedback rating | 96% of 256 |
Total "Very Satisfied" Votes | 237 |
Total "Somewhat Satisfied" Votes | 15 |
Total "Not Satisfied" Votes | 4 |
Total Rank Assessments | 5 |
Average Assessed Rank | 1 kyu |
Highest Assessed Rank | 1 kyu |
Lowest Assessed Rank | 2 kyu |