# | Problem | Pass Rate (passed user / total user) |
---|---|---|
13881 | Sales Forecast |
|
13904 | Top-3 Genre |
|
13929 | Bakery Problem |
|
Description
Ben is planning to open a pizza store. He wants to predict the sales volume of pizza for a week in order to prepare the ingredients accordingly.
The formula for calculating the sales volume for each day of the week is as follows:
(Note that f1, f2, f3 are factors that could affect the pizza sales. They are all integers)
Monday's predicted volume = 2 * f1 + 3 * f3
Tuesday's predicted volume = 0.2 * f1 + 5 * f3 + 20
Wednesday's predicted volume = 0.5 * f1 + 4 * f3 + 10
Thursday's predicted volume = 0.35 * f1 + 7 * f3 + 20
Friday's predicted volume = 0.2 * f1 + 5 * f2 + 100
Sunday's predicted volume = 0.8 * f1 + 15 * f2 + 105
Ben wants to have a day off on Saturday, so he doesn't need to predict the volume for Saturday.
Additionally, since it's not possible to sell half a pizza, you must round the calculated volume to the nearest whole number.
Note: Use the round()
function to round to the nearest whole number.
Input
Six lines of factors
The format of each line is given as:
f1 f2 f3 for Monday
f1 f2 f3 for Tuesday
f1 f2 f3 for Wednesday
f1 f2 f3 for Thursday
f1 f2 f3 for Friday
f1 f2 f3 for Sunday
Examples are shown below.
1 2 3
2 4 5
5 6 7
8 10 2
4 5 10
7 4 5
Output
The output will be:
Monday:11
Tuesday:45
Wednesday:40
Thursday:37
Friday:126
Sunday:171
Example: Monday's sales volume = (2 * 1) + (3 * 3) = 11
Sample Input Download
Sample Output Download
Tags
Discuss
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.
- If two genres have the same average rating, sort them by their genre names in ascending order(from a to z).
- 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
Description
Max owns a successful pizza store and is now planning to open a new bakery. He needs your help to build a new inventory management system to meet his needs.
You are given two types of information about the inventory:
-
Restock Information: This information starts with the keyword "restock", followed by the ingredient title and the quantity separated by a whitespace. Restock will increase the amount of the ingerdient in the storehouse.
-
Record Information: This information starts with the keyword "record", followed by the product title and the quantity separated by a whitespace. Record would consume the amount of the ingredient to make the product.
There are 4 types of products in this bakery, and each product requires a specific amount of ingredients, as shown in the table below:
Your task is to calculate the remaining quantity of each ingredient in the storehouse based on the restock and record information. Then output the final inventory at the end. If the remaining quantity of an ingredient is zero, it should not be included in the output.
Input
The input consists of multiple lines of text. Each line contains either the restock information or the product record information.
Output
The output should contain the remaining quantity of each ingredient in the warehouse. The remaining quantities should be displayed in lowercase and sorted in alphabetical order. The quantity should have one decimal place (rounded down). If the remaining quantity of an ingredient is zero, it should not be included in the output.