6 kyu

Coding 3min : Half it III

68 of 80myjinxin2015

Description:

This is the simple version of Fastest Code series. If you need some challenges, please try the Performance version

Task:

This time, we coding halfIt with a string.

Give you a string s, return "Half" of s.

What does "Half" mean? In this kata, "Half" means:

If a char in s appear more than one time, remove half and left half.

Some example to help you understand the rules:

halfIt("aabb")="ab"
halfIt("abab")="ab"
s has two "a" and two "b", so first "a" and "b" left

halfIt("aaab")=???
halfIt("abaa")=???
When number of a char is odd, like "aaa"
We can't left one and half "a", we need "round" it to 2
And we always keep chars which at leftside of s
So first "a",second "a" and a "b" left, last "a" should removed
 "aaab"-->"aab", "abaa"-->"aba"

halfIt("!!??")="!?"
It should work properly in all types of chars, not only letters

halfIt("CcCccccccCcCCcC")="CcCccccC"
It should not ignore the case, C and c are different

If s is not a string, return ""
halfIt(1)=""
halfIt([])=""
halfIt(true)=""
halfIt({})=""
halfIt(null)=""
halfIt(undefined)=""

Series:

Puzzles
Games

Stats:

CreatedApr 20, 2016
PublishedApr 21, 2016
Warriors Trained167
Total Skips0
Total Code Submissions208
Total Times Completed80
JavaScript Completions68
Python Completions16
Total Stars3
% of votes with a positive feedback rating93% of 35
Total "Very Satisfied" Votes31
Total "Somewhat Satisfied" Votes3
Total "Not Satisfied" Votes1
Total Rank Assessments5
Average Assessed Rank
5 kyu
Highest Assessed Rank
5 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • kazk Avatar
  • user9644768 Avatar
  • ejini战神 Avatar
  • dfhwze Avatar
  • saudiGuy Avatar
Ad