I guess this is a 6kyu kata #9: Squeeze two strings
Description:
Description
We have two strings left
and right
:
left= right=
`aaaaaaaa ` fff
bbb ggggggg
cccccc hhhh
dd iiiiiiiiii
eeeeeeeeeeeeeee` jjjj`
Squeeze them from the left and right sides to the middle, until the characters of some lines come together, or the character of the left side reach to the tail of right side,or the character of the right side reach to the head of left side. Then stop squeezing and forming a new string.
squeeze ---> aaaaaaaa fff <--- squeeze
squeeze ---> bbb ggggggg <--- squeeze
squeeze ---> cccccc hhhh <--- squeeze
squeeze ---> dd iiiiiiiiii <--- squeeze
squeeze ---> eeeeeeeeeeeeeee jjjj <--- squeeze
finally we got:
aaaaaaaa fff
bbb ggggggg
cccccc hhhh
dd iiiiiiiiii
eeeeeeeeeeeeeeejjjj
Note 1: They don't necessarily have the same number of rows. In the example below, the left
and right
have a different number of rows, and one line reach to the tail of the right side.
left= right=
`aaa `
bbbbb
ccccccccccccccc
dddd
ee`
fff`
squeeze:
squeeze ---> aaa <--- squeeze
squeeze ---> bbbbb <--- squeeze
squeeze ---> ccccccccccccccc <--- squeeze
squeeze ---> dddd <--- squeeze
squeeze ---> ee <--- squeeze
squeeze ---> fff <--- squeeze
finally we got:
aaa
bbbbb
ccccccccccccccc
dddd
ee
fff
Note 2: The relative position of the character should not be changed. Use examples to illustrate: The following example is similar to the last one, the only difference is the characters "bbbbb" and "bbb", please pay attention to its location:
left= right=
`aaa `
bbb
ccccccccccccccc
dddd
ee`
fff`
squeeze:
squeeze ---> aaa <--- squeeze
squeeze ---> bbb <--- squeeze
squeeze ---> ccccccccccccccc <--- squeeze
squeeze ---> dddd <--- squeeze
squeeze ---> ee <--- squeeze
squeeze ---> fff <--- squeeze
finally we got:
aaa
bbb
ccccccccccccccc
dddd
ee
fff
Note 3: In the final result, the spaces at the tail of rows should be removed.
OK, that's all. I guess this is a 6kyu kata. If you agree, please rank it as 6kyu and vote very
;-) If you think this kata is too easy or too hard, please shame me by rank it as you want and vote somewhat
or none
:[
Task
Complete function squeeze
that accepts two arguments left
and right
. Returns the result in accordance with the rules above.
Similar Kata:
Stats:
Created | Sep 13, 2016 |
Published | Sep 13, 2016 |
Warriors Trained | 340 |
Total Skips | 7 |
Total Code Submissions | 779 |
Total Times Completed | 42 |
JavaScript Completions | 36 |
Python Completions | 7 |
Total Stars | 8 |
% of votes with a positive feedback rating | 92% of 18 |
Total "Very Satisfied" Votes | 16 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 4 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 6 kyu |