2793 - 2023GEC1506 - HW4 Scoreboard

Time

2023/05/01 14:00:00 2023/05/14 23:59:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
13193 GEC1506 - Advanced - TopN longest words
13902 GEC1506 - Basic - Inventory Management
13904 Top-3 Genre

13193 - GEC1506 - Advanced - TopN longest words   

Description

Given a number N  and an article with each word separated by space,

you need to return top-N longest words.

Input

The input contains two parts:

  1. The first line of the input is a number that indicates N numbers of top-N.
  2. The remaining parts of the input (multiple lines) are the content of articles with each word/token separated by SPACE.

2
hello world ! welcome to gec course for exploring world of programming
good luck in the quiz

With these inputs, you need to sort the words based on the following criteria to find the top-N words:

  1. Word length in descending order. You can use function len() , e.g. len('abc') # 3.
  2. If there are words having the same length, sort them again by the sum of the word's code using function ord().
    e.g. ord('a') # 97
  3. If two above values are the same for words, sort these words by their occurrence order.

Output

Print out multiple lines of distinct words in descending order.

Note that

  1. if N is more than the total distinct words, just print out the necessary lines of words.
    e.g. if N=5, but there are only 4 words. You only need to print 4 lines of words as there is no way to print out 5 lines.
  2. if there exists a word that occurs more than 1 time, you don't need to remove the duplicated words when you are counting. That is, the output could have duplicate words.

Sample Input  Download

Sample Output  Download

Tags




Discuss




13902 - GEC1506 - Basic - Inventory Management   

Description

 

Max has opened a pizza store last month but he is not good at managing inventory. He needs your help to build an inventory management system. You are given multiple lines of text that contain information about the products. Each line contains three parts separated by a whitespace: the product title, the indicator ('I' for restock or 'O' for outgoing), and the quantity.

Your task is to calculate the remaining quantity of each product in the storehouse and output the final inventory. If the remaining quantity of a product is zero, do not include it in the output. If two product titles are the same in lowercase, they should be considered the same product.


 

Input

 

The input consists of multiple lines of text. Each line contains a product title, an indicator, and a quantity separated by a whitespace.

  • 1 <= len(Product title) <= 10^2
  • -10^3 <= quantity <= 10^3
  • If the name is same in lowercase, they should be consider the same product.

Output

 

The output should contain the remaining quantity of each product in the warehouse. If the remaining quantity of a product is zero, do not include it in the output. The product title should be displayed in lowercase. The output should be in the order that the product title first appeared in the input.

Sample Input  Download

Sample Output  Download

Tags




Discuss




13904 - Top-3 Genre   

Description

A movie streaming platform has a list of movies, each with multiple genres and a user rating. Your task is to analyze the given data and find the top 3 genres with the highest average rating across all movies. Additionally, calculate the average rating for each genre.

 

Input

A multi-line string, where each line represents a movie's title, genres, and user rating, separated by commas. The movie's title is a string, genres are lowercase letters (a-z) separated by a vertical bar (|), and the user rating is a float. The number of lines in the input is n (1 ≤ n ≤ 10^4), and the user rating is in the range of [0, 10].

 

 

Output

A multi-line string, where each line represents the genre and its average rating. The output should include only the top 3 genres with the highest average ratings.

  1. If two genres have the same average rating, sort them by their genre names in ascending order(from a to z).
  2. The score should have 2 decimals. (truncate to the second decimal place, elaborate below)

 

Noted, If you directly use %.2f to cut the number, the number will be rounded up.

For example:

eg = 7.9775609756097534

formatted_eg = String(format: "%.2f", eg)

formatted_eg will be 7.98 instead of 7.97

 

Here is the hint you can use in your code

number = 7.9775609756097534 
truncated_number = int(number * 100) / 100
truncated_number = "{:.2f}".format(truncated_number)

print(truncated_number) // truncated_number will be 7.97

Sample Input  Download

Sample Output  Download

Tags




Discuss