Hi, I wrote the code from this question, but I am unable to input anything and get an output for it. Would you please be able to help me change the code in order to be able to run the code and be able to input the specific things in the question and get the right output? Thank you. Question: Dan’s recently announced that he’s teaching n top-secret courses next semester. Instead of enrolling in them through ACORN, students need to email Dan to express their interests. These courses are numbered from 1 to n in some arbitrary order. In particular, if a student named s is interested in taking a course c, they need to send an email to Dan containing the message c s. Note that if a student is interested in taking multiple courses, they need to send multiple emails, one per course. Uponreceivingamessagec s,Danlooksatthelistofstudentsalreadyenrolledin course c. If there’s already a student on the list whose name is too similar to s, Dan assumes s is the same student and ignores the message. Otherwise, he enrolls s in the course. Dan considers two names too similar if and only if they have the same length and differ in at most one letter (note that “a” and “A” are considered the same letter). For example, “Josh” and “Josh” are too similar. “Sam” and “CaM” are too similar as well. However, neither “Max” and “Cat” nor “Ann” and “Anne” are too similar. Dan has a lot of students and teaches a lot of courses. Consequently, it would take him forever to process the messages sent by the students one-by-one manually. Instead, he’s asking you to help him out by writing a program that takes in the messages as the input and outputs, for every course, the list of the students enrolled in that course in the order of their enrolments. Input The first line of the input consists of two space-separated integers n and m, denoting the number of secret courses Dan is teaching next semester and the number of messages sent by the students, respectively. The m messages will be described in the following m lines in chronological order. The i-th line describes the i-th message and consists of an integer c_i followed by a string s_i. This indicates that a student named s_i wants to enrol in course c_i. Output You should output exactly n lines. The i-th line should contain the names of the students enrolled in the i-th course in the order of enrolment (note that the line would be empty if there were no students enrolled in the course). These names should be separated by single spaces. Sample Input 1 2 6 1 alex 1 Alex 2 sam 1 alix 1 Alix 2 caM Sample Output 1 alex sam Sample 1 Explanation The first line of the input indicates that there are 2 courses and 6 messages to process. Dan ignores the second, fourth, fifth, and sixth messages. The second, fourth, and fifth messages are all ignored because “Alex”, “alix”, and “Alix” are all too similar to “alex”. The sixth message is ignored because “caM” is too similar to “sam”. Sample Input 2 3 16 3 jun 3 Jin 1 Li 2 Kitty 2 Josh 3 Bob 1 Dave 2 Jose 1 David 3 Rob 3 Anne 3 Ann 2 Kevin 2 Lara 1 ALI 3 Xin Sample Output 2 Li Dave David ALI Kitty Josh Kevin Lara jun Bob Anne Ann Xin

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question
100%

Hi, I wrote the code from this question, but I am unable to input anything and get an output for it. Would you please be able to help me change the code in order to be able to run the code and be able to input the specific things in the question and get the right output? Thank you.

Question:

Dan’s recently announced that he’s teaching n top-secret courses next semester. Instead of enrolling in them through ACORN, students need to email Dan to express their interests. These courses are numbered from 1 to n in some arbitrary order.

In particular, if a student named s is interested in taking a course c, they need to send an email to Dan containing the message c s. Note that if a student is interested in taking multiple courses, they need to send multiple emails, one per course.

Uponreceivingamessagec s,Danlooksatthelistofstudentsalreadyenrolledin course c. If there’s already a student on the list whose name is too similar to s, Dan assumes s is the same student and ignores the message. Otherwise, he enrolls s in the course.

Dan considers two names too similar if and only if they have the same length and differ in at most one letter (note that “a” and “A” are considered the same letter). For example, “Josh” and “Josh” are too similar. “Sam” and “CaM” are too similar as well. However, neither “Max” and “Cat” nor “Ann” and “Anne” are too similar.

Dan has a lot of students and teaches a lot of courses. Consequently, it would take him forever to process the messages sent by the students one-by-one manually. Instead, he’s asking you to help him out by writing a program that takes in the messages as the input and outputs, for every course, the list of the students enrolled in that course in the order of their enrolments.

Input

The first line of the input consists of two space-separated integers n and m, denoting the number of secret courses Dan is teaching next semester and the number of messages sent by the students, respectively.

The m messages will be described in the following m lines in chronological order. The i-th line describes the i-th message and consists of an integer c_i followed by a string s_i. This indicates that a student named s_i wants to enrol in course c_i.

Output

You should output exactly n lines. The i-th line should contain the names of the students enrolled in the i-th course in the order of enrolment (note that the line would be empty if there were no students enrolled in the course). These names should be separated by single spaces.

Sample Input 1

2 6
1 alex

1 Alex

2 sam

1 alix

1 Alix

2 caM

Sample Output 1

alex

sam

Sample 1 Explanation

The first line of the input indicates that there are 2 courses and 6 messages to process.
Dan ignores the second, fourth, fifth, and sixth messages.

The second, fourth, and fifth messages are all ignored because “Alex”, “alix”, and “Alix” are all too similar to “alex”.
The sixth message is ignored because “caM” is too similar to “sam”.

Sample Input 2

3 16
3 jun
3 Jin
1 Li
2 Kitty
2 Josh
3 Bob
1 Dave
2 Jose
1 David
3 Rob
3 Anne
3 Ann
2 Kevin
2 Lara
1 ALI
3 Xin

Sample Output 2

Li Dave David ALI
Kitty Josh Kevin Lara
jun Bob Anne Ann Xin
15
16
17
18
19
20
21
22
23
24
25
, 26
27
28
29
30
S
A
A
return count
A
if n[i] == name[i]:
match_count
if match_count >= Len (name) - 1:
count = count + 1
# to print the result list
def print line (result):
for i in range(0, len(result)):
print (result[i] end_=" ")
if ___name____
main()
h
# display the output from the course dictionary
def display output(course dict):
match_count + 1
'__main__':
Transcribed Image Text:15 16 17 18 19 20 21 22 23 24 25 , 26 27 28 29 30 S A A return count A if n[i] == name[i]: match_count if match_count >= Len (name) - 1: count = count + 1 # to print the result list def print line (result): for i in range(0, len(result)): print (result[i] end_=" ") if ___name____ main() h # display the output from the course dictionary def display output(course dict): match_count + 1 '__main__':
123
45
6
7
S85REREREREE.
10
11
12
13
14
15
16
17
18
19
20
21
U
# Check if name matches any name in list
def check_if_name_exists(name,
name_list):
A
A
A
name = input()
n = int (input())
name = name.lower()
count = 0
for n in name_list:
match_count = 0
n = n.lower()
if n == name:
count = count + 1
else:
if len (name) == len(n):
for i in range(0, len(n.lower())):
if n[i] == name[i]:
match_count = match_count + 1
if match_count >= len (name) - 1:
count = count + 1
return count
# to print the result list
def print line(result) •
Transcribed Image Text:123 45 6 7 S85REREREREE. 10 11 12 13 14 15 16 17 18 19 20 21 U # Check if name matches any name in list def check_if_name_exists(name, name_list): A A A name = input() n = int (input()) name = name.lower() count = 0 for n in name_list: match_count = 0 n = n.lower() if n == name: count = count + 1 else: if len (name) == len(n): for i in range(0, len(n.lower())): if n[i] == name[i]: match_count = match_count + 1 if match_count >= len (name) - 1: count = count + 1 return count # to print the result list def print line(result) •
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Operators
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education