Help the bookseller !
Description:
A bookseller has lots of books classified in 26 categories labeled A, B, C, ..., Z
. Each book has a code of at least 3 characters. The 1st character of a code is a capital letter which defines the book category.
In the bookseller's stocklist each code is followed by a space and by a positive integer, which indicates the quantity of books of this code in stock.
Task
You will receive the bookseller's stocklist and a list of categories. Your task is to find the total number of books in the bookseller's stocklist, with the category codes in the list of categories. Note: the codes are in the same order in both lists.
Return the result as a string described in the example below, or as a list of pairs (Haskell/Clojure/Racket/Prolog).
If any of the input lists is empty, return an empty string, or an empty array/list (Clojure/Racket/Prolog).
Example
# the bookseller's stocklist:
"ABART 20", "CDXEF 50", "BKWRK 25", "BTSQZ 89", "DRTYM 60"
# list of categories:
"A", "B", "C", "W"
# result:
"(A : 20) - (B : 114) - (C : 50) - (W : 0)"
Explanation:
- category
A
: 20 books (ABART
) - category
B
: 114 books = 25 (BKWRK
) + 89 (BTSQZ
) - category
C
: 50 books (CDXEF
) - category
W
: 0 books
Similar Kata:
Stats:
Created | Feb 12, 2015 |
Published | Feb 12, 2015 |
Warriors Trained | 96007 |
Total Skips | 25274 |
Total Code Submissions | 210732 |
Total Times Completed | 30907 |
Java Completions | 3988 |
Ruby Completions | 734 |
Python Completions | 7872 |
C# Completions | 1664 |
JavaScript Completions | 7049 |
Clojure Completions | 222 |
Haskell Completions | 330 |
CoffeeScript Completions | 20 |
C++ Completions | 1784 |
PHP Completions | 1197 |
C Completions | 500 |
TypeScript Completions | 1333 |
Swift Completions | 614 |
Crystal Completions | 21 |
R Completions | 126 |
Shell Completions | 116 |
OCaml Completions | 48 |
F# Completions | 73 |
Julia Completions | 48 |
Scala Completions | 209 |
Go Completions | 1252 |
Nim Completions | 20 |
Rust Completions | 771 |
Racket Completions | 27 |
Kotlin Completions | 878 |
Groovy Completions | 57 |
Dart Completions | 537 |
Pascal Completions | 16 |
Lua Completions | 111 |
Perl Completions | 29 |
Elm Completions | 8 |
D Completions | 6 |
Erlang Completions | 7 |
Prolog Completions | 8 |
Total Stars | 1376 |
% of votes with a positive feedback rating | 86% of 3467 |
Total "Very Satisfied" Votes | 2668 |
Total "Somewhat Satisfied" Votes | 646 |
Total "Not Satisfied" Votes | 153 |