Simple Fun #53: Combs
Description:
Task
Miss X has only two combs in her possession, both of which are old and miss a tooth or two. She also has many purses of different length, in which she carries the combs. The only way they fit is horizontally and without overlapping. Given teeth' positions on both combs, find the minimum length of the purse she needs to take them with her.
It is guaranteed that there is at least one tooth at each end of the comb.
- Note, that the combs can not be rotated/reversed.
Example
For comb1 = "*..*" and comb2 = "*.*"
, the output should be 5
Although it is possible to place the combs like on the first picture, the best way to do this is either picture 2 or picture 3.
Input/Output
[input]
stringcomb1
A comb is represented as a string. If there is an asterisk ('*') in the ith position, there is a tooth there. Otherwise there is a dot ('.'), which means there is a missing tooth on the comb.
Constraints: 1 ≤ comb1.length ≤ 10.
[input]
stringcomb2
The second comb is represented in the same way as the first one.
Constraints: 1 ≤ comb2.length ≤ 10.
[output]
an integerThe minimum length of a purse Miss X needs.
Similar Kata:
Stats:
Created | Jan 26, 2017 |
Published | Jan 26, 2017 |
Warriors Trained | 1188 |
Total Skips | 65 |
Total Code Submissions | 2368 |
Total Times Completed | 319 |
JavaScript Completions | 88 |
C# Completions | 58 |
Python Completions | 155 |
Ruby Completions | 28 |
Haskell Completions | 18 |
Total Stars | 46 |
% of votes with a positive feedback rating | 97% of 92 |
Total "Very Satisfied" Votes | 87 |
Total "Somewhat Satisfied" Votes | 4 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 5 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 5 kyu |