#18 Convert string to camel case



Complete the method/function so that it converts dash/underscore delimited words into camel casing. The first word within the output should be capitalized only if the original word was capitalized.


Examples:


// returns "theStealthWarrior"

toCamelCase("the-stealth-warrior") 


// returns "TheStealthWarrior"

toCamelCase("The_Stealth_Warrior")





#16 Java format Unicode encoder/decoder 


We need a reusable program to encode/decode text to unicode value as represented in Java and vice-versa.


Encoder:


Input

"hola"


Output

"\u0068\u006f\u006c\u0061"


Decoder:


Input

"\u0068\u006f\u006c\u0061"


Output

"hola"


Observations:

Please note that unicode values have always a back slash \ the letter u and 4 hexadecimal digits corresponding to the value in the unicode character set.

Codewars has some trouble showing non ASCII characters so perhaps you should try it locally first.





#Range Extraction


A format for expressing an ordered list of integers is to use a comma separated list of either


individual integers

or a range of integers denoted by the starting integer separated from the end integer in the range by a dash, '-'. The range includes all integers in the interval including both endpoints. It is not considered a range unless it spans at least 3 numbers. For example ("12, 13, 15-17")

Complete the solution so that it takes a list of integers in increasing order and returns a correctly formatted string in the range format.


Example:


Solution.rangeExtraction(new int[] {-6, -3, -2, -1, 0, 1, 3, 4, 5, 7, 8, 9, 10, 11, 14, 15, 17, 18, 19, 20})

# returns "-6,-3-1,3-5,7-11,14,15,17-20"



'매일매일개발 > Codewars' 카테고리의 다른 글

Codewars #14 Calculator (3kyu)  (0) 2018.04.03
Codewars #13 Anagram Detection (7kyu)  (0) 2018.04.02
Codewars #11 Double Cola (5kyu)  (0) 2018.03.30
Codewars #10 Scramblies (5kyu)  (0) 2018.03.28
Codewars #9 Large Factorials (4kyu)  (0) 2018.03.27

#Calculate String Rotation


Write a function that receives two strings and returns n, where n is equal to the number of characters we should shift the first string forward to match the second.


For instance, take the strings "fatigue" and "tiguefa". In this case, the first string has been rotated 5 characters forward to produce the second string, so 5 would be returned.


If the second string isn't a valid rotation of the first string, the method returns -1.


Examples:

"coffee", "eecoff" => 2

"eecoff", "coffee" => 4

"moose", "Moose" => -1

"isn't", "'tisn" => 2

"Esham", "Esham" => 0

"dog", "god" => -1




+ Recent posts