7 kyu

Apparently-Modifying Strings

674 of 1,586user3010812

Description:

For every string, after every occurrence of 'and' and/or 'but', insert the substring 'apparently' directly after the occurrence(s).

If input does not contain 'and' or 'but', return the same string. If a blank string, return ''.

If substring 'apparently' is already directly after an 'and' and/or 'but', do not add another. (Do not add duplicates).

Examples:

Input 1

'It was great and I've never been on live television before but sometimes I don't watch this.'

Output 1

'It was great and apparently I've never been on live television before but apparently sometimes I don't watch this.'

Input 2

'but apparently'

Output 2

'but apparently' 

(no changes because 'apparently' is already directly after 'but' and there should not be a duplicate.)

An occurrence of 'and' and/or 'but' only counts when it is at least one space separated. For example 'andd' and 'bbut' do not count as occurrences, whereas 'b but' and 'and d' does count.

reference that may help: https://www.youtube.com/watch?v=rz5TGN7eUcM

Strings
Fundamentals

More By Author:

Check out these other kata created by user3010812

Stats:

CreatedMay 22, 2018
PublishedMay 23, 2018
Warriors Trained2922
Total Skips39
Total Code Submissions16020
Total Times Completed1586
Python Completions674
JavaScript Completions825
Rust Completions124
Total Stars26
% of votes with a positive feedback rating86% of 255
Total "Very Satisfied" Votes198
Total "Somewhat Satisfied" Votes45
Total "Not Satisfied" Votes12
Total Rank Assessments4
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • user3010812 Avatar
  • imjasonmiller Avatar
  • Voile Avatar
  • FArekkusu Avatar
  • jjsullivan5196 Avatar
  • user8436785 Avatar
  • saudiGuy Avatar
Ad