@abx_2109 posted a new topic, subject "NW1 - EDITORIAL". It read:

   ### PROBLEM LINK:
    
    Practice  
    Contest
    
    **Setter :** Mohammad Salik
    
    **Tester :** Hasan Jaddouh
    
    **Editorialist :** Mohammad Salik
    
    ## Difficulty
    
    Cakewalk
    
    ## Prerequisites
    
    None
    
    ## Problem
    
    You are given an integer W and a string S where W is the number of days in the month and S is the first day of the month. You are required to find the frequencies of all the seven days(monday to sunday) in that month.
    
    ## Explanation
    
    Each day of the month will come at least 4 times in a month irrespective of the number of days in that month or the start day.
    
    All 7 days coming 4 times each : 7*4=28
    
    Number of Days left: W-28 (lets denote this by X)
    
    Now we assign the frequency 5 to X days starting from S(The start day)
    
    Rest of the days will be assigned the frequency 4
    
    Alternate Explanation
    
    We run a loop from 1 to W updating the count of days according to the day of start
    [code] 
               for(int i=1;i<=W;i++)
               {
                    count[id]++;
                    id++;
                    if(id==7)
                    {
                       id=0;
                    }
                }
        
    [/code]
    
    where id is initialized according to the first day .
    
    id=0 represents S=mon
    
    id=1 represents S=tues  
    and so on…
    
    count[0] represent frequency of monday
    
    count$[$1] represent frequency of tuesday
    
    and so on…
    
    ## Time Complexity
    
    O(1) per testcase
    
    ## Space Complexity
    
    O(1)
    
    ### AUTHOR'S AND TESTER'S SOLUTIONS:
    
    Author's solution can be found here.  
    Tester's solution can be found here.

Then @ujjawal14 said

    TO @jeioncs
    
    i do not understand what real world implementation u are showing.  
    but look at calendar and see the month of november 2017  
    now add one more day i.e. 31st to november. Now calculate the number of occurance for each day.  
    And remember the starting day is monday here as written in problem statement.
    
    the answer is correct.It doesn't fail in the reality.  
    welcome to help.
    
    adios.

Then @jeioncs (Javier Escudero CS) said

    To @ujjawal14
    
    Perhaps i am missing something, what i want to say is…
    
    **[test data year 2017]**
    [code] 
        12
        31 tues
        28 tues
        31 fri
        30 sun
        31 wed
        30 fri
        31 mon
        31 thurs
        30 sat
        31 tues
        30 thurs
        30 sun
        
    [/code]
    
    **[Solution proposed in the challenge]**
    [code] 
        4 5 5 5 4 4 4 
        4 4 4 4 4 4 4 
        4 4 4 4 5 5 5 
        5 4 4 4 4 4 5 
        4 4 5 5 5 4 4 
        4 4 4 4 5 5 4 
        5 5 5 4 4 4 4 
        4 4 4 5 5 5 4 
        4 4 4 4 4 5 5 
        4 5 5 5 4 4 4 
        4 4 4 5 5 4 4 
        5 4 4 4 4 4 5 
        
    [/code]
    
    **[Solution that i think is correct]**
    [code] 
         5 5 4 4 4 4 5
         4 4 4 4 4 4 4
         4 4 5 5 5 4 4
         4 4 4 4 4 5 5
         5 5 5 4 4 4 4
         4 4 4 5 5 4 4
         5 4 4 4 4 5 5
         4 5 5 5 4 4 4
         4 4 4 4 5 5 4
         5 5 4 4 4 4 5
         4 4 5 5 4 4 4
         4 4 4 4 4 5 5
        
    [/code]
    
    **[Reality]**
    
    on a linux system --> **ncal -M -b -y 2017** or  
    
    
    There is no need to invent days like November 31
    
    I hope this is better explained.
    
    Thanks for your quick answer.
    
    Bye

To which @paranoia replied

    simple pen and paper https://www.codechef.com/viewsolution/16709580

After which, @anon55377985 added

    while (t-- > 0)  
    {
    
    int W=s.nextInt();  
    String str=s.next();
    
    int y=W%7;  
    if (str.equals(“mon”))  
    {  
    if (y==0) System.out.println(“4 4 4 4 4 4 4”);  
    if (y==1)System.out.println(“5 4 4 4 4 4 4”);  
    if (y==2)System.out.println(“5 5 4 4 4 4 4”);  
    if (y==3)System.out.println(“5 5 5 4 4 4 4”);
    [code] 
                }
                if (str.equals("tues"))
                {
                    if (y==0) System.out.println("4 4 4 4 4 4 4");
                    if (y==1) System.out.println("4 5 4 4 4 4 4");
                    if (y==2) System.out.println("4 5 5 4 4 4 4");
                    if (y==3) System.out.println("4 5 5 5 4 4 4");
                }
                if (str.equals("wed"))
                {
                    if (y==0) System.out.println("4 4 4 4 4 4 4");
                    if (y==1) System.out.println("4 4 5 4 4 4 4");
                    if (y==2) System.out.println("4 4 5 5 4 4 4");
                    if (y==3) System.out.println("4 4 5 5 5 4 4");
                }
                if (str.equals("thurs"))
                {
                    if (y==0) System.out.println("4 4 4 4 4 4 4");
                    if (y==1) System.out.println("4 4 4 5 4 4 4");
                    if (y==2) System.out.println("4 4 4 5 5 4 4");
                    if (y==3) System.out.println("4 4 4 5 5 5 4");
                }
                if (str.equals("fri"))
                {
                    if (y==0) System.out.println("4 4 4 4 4 4 4");
                    if (y==1) System.out.println("4 4 4 4 5 4 4");
                    if (y==2) System.out.println("4 4 4 4 5 5 4");
                    if (y==3) System.out.println("4 4 4 4 5 5 5");
                }
                if (str.equals("sat"))
            {
                if (y==0) System.out.println("4 4 4 4 4 4 4");
                if (y==1) System.out.println("4 4 4 4 4 5 4");
                if (y==2) System.out.println("4 4 4 4 4 5 5");
                if (y==3) System.out.println("5 4 4 4 4 5 5");
            }
                if (str.equals("sun"))
                {
                    if (y==0) System.out.println("4 4 4 4 4 4 4");
                    if (y==1) System.out.println("4 4 4 4 4 4 5");
                    if (y==2) System.out.println("5 4 4 4 4 4 5");
                    if (y==3) System.out.println("5 5 4 4 4 4 5");
                }
        
        
        
        
            }
    [/code]

To which @jeioncs (Javier Escudero CS) replied

    I just see now!!!  
    I misinterpreted the problem. The day of the week in not the las day of the month, even the first.
    
    Thanks for the patience an answers!!!
    
    Thanks to @ujjawal14 and @paranoia

@anupam_12 (_the.deadcode) replied

    This is my not so appreciable code:
    [code] 
        //AUTHOR ANUPAM PRAKASH MMMUT
        
    [/code]
    
    #include<bits/stdc++.h>  
    #define ll long long int  
    #define FAST ios8b7c:f320:99b9:690f:4595:cd17:293a:c069sync_with_stdio(0);cin.tie(0);cout.tie(0);  
    using namespace std;
    
    int main()  
    {  
    //your code goes here  
    FAST  
    int t;  
    cin>>t;  
    while(t–)  
    {  
    int mon=0,tue=0,wed=0,thurs=0,fri=0,sat=0,sun=0;  
    int w;cin>>w;  
    string s;cin>>s;  
    if(s==“mon”)  
    {  
    for(int i=1;i<=w;i+=7)  
    if(i<=w)  
    mon++;  
    for(int i=2;i<=w;i+=7)  
    if(i<=w)  
    tue++;  
    for(int i=3;i<=w;i+=7)  
    if(i<=w)  
    wed++;  
    for(int i=4;i<=w;i+=7)  
    if(i<=w)  
    thurs++;  
    for(int i=5;i<=w;i+=7)  
    if(i<=w)  
    fri++;  
    for(int i=6;i<=w;i+=7)  
    if(i<=w)  
    sat++;  
    for(int i=7;i<=w;i+=7)  
    if(i<=w)  
    sun++;  
    }  
    else if(s==“tues”)  
    {  
    for(int i=7;i<=w;i+=7)  
    if(i<=w)  
    mon++;  
    for(int i=1;i<=w;i+=7)  
    if(i<=w)  
    tue++;  
    for(int i=2;i<=w;i+=7)  
    if(i<=w)  
    wed++;  
    for(int i=3;i<=w;i+=7)  
    if(i<=w)  
    thurs++;  
    for(int i=4;i<=w;i+=7)  
    if(i<=w)  
    fri++;  
    for(int i=5;i<=w;i+=7)  
    if(i<=w)  
    sat++;  
    for(int i=6;i<=w;i+=7)  
    if(i<=w)  
    sun++;  
    }  
    else if(s==“wed”)  
    {  
    for(int i=6;i<=w;i+=7)  
    if(i<=w)  
    mon++;  
    for(int i=7;i<=w;i+=7)  
    if(i<=w)  
    tue++;  
    for(int i=1;i<=w;i+=7)  
    if(i<=w)  
    wed++;  
    for(int i=2;i<=w;i+=7)  
    if(i<=w)  
    thurs++;  
    for(int i=3;i<=w;i+=7)  
    if(i<=w)  
    fri++;  
    for(int i=4;i<=w;i+=7)  
    if(i<=w)  
    sat++;  
    for(int i=5;i<=w;i+=7)  
    if(i<=w)  
    sun++;  
    }  
    else if(s==“thurs”)  
    {  
    for(int i=5;i<=w;i+=7)  
    if(i<=w)  
    mon++;  
    for(int i=6;i<=w;i+=7)  
    if(i<=w)  
    tue++;  
    for(int i=7;i<=w;i+=7)  
    if(i<=w)  
    wed++;  
    for(int i=1;i<=w;i+=7)  
    if(i<=w)  
    thurs++;  
    for(int i=2;i<=w;i+=7)  
    if(i<=w)  
    fri++;  
    for(int i=3;i<=w;i+=7)  
    if(i<=w)  
    sat++;  
    for(int i=4;i<=w;i+=7)  
    if(i<=w)  
    sun++;  
    }  
    else if(s==“fri”)  
    {  
    for(int i=4;i<=w;i+=7)  
    if(i<=w)  
    mon++;  
    for(int i=5;i<=w;i+=7)  
    if(i<=w)  
    tue++;  
    for(int i=6;i<=w;i+=7)  
    if(i<=w)  
    wed++;  
    for(int i=7;i<=w;i+=7)  
    if(i<=w)  
    thurs++;  
    for(int i=1;i<=w;i+=7)  
    if(i<=w)  
    fri++;  
    for(int i=2;i<=w;i+=7)  
    if(i<=w)  
    sat++;  
    for(int i=3;i<=w;i+=7)  
    if(i<=w)  
    sun++;  
    }  
    else if(s==“sat”)  
    {  
    for(int i=3;i<=w;i+=7)  
    if(i<=w)  
    mon++;  
    for(int i=4;i<=w;i+=7)  
    if(i<=w)  
    tue++;  
    for(int i=5;i<=w;i+=7)  
    if(i<=w)  
    wed++;  
    for(int i=6;i<=w;i+=7)  
    if(i<=w)  
    thurs++;  
    for(int i=7;i<=w;i+=7)  
    if(i<=w)  
    fri++;  
    for(int i=1;i<=w;i+=7)  
    if(i<=w)  
    sat++;  
    for(int i=2;i<=w;i+=7)  
    if(i<=w)  
    sun++;  
    }  
    else  
    {  
    for(int i=2;i<=w;i+=7)  
    if(i<=w)  
    mon++;  
    for(int i=3;i<=w;i+=7)  
    if(i<=w)  
    tue++;  
    for(int i=4;i<=w;i+=7)  
    if(i<=w)  
    wed++;  
    for(int i=5;i<=w;i+=7)  
    if(i<=w)  
    thurs++;  
    for(int i=6;i<=w;i+=7)  
    if(i<=w)  
    fri++;  
    for(int i=7;i<=w;i+=7)  
    if(i<=w)  
    sat++;  
    for(int i=1;i<=w;i+=7)  
    if(i<=w)  
    sun++;  
    }  
    cout<<mon<<" “<<tue<<” “<<wed<<” “<<thurs<<” “<<fri<<” “<<sat<<” "<<sun<<endl;
    [code] 
        }
        return 0;
        
    [/code]
    
    }

@rohit272000 (Rohit Bajaj) replied

    https://www.codechef.com/viewsolution/33327804  
    can anyone pls tell how to resolve the runtime error NZEC ( on submitting the code)

Then @sanskritim (sanskriti) said

    **t=int(input())  
    for _ in range(t):  
    n,s=input().split()  
    n=int(n)  
    c=n%7  
    count=[4,4,4,4,4,4,4]  
    week=[‘mon',‘tues',‘wed',‘thurs',‘fri',‘sat',‘sun']  
    i=week.index(s)
    [code] 
        for j in range(i,i+c):
            count[j]+=1
        print(" ".join([str(item) for item in count]))**
        
    [/code]
    
    please remind me my mistake

Then @murshid_13 (Sk Murshid Alam) said

    anupam_12:
    
    > w
    
    k=w%7;  
    in this problem there are only 4 possible cases.  
    case1: k = = 0, here all the days of this month will be repeated 4 times each.  
    case2: k = = 1, here all the days of this month will be repeated 4 times each ,except that day will be repeated 5 times, which given in the testcase .  
    case3:k==2,here that day(which will given in the testcase) and next one day(if day = mon, then mon and tue will be repeated 5 times,if day= sun then sun and mon will be repeated 5 times) will be repeated 5 times each and except that two days all days will be repeated 4 times each.  
    case4:k==3,same as case3(if day = mon, then mon ,tue and wed will be repeated 5 times or if day= sun then sun,mon and tue will be repeated 5 times or if day=sat then sat,sun and mon will be repeated 5 times.)
    
    i think this approach is lengthy but very easy and useful to solve this problem


{'source': 'discourse', 'url': 'https://discuss.codechef.com/t/nw1-editorial/17726', 'title': 'NW1 - EDITORIAL', 'views': 3182, 'has_accepted_answer': False, 'word_count': 2106, 'like_count': 0, 'reply_count': 2, 'participant_count': 9, 'posts': 10, 'tags': 'ad-hoc cakewalk editorial ltime55 nw1', 'author': '@abx_2109', 'participants': '@abx_2109, @ujjawal14, @jeioncs (Javier Escudero CS), @paranoia, @anon55377985, @anupam_12 (_the.deadcode), @rohit272000 (Rohit Bajaj), @sanskritim (sanskriti), @murshid_13 (Sk Murshid Alam)', 'image_url': [None], 'created_at': '2017-12-29T21:32:51.000Z', 'last_posted_at': '2022-08-08T17:09:38.316Z'}