# | Problem | Pass Rate (passed user / total user) |
---|---|---|
14701 | Gold Ship’s quiz |
|
14705 | Prez's puns |
|
Description
Gold Ship want to hold a contest to see who can count words the fastest. Although she knows that no one could count faster than her, her trainer has a secret weapon, and it is you! Please help Trainer-san write a program to beat Gold Ship.
The contest contents is as follows: Given a sentence, turn the words into their lowercase version and return a dictionary containing the count of those words.
Seeing you struggle, Trainer-san gave you this slip of code and a hint to help you:
def count(inStr: str)->dict:
#Write your code here
print(sorted(count(input()).items()))
Hint: Check if key exist in dictionary
With the above code, write a function named "count" that takes a string as a parameter to complete the code and beat Gold Ship!
Comic credit: @NeitheYAGI
Input
Write a function take a string as a parameter.
The words in the string are separated by spaces and will only contain uppercase and lowercase Latin characters.
Output
And return a dictionary containing the count of lowercased version of the words.
Sample Input Download
Sample Output Download
Discuss
Description
Symboli Rudof is trying to find new jokes to tell Air Groove, and she's asking you to inspire her! In order to do that, she's given you a list of sentences.
Your mission is to write a function called "pun" that takes in a list of string and a list of queries and print out the words at the specified index of each sentences to see if it inspires her.
Seeing you so excited to help her, she's also given you a piece of code so you can focus on your main task:
#Write your code here
(line, query) = map(int, input().split())
sentences = []
queries = []
for i in range(line):
sentences.append(input())
for i in range(query):
queries.append(tuple(map(int, input().split())))
pun(sentences, queries)
Input
The function will takes in 2 parameters:
- The first parameter is a list of strings
- The second parameter is a list of tuples (a, b):
- The first item a is the line Symboli Rudolf wants you to start from
- The second item b is the index of the word.
a >= 0, b >= 0
Output
For each tuple (a, b), print out the word at index b from sentence a to the last sentence of the list.
If the number of word in the current sentence is less than or equal to b, print out the last word of the sentence.
Print out an empty line if a is larger than the number of sentences.