5 kyu

Shortest code : Balance Attraction

Description:

Shortest code : Balance Attraction
(Code length limit: 200 chars)

This is the challenge version of coding three minutes series. If you feel difficult, please complete the simple version

Task

Insert some characters into a string, if there are the same characters in the string, they attract each other.

sc("abc",["b"]) === "abbc"

If there are two or more parts in a string, both have the same character. Character will be added to the shorter character chain.

sc("abbbab",["b"]) === "abbbabb"
sc("ababbb",["b"]) === "abbabbb"

If there are two or more parts in a string, both have the same character, and chains have same length. Character will be added to the left one.

sc("ababab",["b"]) === "abbabab"

If there is no same character in the string, add character to the end of string.

sc("ab",["c"]) === "abc"

input: string str, string array chars,insert chars into str, str and char range is a-z.

output: the str after insert chars

Code length calculation

In javascript, we can't get the user's real code, we can only get the system compiled code. Code length calculation is based the compiled code.

For example:

If you typed sc=x=>x+1
after compile, it will be:sc=function(x){return x+1;}

Series

Puzzles
Games
Restricted

Stats:

CreatedApr 3, 2016
PublishedApr 5, 2016
Warriors Trained275
Total Skips16
Total Code Submissions1179
Total Times Completed63
JavaScript Completions63
Total Stars8
% of votes with a positive feedback rating92% of 33
Total "Very Satisfied" Votes29
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
  • smile67 Avatar
  • kazk Avatar
Ad