Count and total · Easy

Most borrowed book

A library keeps a log of how many times each book was borrowed. The same book can appear on several lines.

Task

Write a prompt that finds the book borrowed the most times in total, and its total.

Output format

<Book name>,<Total>

  • If two books have the same highest total, give the one that appears first in the list.
  • If the list is empty, return NONE.

Your prompt must contain {input}: it is replaced by each test case, just like the hidden tests in a hiring test.

Sample case 1
Input
The Hobbit - Borrowed 4 times
Dune - Borrowed 6 times
The Hobbit - Borrowed 3 times
Output
The Hobbit,7
Sample case 2
Input
Emma - Borrowed 2 times
Ivanhoe - Borrowed 9 times
Emma - Borrowed 1 time
Output
Ivanhoe,9

There are 6 test cases in all; the others are like hidden tests: work out what tricky inputs they might use!

Loading the editor…