subject

Write a Python program . Suppose that there are N events to be held this year. The ith event is scheduled from day si to day ti, and free food is to be served for that event every day from day si to ti (inclusive). Your task is to find out how many days there are in which free food is served by at least one event. Write a function called calculate that takes a list of strings containing the start and end days to solve this problem. Your main function will only read in the inputs and pass those inputs as a list to the calculate function (see the provided template for more information). Example
Let N = 3 events. The first event is held from day 10 to 14, the second event is held from day 13 to 17, and the third event is held from day 25 to 26. The days in which free food is served by at least one event are 10, 11, 12, 13, 14, 15, 16, 17, 25, 26, for a total of 10 days. Note that both events serve free food on days 13 and 14, and therefore they are only counted once. Input The first line the user will supply you is an integer, N, denoting the number of events. Each of the next N lines contains two integers si and ti denoting that the ith event will be held from si to ti (inclusive), and free food is served for all of those days.
Note that both events serve free food on days 13 and 14, and therefore they are only counted once.
Input
The first line the user will supply you is an integer, N, denoting the number of events. Each of the next N lines contains two integers si and ti denoting that the ith event will be held from si to ti (inclusive), and free food is served for all of those days.
Output
The output contains a single integer which denotes the number of days in which free food is served by at least one event. Sample Input: 3 10 14 13 17 25 26 Output: 10

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 17:30
How do you make a lenny face? plz, brailiest to who can answer first.
Answers: 1
question
Computers and Technology, 23.06.2019 14:30
Open this link after reading about ana's situation. complete each sentence using the drop-downs. ana would need a minimum of ato work as a translator. according to job outlook information, the number of jobs for translators willin the future.
Answers: 3
question
Computers and Technology, 23.06.2019 16:30
If i wanted to include a built-in calendar in a document, what option could i select? draw table insert table insert chart quick tables
Answers: 1
question
Computers and Technology, 23.06.2019 21:00
Which task uses a simple parameter?
Answers: 1
You know the right answer?
Write a Python program . Suppose that there are N events to be held this year. The ith event is sche...
Questions
question
English, 20.04.2020 19:19
question
Mathematics, 20.04.2020 19:20
question
Biology, 20.04.2020 19:20
Questions on the website: 13722367