1 kyu
Regular Expression for Binary Numbers Divisible by n
603 of 1,236hufftheweevil
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 | 18976 |
Total Skips | 1538 |
Total Code Submissions | 39306 |
Total Times Completed | 1236 |
JavaScript Completions | 603 |
Python Completions | 468 |
Java Completions | 121 |
Kotlin Completions | 21 |
Groovy Completions | 6 |
Scala Completions | 24 |
F# Completions | 6 |
Ruby Completions | 22 |
C Completions | 27 |
Rust Completions | 29 |
C++ Completions | 14 |
Total Stars | 492 |
% of votes with a positive feedback rating | 96% of 260 |
Total "Very Satisfied" Votes | 241 |
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 |