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 06:30
This technology is used to produce high-quality documents that look good on the computer screen and in print. wiki presentation paint desktop publishing
Answers: 3
question
Computers and Technology, 22.06.2019 09:40
Sarah is having a hard time finding a template for her advertising business that she may be able to use at a later date and also make it available to her colleagues
Answers: 1
question
Computers and Technology, 22.06.2019 10:30
Auniversity wants to install a client-server network. which feature do you think is important for them as they set up the network? sending email blocking multiple people to use the same file low security low set up cost limited access to files
Answers: 1
question
Computers and Technology, 22.06.2019 10:50
Using least squares fitting, you are to fit the data sets to the following models and solve for the parameters ai , where i is the index of the parameter. the input/output data for the systems are linked in the bblearn site. for each of the systems use matlab to plot the supplied data vs. the model fit on one plot. include your code in the solutions. (a) linear fit "lineardata.mat" y=a1x^3 + a2x^2 + a3x + a4 (b) plant fit "plantdata.mat g(s) = a1/(s + a2)
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, 06.07.2019 10:20
question
Mathematics, 06.07.2019 10:20
question
History, 06.07.2019 10:20
Questions on the website: 13722361