2803 - 2023GEC1506 - 0529 - EXAM 2 Scoreboard

Time

2023/05/29 12:40:00 2023/05/29 15:20:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

12829 - GEC1506 - Basic - WF_Python   

Description

Given a few lines of text, you need to parse it and perform the following requirements.

 

Input

In this assignment, a few lines of text will be given as an input.

Output

You will need to read the given input and calculate the word frequency in the input text.

Then, print out only the bottom 3 as your output results.

For example,

Example

If we get two lines of Input:

'Hello Hello John'

'Hello Bob'

WF value:

'John' is equal to 1

'Bob' is also equal to 1

'Hello' is equal to 3      

Output:

John

Bob

Hello

Print the bottom 3 as your OUTPUT. 

(If values are the same, the order should depend on their appearance order)

 
 
 
 

Sample Input  Download

Sample Output  Download

Tags




Discuss




13234 - GEC1506 - Medium - Verify credit card   

Description

In this problem, you need to process the numerical format of the credit card number to see whether the credit card is real or fake.

 

Assuming that there is a credit card number as 1234567891234563, the digits in the credit card number can show if the card is verified or not.

 

To make sure if the credit card number is verified, we need to follow the rules:

 

1. Make sure you got 15 or 16 digits in total, and list the digits from right to left, such as below:

 

 

2. For each digit, we multiply with 1 or 2. We multiply 1 for the odd digits, and multiply 2 for the even digits:

 

 

3.Sum all the multiplied result. 

 

 

4.As a verified credit card number, the sum of all the digits divided by 10 should be 0.

Input

The first several lines are the possible credit card numbers, such as:

1234567891234563

1234567891234573

1234567891234583

1234567891234593

**Note that: There will be 15 or 16 digits in one line.

Output

The result after the verification process, print out the "verified card numbers" if they are verified.

For the example input here, the output will be:

1234567891234563

 

Sample Input  Download

Sample Output  Download

Tags




Discuss




13235 - GEC1506 - Advanced - Credit card security code   

Description

As credit card is so popular nowadays, the security of credit card is an important issue.

In this problem, you are asked to verify whether the credit card number and its security code match or not.

Input

The input contains

  1. One based number for security encoding; and
  2. One or more lines pairs for credit card information, where each line consists of  a pair of credit card numbers (separated by space) and  security code numbers

17

4024 7603 2331 3208,308
6011 1297 0941 1814,211

You are asked to verify these pairs by following rules:
(Take 1st pair as example)

1. Sum up all the credit card numbers.

4024+7603+2331+3208 = 17166

2. Encode the summed numbers using the following base-decimal format.
e.g.

base=17

17166 =  3 * 173 + 8 * 172 + 6*171 + 13 * 170

With this encoding method, 17166 is then encoded to 38613.

Note that in some cases, we may need more/less than the power of "3" times for the base number to encode.

Hint: You can get the power of the base number by following python code:

>>> result = 17  ** 2

>>>print(result)

289

>>> result = 17  ** 3

>>>print(result)

4913

 

3. The real security code number is the even position of the encoded number (Start from the right).

There are only 3 digits for a credit card security code.

From this example, an additional "0" is necessary to add in the beginning as we only get 2 digits (8 and 1).
The final verified security code is then found as these 3 digits (081).

In other words, if more than 3 digits you got, just keep the rightest 3 ones.
 

4. If the given security code (308) matches the one you encode (081), you return "correct", otherwise, "incorrect"

Output

The output is multiple lines of verification results based on given credit card pairs.

Sample Input  Download

Sample Output  Download

Tags




Discuss




13929 - Bakery Problem   

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:

  1. 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.

  2. 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.

 
 

Sample Input  Download

Sample Output  Download

Tags




Discuss