3266 - I2P(I)2025_Chou_Hu_Hw6_ClassB Scoreboard

Time

2025/11/04 20:30:00 2025/11/11 18:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
14792 Daily schedule sort
14808 Busy day

14792 - Daily schedule sort   

Description

You’re an NTHU computer science student, and your schedule is packed with homework, labs, tests, and quizzes. Today you’ve got a lot to do. Worried you might miss something, you decide to put all your activities into a program and sort them by which one happens first. The problem are for every event you have, the time that you use to track the event have 2 different format, 12 hour format (09:00 AM or 12:00 PM) and 24 hour format (00:00 - 23:59). you might need to define a specific funtion to handle these so the sorting method is correct.

You can use this code snippet and complete the functions:

def sort_time_activity(items):
    pass

tokens = input().split(', ')
items = [', '.join(tokens[i:i+2]).strip('"') for i in range(0, len(tokens), 2)]

result = sort_time_activity(items)
print("\n".join(result))

Hint

use map() to map the value of each item, and use sort() and lambda expression to sort it by the value you gave to each item 

Input

got a list of activity for today with one item looks like:

"09:00 PM, study programming", "23:00, meet friends in the bar", "12:00 AM, calculus homework"

with the format "time, activity_name" for every event.

Output

sorted activity by its time from what come first to last:

12:00 AM, calculus homework
09:00 PM, study programming
23:00, meet friends in the bar

Sample Input  Download

Sample Output  Download




Discuss




14808 - Busy day   

Description

Today your stall got so many customer. because the ticket system is broken, you have to make your own queue system. 

in you queue system, you just need to concern 5 functionality:

show():

to show the queue right now (the first got the order to the last)

- push():

to add new customer to the queue system

- pop()

to remove the customer that been served

- size()

to get how long is the queue

- clear()

to clear the queue

 

as we know in the queue system, the first one in the queue will got the order first

given snippet code below:

def queue():
    Q = []

    def show():
        pass

    def push(v):
        pass

    def pop():
        pass

    def size():
        pass

    def clear():
        pass

    D = {
        #fill the command here
    }

    for _ in range(n):
        line = input()

        words = line.split()
        cmd = words[0]
        
        ##call the command here

n = int(input())
queue()

You can review the slide: 17-functional-prog, for another way to write the same logic.

We encouraged you to utilize lambda expression to learn more about it :D

Input

input integer to represent how many command will you do,

the following n lines are one of the 5 command:

push x : (x are integer to be pushed), add the customer to the queue (for simplicity, all customer name are a number)

pop  : remove the customer that been served from the queue (the one that have been in the queue first)

show

size

clear

 

Output

depends on the command:

push: output NOTHING 

pop: output the number that been pop, if the queue is empty, print empty

show: output the list of the customer in the queue

size: print the size of the queue

clear: empty the queue

Sample Input  Download

Sample Output  Download




Discuss