FunctionRacerProblemsRace

Tally Counter

BeginnerClassesPython, JavaScript, TypeScript, Java, C++

Implement a class TallyCounter that keeps tally marks next to names, like a clipboard at a club vote. Write these methods:

The tests call the methods in sequence and compare every return value. The expected list holds null for the constructor.

Example 1

TallyCounter()
mark("ann") returns 1
mark("bo") returns 1
mark("ann") returns 2
count_for("ann") returns 2
erase("bo") returns true
count_for("bo") returns 0
get_total() returns 2

ann gets two marks and bo one. Erasing bo works and leaves bo at 0, so the total is 2.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Classes problems