#38  Highest Scoring Word


Given a string of words, you need to find the highest scoring word.


Each letter of a word scores points according to it's position in the alphabet: a = 1, b = 2, c = 3 etc.


You need to return the highest scoring word as a string.


If two words score the same, return the word that appears earliest in the original string.


All letters will be lowercase and all inputs will be valid.




#25 Find The Parity Outlier



You are given an array (which will have a length of at least 3, but could be very large) containing integers. The array is either entirely comprised of odd integers or entirely comprised of even integers except for a single integer N. Write a method that takes the array as an argument and returns this "outlier" N.


Examples

[2, 4, 0, 100, 4, 11, 2602, 36]

Should return: 11 (the only odd number)


[160, 3, 1719, 19, 11, 13, -21]

Should return: 160 (the only even number)



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

오늘은 하루 쉼  (0) 2018.04.23
codewars #26 lucky number (7kyu)  (1) 2018.04.20
codewars #24 A + B == 123 (6kyu)  (0) 2018.04.18
codewars #23 Prime Streaming (NC-17) (2kyu)  (1) 2018.04.17
codewars #22 Fat Fingers (5kyu)  (0) 2018.04.16

#24 A + B = 123



Task

Given number A you must return number B so that


(int) (A + B) == 123


Note

B can't be negative


:-)



#22 Fat Fingers


Freddy has a really fat left pinky finger, and every time Freddy tries to type an A, he accidentally hits the CapsLock key!


Given a string that Freddy wants to type, emulate the keyboard misses where each A supposedly pressed is replaced with CapsLock, and return the string that Freddy actually types. It doesn't matter if the A in the string is capitalized or not. When CapsLock is enabled, capitalization is reversed, but punctuation is not affected.


Examples:


"The quick brown fox jumps over the lazy dog."

-> "The quick brown fox jumps over the lZY DOG."


"The end of the institution, maintenance, and administration of government, is to secure the existence of the body politic, to protect it, and to furnish the individuals who compose it with the power of enjoying in safety and tranquillity their natural rights, and the blessings of life: and whenever these great objects are not obtained, the people have a right to alter the government, and to take measures necessary for their safety, prosperity and happiness."

-> "The end of the institution, mINTENnce, ND dministrTION OF GOVERNMENT, IS TO SECURE THE EXISTENCE OF THE BODY POLITIC, TO PROTECT IT, nd to furnish the individuLS WHO COMPOSE IT WITH THE POWER OF ENJOYING IN Sfety ND TRnquillity their nTURl rights, ND THE BLESSINGS OF LIFE: nd whenever these greT OBJECTS re not obtINED, THE PEOPLE Hve  RIGHT TO lter the government, ND TO Tke meSURES NECESSry for their sFETY, PROSPERITY nd hPPINESS."


"aAaaaaAaaaAAaAa"

-> ""

If the given string is null, return null.


If the given string is "", the answer should be evident.


Happy coding!



 #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")





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


#13 Anagram Detection


An anagram is the result of rearranging the letters of a word to produce a new word (see wikipedia).


Note: anagrams are case insensitive


Complete the function to return true if the two arguments given are anagrams of theeach other; return false otherwise.


Examples :


"foefet" is an anagram of "toffee"

"Buckethead" is an anagram of "DeathCubeK"



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

Codewars #15 Bagels (4kyu)  (0) 2018.04.06
Codewars #14 Calculator (3kyu)  (0) 2018.04.03
Codewars #12 Range Extraction (4kyu)  (0) 2018.03.30
Codewars #11 Double Cola (5kyu)  (0) 2018.03.30
Codewars #10 Scramblies (5kyu)  (0) 2018.03.28

#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

# Double Cola



Sheldon, Leonard, Penny, Rajesh and Howard are in the queue for a "Double Cola" drink vending machine; there are no other people in the queue. The first one in the queue (Sheldon) buys a can, drinks it and doubles! The resulting two Sheldons go to the end of the queue. Then the next in the queue (Leonard) buys a can, drinks it and gets to the end of the queue as two Leonards, and so on.


For example, Penny drinks the third can of cola and the queue will look like this:


Rajesh, Howard, Sheldon, Sheldon, Leonard, Leonard, Penny, Penny

Write a program that will return the name of the person who will drink the n-th cola.


Note that in the very beginning the queue looks like that:


Sheldon, Leonard, Penny, Rajesh, Howard

##Input


The input data consist of an array which contains at least 1 name, and single integer n.


(1 ≤ n ≤ 1000000000).


##Output / Examples Return the single line — the name of the person who drinks the n-th can of cola. The cans are numbered starting from 1. Please note that you should spell the names like this: "Sheldon", "Leonard", "Penny", "Rajesh", "Howard" (without the quotes). In that order precisely the friends are in the queue initially.


 string[] names = new string[] { "Sheldon", "Leonard", "Penny", "Rajesh", "Howard" };

 int n = 1;

 Line.WhoIsNext(names, n) --> "Sheldon"


 int n = 6;

 Line.WhoIsNext(names, n) --> "Sheldon"


 int n = 52;

 Line.WhoIsNext(names, n) --> "Penny"


 int n = 7230702951;

 Line.WhoIsNext(names, n) --> "Leonard"



# Scramblies


Complete the function scramble(str1, str2) that returns true if a portion of str1 characters can be rearranged to match str2, otherwise returns false.


Notes:


Only lower case letters will be used (a-z). No punctuation or digits will be included.

Performance needs to be considered


Examples

scramble('rkqodlw', 'world') ==> True

scramble('cedewaraaossoqqyt', 'codewars') ==> True

scramble('katas', 'steak') ==> False




+ Recent posts