A bookseller has lots of books classified in 26 categories labeled A, B, ... Z. Each book has a code of 3, 4, 5 or more capitals letters. The first letter of a letter is the capital letter of the book category. In the bookseller's stocklist each code is followed by a space and a positive integer n (int n> = 0) which indicates the quantity of books in this code in stock.
For example an extract of one of the stocklists could be:
L = {"ABART 20", "CDXEF 50", "BKWRK 25", "BTSQZ 89", "DRTYM 60"}.
or
L = ["ABART 20", "CDXEF 50", "BKWRK 25", "BTSQZ 89", "DRTYM 60"] or ....
You will be given a stocklist (L) and a list of categories in capital letters.
M = {"A", "B", "C", "W"}
or
M = ["A", "B", "C", "W"] or ...
and your task is to find all the books of L with codes belonging to each category.
For the lists L and M, you have to return the string (in Haskell / Clojure a list of pairs):
(A: 20) - (B: 114) - (C: 50) - (W: 0)
"BKWRK" and "BTSQZ", 50 corresponding to "CDXEF" and 0 to category 'W', where A, B, C and W are the categories, since there is no code beginning with W.
If L or M are empty return string is "" (Clojure should return an empty array instead).
'매일매일개발 > Codewars' 카테고리의 다른 글
codewars #41 Dashatize it (6kyu) (0) | 2018.05.15 |
---|---|
codewars #40 What's a Perfect Power anyway? (5kyu) (1) | 2018.05.14 |
codewars #38 Highest Scoring Word (6kyu) (1) | 2018.05.09 |
codewars #37 Count the smiley faces! (6kyu) (1) | 2018.05.08 |
codewars #36 The Supermarket Queue (6kyu) (1) | 2018.05.07 |