Can you explain "sum of the date intervals" means.
If there are still multiple solutions for a group you must choose the one where the sum of the date intervals is a minimum.
Apply DateDiff to the start date and end date of each date interval and sum these values.
Thanks For replay..
GroupId StartDate EndDate interval
1 2012-04-05 00:00:00.000 2012-04-21 00:00:00.000 16
1 2012-04-04 00:00:00.000 2012-04-20 00:00:00.000 16
Here the interval is 16. What is the sum ?
The sum is 32.
The purpose of doing the sum of the date intervals is so that it can be used as a criteria to measure how GOOD the solution is. The lower the value the BETTER the solution. By this is meant that there is less overlapping going on.
For example, if you have interevals 01-10, 20-30, 09-21 and 02-29 then you have two possible soluions: 01-10, 02-29, 20-30 and 01-10, 09-21, 20-30. Applying to sum of the date intervals you would choose the second solution is being BETTER.
But as per puzzle , When the interval is same ,then only we will go for condition 2. thats , sum of interval.
if the interval is same,then we will get the same sum,
then why should we go with condition 2?
(Condition 2 means SUM(Intervals) )
In above Example, your input intervals are 4 ,and you calculated for 3 intervals in each solution.
in the 2nd solution sum is 31. So you are saying 2nd solution is BETTER.
in your solution why u accepted only 3 intervals ?
correct me if am wrong...
The purpose of the challenge is to remove all reduntantly overlapping intervals.
In the challenge description there is the definition of a solution: if you remove any of the date intervals (except for the first and last one) you create a gap. This definition is a little tricky. Try to understand its exact meaning.
Above I showed data with 4 date intervals and two solutions of 3 intervals each. These meet the requirement of a solution. In each case, if I remove the second interval I create a gap.
Both solutions have the same number of date intervals. Thus you must use the sum of the date intervals to determine the best solution. For the first one this is 9+26+9=44. For the second one this is 9+11+9=29. Thus the second one is the better solution.
Hope this makes it clearer.
Thanks for explanation.
For GroupID 1, why isn't this a valid solution?
4-26 (22 days, same as 4-20 + 15-21)
5-24 (19 days)
You solution can only consist of the original date intervals You cannot combine them to form new date intervals. To arrive at a solution all you are allowed to do is remove none or one or more date intervals. When I say 'none' it means your group contains only two date intervals which implies they are the root intervals which cannot be removed.
Managed Windows Shared Hosting by OrcsWeb