6 kyu

Simple Fun #161: Replace Dashes As One

217 of 491myjinxin2015

Description:

Task

If string has more than one neighboring dashes(e.g. --) replace they with one dash(-).

Dashes are considered neighbors even if there is some whitespace between them.

Example

For str = "we-are- - - code----warriors.-"

The result should be "we-are- code-warriors.-"

Input/Output

  • [input] string str

  • [output] a string

Algorithms

Stats:

CreatedFeb 24, 2017
PublishedFeb 24, 2017
Warriors Trained1101
Total Skips19
Total Code Submissions2868
Total Times Completed491
JavaScript Completions216
C# Completions55
Python Completions217
Ruby Completions43
Total Stars19
% of votes with a positive feedback rating94% of 158
Total "Very Satisfied" Votes141
Total "Somewhat Satisfied" Votes16
Total "Not Satisfied" Votes1
Total Rank Assessments10
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
7 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • smile67 Avatar
  • hobovsky Avatar
  • dfhwze Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad