Coder Life Matters Codechef Solution

Coders/programmers are the backbone of the new age society (though whether they themselves have a strong back bone is debatable :P). As some wise man said, a task stops being fun when someone starts paying you to do it and commands you. Similarly, though coding is quite fun, in a corporate setting, if the coders work continuously without breaks, they will soon get tired and bored.

You have data about the activities of a programmer over the month of April (which, in case you didn’t know, has exactly 30 days). For each day, you know whether the programmer coded on that day or not. If the coder codes consecutively for more than 5 days, she gets bored. Given the activities of the programmer, tell whether she is always a happy person or whether she has gotten bored at some point. If she has been bored, you should support her by outputting “#coderlifematters”, otherwise output “#allcodersarefun”.

Input

The first line of the input contains an integer T denoting the number of test cases. The description of T cases follow.

The only line of each test case contains 30 space separated boolean integers denoting whether the coder programmed on that day of the month or not. 1 signifies that she coded on that day, and a 0 denotes that she did not.

Output

For each test case, output in a single line “#coderlifematters” if the coder has been bored. If not, output “#allcodersarefun”.

Constraints

  • 1 ≤ T ≤ 1000

Example

Input
4
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 1 1 0 0 1 1 1 1 1 0 0 1 1 1 1 1 0 0 1 1 1 1 1 0 0 1 1
1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 0 0 1 1

Output
#coderlifematters
#allcodersarefun
#allcodersarefun
#coderlifematters

Explanation

Testcase 1: The coder is working all days in the month. She is very bored.

Testcase 2: The coder didn’t work any day during the month. We shouldn’t call such a person a coder, but what matters is that she has a job and she is happy and we should chant #allcodersarefun

Testcase 3: This is a typical professional coder. She works hard for 5 days, takes a break for 2 days and then works again. She is happy, so why should we be worried, let us chant #allcodersarefun

Testcase 4: This seems like a curious case of a programmer, she works 7 days and rests 7 days. Even if she rests well, but as she works for more than 5 days consecutively, her life is still boring (as she doesn’t get to party on weekends). So, we shall say #coderlifematters

Coder Life Matters   – CodeChef Solution in JAVA

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
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		while(t-->0){
		    int count=0;
		    int arr[]=new int[30];
		    for(int i=0;i<30;i++){
		        arr[i]=sc.nextInt();
		    }
		    for(int i=0;i<25;i++){
		        
		            if(arr[i]==1 && arr[i+1]==1 && arr[i+2]==1&& arr[i+3]==1&& 
		            arr[i+4]==1 && arr[i+5]==1){
		                count=1;
		                break;
		           
		        }
		    }
		    System.out.println(count==0 ? "#allcodersarefun" : "#coderlifematters");
		    
		}
	}
}

Coder Life Matters – CodeChef Solution in CPP

#include <iostream>
using namespace std;

int main() {
	int t;
	cin>>t;
	while(t--){
	    int arr[30];
	    for(int i=0; i<30; i++)
	        cin>>arr[i];
	    int count=1,max=0;
	    for(int i=0; i<30; i++){
	        if(arr[i]==1 && arr[i+1]==1 && i<29){
	            count++;
	            if(count>max)
	                max=count;
	        }
	        else if(arr[i]==0)
	            count=1;
	    }
	    if(max>5)
	        cout<<"#coderlifematters"<<endl;
	    else
	        cout<<"#allcodersarefun"<<endl;
	}
	return 0;
}

Coder Life Matters -CodeChef Solution in Python

t=int(input())
for i in range(t):
    l = list(map(int,input().split()))
    c = 0
    for i in range(len(l)-5):
        if l[i] == l[i+1] == l[i+2] == l[i+3] == l[i+4] == l[i+5] == 1:
            print("#coderlifematters")
            c += 1
            break
    if c == 0:
        print("#allcodersarefun")
 

Disclaimer: The above Problem (Coder Life Matters) is generated by CodeChef but the solution is provided by Codeworld19.This tutorial is only for Educational and Learning purpose.

Leave a Reply

Your email address will not be published. Required fields are marked *