6 kyu
Midpoint inception
87joh_pot
Description:
Write
function midPoint(str)
that takes all the words in a string str
and cumulatively appends their midpoints
For example:
midPoint('abc') === 'b'
midPoint('abcd') === 'bc' // when length is even, then midpoint is 2 chars
midPoint('abcdefg') === 'dbf'
// 'd' is the midpoint of 'abcdefg' (abc)d(efg) --> go left split first
// 'b' is the midpoint 'abc'
// 'f' is the midpoint of 'efg'
midPoint('abcdefgh') === 'debg'
// 'de' is midpoint of 'abcdefgh' (abc)de(fgh)
// 'b' is midpoint of 'abc'
// 'g' is midpoint of 'fgh'
midPoint('abcdefghij1234567890') === 'j1ebcgh63489'
// 'j1' is midpoint of 'abcdefghij1234567890' (abcdefghi)j1(234567890)
// 'e' is midpoint of 'abcdefghi' (abcd)e(fghi)
// 'bc' is midpoint of 'abcd' (a)bc(d)
// 'gh' is midpoint of 'fghi' (f)gh(i)
// '6' is midpoint of '234567890' (2345)6(7890)
// '34' is midpoint of '2345' (2)34(5)
// '89' is midpoint of '7890' (7)89(0)
midPoint('abc def') === 'b e' // words can be space seperated
midPoint('a ab abc abcd abcde abcdef abcdefg abcdefgh abcdefghi abcdefghij') === ' b bc c cd dbf debg ebcgh efbchi'
Notes:
- Always go left and then right when finding midpoints
- Keep all the whitespaces of the original sentence
- A "word", here is a sequence of chars delimited by whitespaces or beginning or end of string.
Algorithms
Similar Kata:
Stats:
Created | Mar 2, 2016 |
Published | Mar 2, 2016 |
Warriors Trained | 233 |
Total Skips | 8 |
Total Code Submissions | 290 |
Total Times Completed | 87 |
JavaScript Completions | 87 |
Total Stars | 8 |
% of votes with a positive feedback rating | 93% of 37 |
Total "Very Satisfied" Votes | 33 |
Total "Somewhat Satisfied" Votes | 3 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 8 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |