3238 - I2P(I)2025_Chou_Hu_Lab3_ClassA Scoreboard

Time

2025/09/22 18:00:00 2025/09/22 20:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
14698 A boring article
14720 Domo the manager

14698 - A boring article   

Description

You are helping your friend who is writing an article. Sometimes, they feel their text is too repetitive because the same words appear again and again. To make it more interesting, your friend gives you a dictionary of synonyms.

Your task is to write a program that automatically replaces words with their synonyms whenever possible. If a word does not appear in the dictionary, it should remain unchanged.

Synonym Dictionary given

synonyms = {
    "big": "large",
    "small": "tiny",
    "fast": "quick",
    "slow": "sluggish",
    "happy": "joyful",
    "sad": "unhappy",
    "angry": "furious",
    "good": "great",
    "bad": "awful",
    "hot": "warm",
    "cold": "chilly",
    "smart": "clever",
    "stupid": "dumb",
    "easy": "simple",
    "hard": "difficult",
    "friend": "buddy",
    "enemy": "foe",
    "child": "kid",
    "dog": "puppy",
    "cat": "kitten"
}

Note

You should output the synonym as given in the dictionary (don't make you own synonym dictionary)

 

Input

  • A single line sentence (string).

  • Words are separated by spaces.

  • The input will not contain punctuation, tabs, or newlines — only words and spaces.

Output

  • A single line string where each word is replaced with its synonym (if found in the dictionary).

  • Case of the output word should follow the dictionary (always lowercase as defined).

  • If the word's synonym isn't found in the dictionary preserve it exactly as the input.

  • If the word is in the dictionary matching will be case-insensitive (e.g., BigBIG, and big all map to large).

  • All spaces between words should be preserved exactly as in the input.

There should be '\n' at the end of the output

Sample Input  Download

Sample Output  Download

Tags




Discuss




14720 - Domo the manager   

Description

WiIth the help of I2P(I) students our good friend Domo received a promotion and now is a manager at his company that stores employee information in a CSV (comma-separated values) file. Where each row represents one employee, and each column contains different details such as name, age, and city. Now that our friend is a manager he has a lot more responsibilities to be done.

Previously we only need to extract certain columns to create a smaller report, now Domo needs to be able to combine certain columns, modify its "header" name, and finally merge it to our original csv string.

Write a program that can combine selected columns and modify our own header name which will be merged into our original csv string as a new column. 
 

def merge_col(current_csv, extracted_col):
    #TODO: Merge the combined columns to our original csv string
   
def combine_col(csv, indices, col_name):
    #TODO: Combine the extracted columns with the modified header
   
# Read the CSV input until EOF
csv_lines = []
while True:
    try:
        line = input()
        if line.strip() == "":
            continue
        csv_lines.append(line)
    except EOFError:
        break
#
num_col = int(csv_lines[0])                     #first line number of col
indices = csv_lines[1:num_col+1]                #indices
col_name = csv_lines[num_col+1: 2*num_col+1]    #new colname
 
# Remaining lines = CSV data
csv_str = "\n".join(csv_lines[2*num_col+1:])
new_csv = csv_str
for i in range(num_col):
   #TODO: use the functions to create our new csv string

print(new_csv)

'''
print(num_col)
print(indices)
print(col_name)
print(csv_str)
'''

Input

  • An integer n, where n is the number of new columns that will be merged.
  • Each of the next n lines contains the indices of the columns (separated by spaces) to be combined for that new column.
  • Each of the next n lines contains one new header name.
  • Followed by the CSV content, where:
  • Rows are separated by newline \n Columns are separated by commas ,
  • The first row of the CSV is the header (column names)


Constraints

  • 1 ≤ Number of rows ≤ 1000
  • 1 ≤ Number of columns ≤ 50 Column indices are 0-based Indices CAN be out of the range of the columns
  • To signal EOF you can use Ctrl + Z + Enter (Windows) or Ctrl + D (Linux/Mac) 

Output

  • Output the new CSV string that have been merged with the combined columns.
  • Output Format:
  • Each column must be separated by a comma (',')
  • Each row of the output must end with a newline character ('\n')
  • Do not add extra space at the end of any line For the combined column, combine it with a blank character between each words (' ')
  • Each out-of-range indice is replaced by "N/A" individually. (Indices will be considered out-of-range if the given indices exceed the number of column of the ORIGINAL csv)
  • The very last line of your output should also end with exactly one newline ('\n')

Sample Input  Download

Sample Output  Download

Tags




Discuss