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:
- Bug in Apple
- Father and Son
- Jumping Dutch act
- Planting Trees
- Give me the equation
- Find the murderer
- Reading a Book
- Eat watermelon
- Special factor
- Guess the Hat
- Symmetric Sort
- Are they symmetrical?
- Max Value
- Trypophobia
- Virus in Apple
- Balance Attraction
- Remove screws I
- Remove screws II
- Regular expression compression
- Collatz Array(Split or merge)
- Tidy up the room
- Waiting for a Bus
Puzzles
Games
Similar Kata:
Stats:
Created | Apr 20, 2016 |
Published | Apr 21, 2016 |
Warriors Trained | 167 |
Total Skips | 0 |
Total Code Submissions | 208 |
Total Times Completed | 80 |
JavaScript Completions | 68 |
Python Completions | 16 |
Total Stars | 3 |
% of votes with a positive feedback rating | 93% of 35 |
Total "Very Satisfied" Votes | 31 |
Total "Somewhat Satisfied" Votes | 3 |
Total "Not Satisfied" Votes | 1 |
Total Rank Assessments | 5 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 6 kyu |