7 kyu
String doubles
97 of 3,064KenKamau
Description:
In this Kata, you will write a function doubles
that will remove double string characters that are adjacent to each other.
For example:
doubles('abbcccdddda') = 'aca'
, because, from left to right:
a) There is only one 'a' on the left hand side, so it stays.
b) The 2 b's disappear because we are removing double characters that are adjacent.
c) Of the 3 c's, we remove two. We are only removing doubles.
d) The 4 d's all disappear, because we first remove the first double, and again we remove the second double.
e) There is only one 'a' at the end, so it stays.
Two more examples: doubles('abbbzz') = 'ab'
and doubles('abba') = ""
. In the second example, when we remove the b's in 'abba'
, the double a
that results is then removed.
The strings will contain lowercase letters only. More examples in the test cases.
Good luck!
Strings
Algorithms
Similar Kata:
Stats:
Created | Nov 21, 2017 |
Published | Nov 22, 2017 |
Warriors Trained | 5918 |
Total Skips | 83 |
Total Code Submissions | 19022 |
Total Times Completed | 3064 |
Ruby Completions | 97 |
Python Completions | 758 |
JavaScript Completions | 1093 |
C# Completions | 204 |
Haskell Completions | 76 |
Rust Completions | 68 |
C++ Completions | 858 |
Clojure Completions | 12 |
Total Stars | 96 |
% of votes with a positive feedback rating | 90% of 589 |
Total "Very Satisfied" Votes | 496 |
Total "Somewhat Satisfied" Votes | 65 |
Total "Not Satisfied" Votes | 28 |
Total Rank Assessments | 5 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 7 kyu |