# EVENT Editorial

Primary Tester: Amir Reza PoorAkhavan
Editorialist: Hussain Kara Fallah

Cakewalk

None

### PROBLEM:

Given the name of the day that some contest started at (Saturday, Sunday, Monday…), and the name of the day it was finished. You have to tell if the duration of the contest is some integer in the range [L, R].

If there’s no such number in the range output “none”.

If there’s one number in the range output this number.

If there’s more than one possible number in the range output “many”.

### EXPLANATION:

The minimum possible duration of the contest is the difference in days between the name of the first day and the name of the second. Start with the day of start, and keep counting till you reach the other day. Let’s name this value D.

Now, what are the possible other values?

Clearly, It’s D + 7 * K, where K is an arbitrary non-negative integer (which means that it lasts for K extra full weeks). So we need to check how many values K makes our value D in the range [L,R]. This can be done with simple calculations, or maybe a loop since constraints are small.

### Example:

Consider our sample was “Saturday Sunday 2 4”.

The minimum possible duration of the contest is 2.

Other possible values {9,16,23,30,…etc}.

Only 2 belongs to the interval thus the answer is 2.

### AUTHOR’S AND TESTER’S SOLUTIONS:

AUTHOR’s solution

Editorialist’s solution

PLEASE FIND THE BUG WOEKING FINE IN MY LOCAL MACHINE
import java.util.;
import java.lang.
;
import java.io.*;

/* Name of the class has to be “Main” only if the class is public. */

class Codechef
{
private static Scanner mScanner=new Scanner(System.in);
private static final String IMPOSSIBLE=“impossible”;
private static final String MANY=“many”;
public static void main (String[] args) throws java.lang.Exception

``````{
try {
int noTestCases=Integer.parseInt(mScanner.nextLine());
while(noTestCases-->0)
{
String weekDays=mScanner.nextLine();
int lowestExpectedDay=Integer.parseInt(mScanner.nextLine());
int highestExpectedDay=Integer.parseInt(mScanner.nextLine());
String weekDaysArrys[]=weekDays.split(" ");
int minimumCompetionDays=getMinimumCompetionDays(weekDaysArrys);
if(minimumCompetionDays>highestExpectedDay)
System.out.println(IMPOSSIBLE);
else if((highestExpectedDay-lowestExpectedDay)+1>13)
System.out.println(MANY);
else{
int estimatedDay=minimumCompetionDays;
while(lowestExpectedDay>estimatedDay)
{
estimatedDay=estimatedDay+7;
}
if(estimatedDay>highestExpectedDay)
System.out.println(IMPOSSIBLE);
else
System.out.println(String.valueOf(estimatedDay));
}

}
} catch(Exception e) {
}
}

private static int getMinimumCompetionDays(String[] weekDays){
String startWeekDay=weekDays[0];
String endWeekDay=weekDays[1];
int startWeekDayNo=getWeekDaysInNumber(startWeekDay.toLowerCase());
int endWeekDayNo=getWeekDaysInNumber(endWeekDay.toLowerCase());
if(startWeekDayNo==endWeekDayNo)
return 1;
else
return (endWeekDayNo-startWeekDayNo)+1;

}

private static int getWeekDaysInNumber(String weekDayString){
switch(weekDayString)
{
case "monday":
return 1;

case "tuesday":
return 2;

case "wednesday":
return 3;

case "thursday":
return 4;

case "friday":
return 5;

case "saturday":
return 6;

case "sunday":
return 7;
}
return 1;
}
``````

}

I am not able to find out any issue here in my code.

``````days = ['saturday', 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday']
for i in range(int(input())):
all_dur = list()
S,E,L,R = map(str, input().split())
L = int(L)
R = int(R)
if days.index(S) < days.index(E):
# currently this is minimum duration
dur = (days.index(E) - days.index(S)) + 1
else:
# currently this is minimum duration
dur = (len(days) - (days.index(S) + 1)) + (days.index(E)+1) + 1
while dur <= R and len(all_dur) < 2:
if dur >= L:
all_dur.append(dur)
dur += 7
if len(all_dur) == 1:
print(all_dur[0])
elif len(all_dur) == 0:
print("impossible")
elif len(all_dur) > 1:
print("many")``````

https://www.codechef.com/viewsolution/38281177