Aptitude

ShareIn calendar problems the question will ask us to find the name of the day for any given date. So, in order to solve the question we have to find whether the given year is a leap year or an ordinary year, we have to find the number of odd days and so on. Let’s start with the important terms and concept that we will use in solving problems.

There are 7 days in a week, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday and Saturday.

There are 365 days in an ordinary year while a leap year has 366 days.

In ordinary year there are 28 days in the month of February. On the other hand, in leap year there are 29 days in the month of February.

There are 52 weeks in a year.

MONTH | DAYS |

January | 31 |

February |
28 29 (leap year) |

March | 31 |

April | 30 |

May | 31 |

June | 30 |

July | 31 |

August | 31 |

September | 30 |

October | 31 |

November | 30 |

December | 31 |

Number of days more than a complete week are called Odd days.

To find the Odd days all we have to do is divide the given number of days by 7. The remainder that we get after division is the Odd days.

For example, if the given number of days is 7, then dividing 7 by 7 we get the remainder 0.

Hence, odd days = 0

Similarly, if the given number of days is 12, then dividing 12 by 7 we get the remainder 5.

Therefore, odd days = 5

This is interesting. If a year is divisible by 4 and is not a century then it is a leap year else an ordinary year.

Example: 2012 was a leap year and so was 2008, 2004 and 2000. However, 2014 is not a leap year.

How do we check whether a given year is a leap year or not? Well, for that we have 2 cases. Let’s look at them one by one.

If the last two digits of a year is not equal to zero and is divisible by 4 then it is definitely a leap year.

For instance, 2012 is a leap year because the last two digits (12) is not equal to zero and 12 is divisible by 4 so, 2012 is a leap year. Similarly, 16 is a leap year.

However, 1990 is not a leap year though the last two digits (90) is not equal to zero but 90 is not divisible by 4.

If the last two digits of the year is equal to zero and the year is divisible by 400 then it is a leap year.

Example, 2000 was a leap year because the last two digits are zeros and 2000 is divisible by 400. Similarly, 1600 was a leap and so was the year 1200.

However, 1000 was not a leap year. This is because even though the last two digits are zero but 1000 is not divisible by 400.

Ok, we have covered odd days and leap year time to look at some important points.

- A leap year has 366 days.
- There are 29 days in February in a leap year.
- There are 52 weeks and 2 odd days in a leap year.
- An ordinary year has 365 days.
- February has 28 days in an ordinary year.
- There are 52 weeks and 1 odd day in an ordinary year.

Odd days help us in finding the day of the week for any given date. So, in this section we will learn to calculate odd days.

We know, for ordinary year there are 365 days and dividing 365 days by 7 we get 1 as remainder. This means for ordinary year we have 1 odd day. Similarly, for a leap year we will have 2 odd days.

Now, let us find the number of odd day in a century.

100 years = 24 leap years + 76 ordinary years

= (24x2) + (76x1) [Odd days]

= 48 + 76

= 124

Divide 124 by 7 we get remainder 5.

Therefore, in 100 years we will have 5 odd days.

Hence, we can calculate the odd days from 200, 300 and 400 years.

100 years = 5 odd days

200 years = 2 x 5 = 10 days = 3 odd days [divide 10 by 7 we get remainder 3]

300 years = 3 x 5 = 15 days = 1 odd days [divide 15 by 7 we get remainder 1]

400 years = 4 x 5 = 20 days + 1 (+1 as 400 is a leap year itself)

= 21 days

= 0 odd days [divide 21 by 7 we get remainder 0]

So, we can create a simple table of odd days.

YEARS | NUMBER OF ODD DAYS |

Ordinary year | 1 |

Leap year | 2 |

100 years | 5 |

200 years | 3 |

300 years | 1 |

400 years | 0 |

Note! Years divisible by 400 like 1200, 1600, 2000 etc. have 0 odd days.

Day of the week is related to the number of odd days.

DAY | Number Of Odd Days |

SUNDAY | 0 |

MONDAY | 1 |

TUESDAY | 2 |

WEDNESDAY | 3 |

THURSDAY | 4 |

FRIDAY | 5 |

SATURDAY | 6 |

**What was the day of the week on 14 ^{th} December 1995?**

To solve this problem we will proceed as follows:

14th December 1995

= 1994 years + period from 1st January 1995 to 14th December 1995

**Step 1:**

Find the base year smaller than or equal to 1995 and multiple of 400.

We have 1600 which is smaller than 1995 and multiple of 400.

Now, find 1994 – 1600

We get, 394 years.

394 years = 300 years + 94 years

**Step 2:**

Find no. of odd days in 300 years and 94 years.

We know that number of odd days in 300 years = 1

So, we have to find number of odd days in 94 years.

94 years = 23 leap years + 71 ordinary years

= (23x2) + (71x1) [odd days]

= 46 + 71

= 117

Divide 117 by 7 we get remainder 5.

No. of odd days in 94 years = 5

Therefore, number of odd days in 394 years

= No. of odd days in 300 years + No. of odd days in 94 years

= 1 + 5

= 6

So, in 1994 we have 6 odd days.

**Step 3:**

Find number of day in the period = 1st January to 14th December 1995

1995 is not a leap year so February has 28 days

Therefore, total number of days

= 31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 14

= 348 days

Divide 348 by 7 we get remainder 5.

So, number of odd days in 348 days = 5

Therefore, total odd days till 14th December 1995

= Odd days in 1994 years + Odd days in 348 days

= 6 + 5

= 11

Divide 11 by 7 we get remainder 4.

**Step 4:**

Using the Odd days table

We get, 4 odd days = Thursday

So, 14th December 1995 was Thursday.

- ES6 - Arrow Function ES6 JavaScript
- PostgreSQL - ALTER Table PostgreSQL
- PostgreSQL - DROP Table PostgreSQL
- PostgreSQL - Database PostgreSQL
- PostgreSQL - CREATE Table PostgreSQL
- PostgreSQL - Data Types PostgreSQL
- Design Patterns - JavaScript - Classes and Objects Design Patterns
- Design Patterns - Getting Started Design Patterns
- PostgreSQL - Getting Started PostgreSQL
- Linux Commands - lsof command to list open files and kill processes Reference Linux