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 01:00
What can you find the under the privacy policy section of a shopping website?
Answers: 1
question
Computers and Technology, 23.06.2019 09:20
How to print: number is equal to: 1 and it is odd number number is equal to: 2 and it is even number number is equal to: 3 and it is odd number number is equal to: 4 and it is even number in the console using java using 1 if statement, 1 while loop, 1 else loop also using % to check odds and evens
Answers: 3
question
Computers and Technology, 23.06.2019 10:00
Install and use wireshark program ( send back screen shots and other vital information) case project 3-2: decode a tcp segment in a wireshark capture in this chapter, you walked through tcp segment to interpret the data included in its header. in this project, you use wireshark to capture your own http messafes, examine the tcp headers, and practice interpreting the data you'll find there. 1. open wireshark and snap the window to one side of your screen. open a browser and snap that window to the other side of your screen so you can see both windows.
Answers: 2
question
Computers and Technology, 24.06.2019 01:00
How can the temperature of a room be raised by 5degreesf?
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
Mathematics, 03.01.2021 22:40
question
Mathematics, 03.01.2021 22:40
question
Mathematics, 03.01.2021 22:40
question
Mathematics, 03.01.2021 22:40
question
Mathematics, 03.01.2021 22:40
question
Mathematics, 03.01.2021 22:40
question
Mathematics, 03.01.2021 22:40
question
Social Studies, 03.01.2021 22:40