#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.





#14 Calculator


Create a simple calculator that given a string of operators (+ - * and /) and numbers separated by spaces returns the value of that expression


Example:


Calculator.evaluate("2 / 2 + 3 * 4 - 6") // => 7

Remember about the order of operations! Multiplications and divisions have a higher priority and should be performed left-to-right. Additions and subtractions have a lower priority and should also be performed left-to-right.


#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

# Josephus Permutation


This problem takes its name by arguably the most important event in the life of the ancient historian Josephus: according to his tale, he and his 40 soldiers were trapped in a cave by the Romans during a siege.


Refusing to surrender to the enemy, they instead opted for mass suicide, with a twist: they formed a circle and proceeded to kill one man every three, until one last man was left (and that it was supposed to kill himself to end the act).


Well, Josephus and another man were the last two and, as we now know every detail of the story, you may have correctly guessed that they didn't exactly follow through the original idea.


You are now to create a function that returns a Josephus permutation, taking as parameters the initial array/list of items to be permuted as if they were in a circle and counted out every k places until none remained.


Tips and notes: it helps to start counting from 1 up to n, instead of the usual range 0..n-1; k will always be >=1.


For example, with n=7 and k=3 josephus(7,3) should act this way.


[1,2,3,4,5,6,7] - initial sequence

[1,2,4,5,6,7] => 3 is counted out and goes into the result [3]

[1,2,4,5,7] => 6 is counted out and goes into the result [3,6]

[1,4,5,7] => 2 is counted out and goes into the result [3,6,2]

[1,4,5] => 7 is counted out and goes into the result [3,6,2,7]

[1,4] => 5 is counted out and goes into the result [3,6,2,7,5]

[4] => 1 is counted out and goes into the result [3,6,2,7,5,1]

[] => 4 is counted out and goes into the result [3,6,2,7,5,1,4]



So our final result is: josephus([1,2,3,4,5,6,7],3)==[3,6,2,7,5,1,4]




# Take a Number And Sum Its Digits Raised To The Consecutive Powers And ....¡Eureka!!


The number 89 is the first integer with more than one digit that fulfills the property partially introduced in the title of this kata. What's the use of saying "Eureka"? Because this sum gives the same number.


In effect: 89 = 8^1 + 9^2


The next number in having this property is 135.


See this property again: 135 = 1^1 + 3^2 + 5^3


We need a function to collect these numbers, that may receive two integers a, b that defines the range [a, b] (inclusive) and outputs a list of the sorted numbers in the range that fulfills the property described above.


Let's see some cases:


sum_dig_pow(1, 10) == [1, 2, 3, 4, 5, 6, 7, 8, 9]


sum_dig_pow(1, 100) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 89]

If there are no numbers of this kind in the range [a, b] the function should output an empty list.


sum_dig_pow(90, 100) == []

Enjoy it!!



# Sort the odd


You have an array of numbers.

Your task is to sort ascending odd numbers but even numbers must be on their places.


Zero isn't an odd number and you don't need to move it. If you have an empty array, you need to return it.


Example


sortArray([5, 3, 2, 8, 1, 4]) == [1, 3, 2, 8, 5, 4]



2018.03.19


#Find the missing letter


Write a method that takes an array of consecutive (increasing) letters as input and that returns the missing letter in the array.


You will always get an valid array. And it will be always exactly one letter be missing. The length of the array will always be at least 2.

The array will always contain letters in only one case.


Example:


['a','b','c','d','f'] -> 'e'

['O','Q','R','S'] -> 'P'


(Use the English alphabet with 26 letters!)


Have fun coding it and please don't forget to vote and rank this kata! :-)


I have also created other katas. Take a look if you enjoyed this kata!



온라인으로 본 채용 테스트 문제

문제 난이도 자체는 그렇게 어렵진 않았지만 문제가 영어여서 당황


팬그램이란? (그리스어: παν γράμμα 판 그람마[*], '모든 글자'라는 뜻)은 알파벳의 모든 글자들을 사용해서 만든 문장을 뜻하며,

'The quick brown fox jumps over the lazy dog' 와 같은 문장이 팬그램입니다.


목표 : 입력받은 문장이 팬그램인지 판별

소요 시간 : 10분



+ Recent posts