Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
A particular month has 30 days, numbered from 1 to 30.
Day 1 is a Monday, and the usual 7-day week is followed (so day 2 is Tuesday, day 3 is Wednesday, and so on).
Every Saturday and Sunday is a holiday. There are N festival days, which are also holidays. Note that it is possible for a festival day to occur on a Saturday or Sunday.
You are given the dates of the festivals. Determine the total number of holidays in this month.
For each test case, output a new line containing the total number of holidays.
Input:
3
2
5 7
3
23 1 6
1
13
Output:
9
10
8
Test Case 1: Days 6,13,20 and 27 are Saturdays, and days 7,14,21,28 are Sundays. The festivals fall on day 5 and day 7, but day 7 is already a Sunday. This gives us 9 holidays in total — days 5,6,7,13,14,20,21,27,28.
Test Case 2: Days 6,13,20 and 27 are Saturdays, and days 7,14,21,28 are Sundays. The festivals fall on day 1, day 6, and day 23. This gives us 10 holidays in total — days 1,6,7,13,14,20,21,23,27,28.
Test Case 3: Days 6,13,20 and 27 are Saturdays, and days 7,14,21,28 are Sundays. The only festival is on day 13, which is already a holiday. This gives us 8 holidays in total — days 6,7,13,14,20,21,27,28.
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--){
int n,count=0;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<n;i++){
if (a[i]%7==0 || (a[i]+1)%7==0){
count++;
}
}
cout<<8+n-count<<endl;
}
return 0;
}
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int,input().split()))
l = [6,7,13,14,20,21,27,28]
for i in a:
if i not in l:
l.append(i)
print(len(l))
/* package codechef; // don't place package name! */
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 n=sc.nextInt();
for(int i=0;i<n;i++)
{
int h=8;
int f=sc.nextInt();
for (int j=0;j<f;j++)
{
int k=sc.nextInt();
if(k!=6&&k!=7&&k!=13&&k!=14&&k!=20&&k!=21&&k!=27&&k!=28)
{
h++;
}
}
System.out.println(h);
}
}
}
In our experience, we suggest you solve this Count the Holidays CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the Count the Holidays CodeChef Solution
I hope this Count the Holidays CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Coding Solutions >>