Training Site
Sideways banner 8b44c02b768aa359c4d0a2bce3b247c6d7ab888f8b26852e9bfc3659c8c25612

Letter Score

Input: Standard Input (stdin)
Output: Standard Output (stdout)
Memory limit: 100 megabytes
Time limit: 1.0 seconds

There will be a number N on its own line. What follows is a list of N phrases, separated by newlines. Each phrase is a maximum of 25 characters long and there will be no more than 1000 phrases. What follows is a single character on its own line. Output a list of letter scores corresponding to each phrase. A letter score is an integer representing the number of times the given character appears in a phrase.

A phrase may contain spaces. However, 80% is awarded assuming no spaces (e.g. sample 1).

  • Sample Input 1

    4
    apple
    banana
    pear
    lime
    a
    

    Sample Output 1

    1
    3
    1
    0
    
  • Sample Input 2

    3
    apple pear
    lime banana
    tomato
    a
    

    Sample Output 2

    2
    3
    1