#43Counting Duplicates


Count the number of Duplicates

Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The input string can be assumed to contain only alphabets (both uppercase and lowercase) and numeric digits.


Example

"abcde" -> 0 # no characters repeats more than once

"aabbcde" -> 2 # 'a' and 'b'

"aabBcde" -> 2 # 'a' occurs twice and 'b' twice (bandB)

"indivisibility" -> 1 # 'i' occurs six times

"Indivisibilities" -> 2 # 'i' occurs seven times and 's' occurs twice

"aA11" -> 2 # 'a' and '1'

"ABBA" -> 2 # 'A' and 'B' each occur twice



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

#3 PANGRAM  (0) 2018.03.08
#2 가챠 - 가중치가 있는 랜덤  (0) 2018.03.07
#1 문자열 역순으로 출력하기  (0) 2018.03.07

#32 Dubstep


Polycarpus works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.


Let's assume that a song consists of some number of words. To make the dubstep remix of this song, Polycarpus inserts a certain number of words "WUB" before the first word of the song (the number may be zero), after the last word (the number may be zero), and between words (at least one between any pair of neighbouring words), and then the boy glues together all the words, including "WUB", in one string and plays the song at the club.


For example, a song with words "I AM X" can transform into a dubstep remix as "WUBWUBIWUBAMWUBWUBX" and cannot transform into "WUBWUBIAMWUBX".


Recently, Jonny has heard Polycarpus's new dubstep track, but since he isn't into modern music, he decided to find out what was the initial song that Polycarpus remixed. Help Jonny restore the original song.


Input

The input consists of a single non-empty string, consisting only of uppercase English letters, the string's length doesn't exceed 200 characters


Output

Return the words of the initial song that Polycarpus used to make a dubsteb remix. Separate the words with a space.


Examples

songDecoder("WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB")

  // =>  WE ARE THE CHAMPIONS MY FRIEND


# 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




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



2018.03.20


#Sum of the first nth term of Series 


Your task is to write a function which returns the sum of following series upto nth term(parameter).


Series: 1 + 1/4 + 1/7 + 1/10 + 1/13 + 1/16 +...


Rules:

- You need to round the answer to 2 decimal places and return it as String.

- If the given value is 0 then it should return 0.00

- You will only be given Natural Numbers as arguments.


Examples:

SeriesSum(1) => 1 = "1.00"

SeriesSum(2) => 1 + 1/4 = "1.25"

SeriesSum(5) => 1 + 1/4 + 1/7 + 1/10 + 1/13 = "1.57"



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!



+ Recent posts