# How does Tomohiko Sakamoto’s Algorithm work?

Let us start with the simple scenario in which leap years did not exist and every year had 365 days.

Knowing  what day January 1 falls on a certain year, it is easy to find which  day any other date falls. This is how you go about it : January has 31 =  7 × 4 + 3 days, so February 1 will fall on the day which follows three  days after January 1. Similarly, March 1 will fall on the day three days  after the day corresponding to January 1, April 1 will fall 6 days  after, and so on. Thus, the first days of each month are offset with  respect to January 1 by the array {0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5}.  This array is essentially what t[] is. Notice that it is slightly  different from the t[] given in the question, but that is due to leap  years and will be explained later. Once the day corresponding to the  first date of the month is known, finding the day for any other date is  just a matter of addition.

Since  365 = 7 × 52 + 1, the day corresponding to a given date will become  incremented by 1 every year. For example, July 14, 2014 is a Monday and  July 14, 2015 will be a Tuesday. Hence adding the difference between  year numbers allows us to switch from the day of a reference year to any  other year.

At this stage, the leap-year free dow function can be written as such:

 1 2 3 4 int dow(int y, int m, int d){   static int t[] = {0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5};   return (y + t[m-1] + d + c) % 7; }

Here  c is a constant which corresponds to setting the "origin" of the day  system : y, t[m] and d only tell us how many days to shift by; we need a  reference to start the shifting and which is provided by c.

Now  let us look at the real case when there are leap years. Every 4 years,  our calculation will gain one extra day. Except every 100 years when it  doesn't. Except every 400 years when it does (Seriously, what kind of  intelligent designer comes up with this stuff? Couldn't the duration of  the year have been an integer multiple of the synodic day?). How do we  put in these additional days? Well, just add y/4 – y/100 + y/400. Note  that all division is integer division. This adds exactly the required  number of leap days.

Except  there is a tiny problem. The leap day is not January 0, it is February  29. This means that the current year should not be counted for the leap  day calculation for the first two months.

How  do we do this? Well, there are probably many intuitive ways to go about  this. But this piece of code sacrifices intuition for brevity. Suppose  that if the month were January or February, we subtracted 1 from the  year. This means that during these months, the y/4 value would be that  of the previous year and would not be counted.

Smart,  right? Except for a tiny problem. We are subtracting 1 from the year  for January and February for non-leap years too. This means that there  would be a "blank" day between February 28 and March 1, that is, we have  made every non-leap year a leap year, and leap years double-leap years.  Hm, so what if we subtracted 1 from the t[] values of every month after  February? That would fill the gap, and the leap year problem is solved.  That is, we need to make the following changes:

• t[] now becomes {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}
• if m corresponds to Jan/Feb (that is, m<3) we decrement y by 1
• the annual increment inside the modulus is now y + y/4 – y/100 + y/400 in place of y

That's it, we get the full solution

 1 2 3 4 5 int dow(int y, int m, int d){   static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};   y -= m < 3;   return (y + y/4 - y/100 + y/400 + t[m-1] + d + c) % 7; }

Coincidentially, c just happens to be 0 – this is an empirical fact and cannot be "derived" from anything we have done till now – and we get back the function in the question.

PS: If I were you, I would substitute this for something way simpler. Say, hardcode the day value of January 1, 2000 and propagate differences over years, months and days. If a 3 line code requires a 1 page explanation, it is not really "simple"

How does Tomohiko Sakamoto's Algorithm work?

# What is the difference between developer, engineer, programmer, coder, architect, and consultant?

• A programmer knows how to program computers.
• A developer is a programmer who sits in a cubicle and gets paid for it.
• A coder is a programmer who sits on a beanbag listening to techno in a black T-shirt and gets paid for it.
• An architect is a programmer who thinks up something really big for the other programmers to program, and gets paid for it
• A consultant was a programmer, but now wears a suit and tells developers, coders, and architects how they ought to develop, code and architect, and gets paid a lot for it.

What is the difference between developer, engineer, programmer, coder, architect, and consultant?

# What is the story of Vanila Ice Cream that made General Motors Crazy?

An Interesting Story

Never underestimate your Clients’ Complaint, no matter how funny it might
seem!

This is a real story that happened between the customer of General Motors
and its Customer-Care Executive………

A complaint was received by the Pontiac Division of General Motors:
‘This is the second time I have written to you, and I don’t blame you for
not answering me, because I sounded crazy, but it is a fact that we have a
tradition in our family of Ice-Cream for dessert after dinner each night,
but the kind of ice cream varies so, every night, after we’ve eaten, the
whole family votes on which kind of ice cream we should have and I drive
down to the store to get it. It’s also a fact that I recently purchased a
new Pontiac and since then my trips to the store have created a
problem…..

You see, every time I buy a vanilla ice-cream, when I start back from the
store my car won’t start. If I get any other kind of ice cream, the car
matter how silly it sounds “What is there about a Pontiac that makes it not
start when I get vanilla ice cream, and easy to start whenever I get any
other kind?” The Pontiac President was understandably skeptical about the
letter, but sent an Engineer to check it out anyway.

The latter was surprised to be greeted by a successful, obviously well
educated man in a fine neighborhood. He had arranged to meet the man just after dinner time, so the two hopped into the car and drove to the ice
cream store. It was vanilla ice cream that night and, sure enough, after
they came back to the car, it wouldn’t start.

The Engineer returned for three more nights. The first night, they got
chocolate. The car started. The second night, he got strawberry. The car
started. The third night he ordered vanilla. The car failed to start.

Now the engineer, being a logical man, refused to believe that this man’s
car was allergic to vanilla ice cream. He arranged, therefore, to continue
his visits for as long as it took to solve the problem. And toward this end
he began to take notes: He jotted down all sorts of data: time of day, type
of gas uses, time to drive back and forth etc.

In a short time, he had a clue: the man took less time to buy vanilla than
any other flavor. Why? The answer was in the layout of the store. Vanilla,
being the most popular flavor, was in a separate case at the front of the
store for quick pickup. All the other flavors were kept in the back of the
store at a different counter where it took considerably longer to check out
the flavor.

Now, the question for the Engineer was why the car wouldn’t start when it
took less time. Eureka – Time was now the problem – not the vanilla ice
cream!!!! The engineer quickly came up with the answer: “vapor lock”.
It was happening every night; but the extra time taken to get the other
flavors allowed the engine to cool down sufficiently to start. When the man
got vanilla, the engine was still too hot for the vapor lock to dissipate.
Even crazy looking problems are sometimes real and all problems seem to be
simple only when we find the solution, with cool thinking.

Nothing is “IMPOSSIBLE” without putting a sincere effort. What really matters is your attitude and your perception.

Moral of the Story “Try to Fix the Bug , instead of making it as a Known
Issue”.

Real Great Story!

What is the story of Vanila Ice Cream that made General Motors Crazy?

# Is there any history/logic behind the common superstitions followed/prevailed in India?

1. CATS CROSSING YOUR PATHIn ancient times, during night people used to travel through forests in bullock carts with a light of kerosene lantern. The carriage animals get past big cats like leopards, hyenas and jackals foxes. These animals have glowing eyes and scare the cows, horses or the bulls that pull the carts. That is why the travelling party halts nearby and help the animals refresh themselves before they pull the carts for the long journey ahead without any stress. Travelers shared their hard experiences and told other travelers not to proceed travel while the cats crossing the roads and in the course of time changing, the cat crossings got live and the people forget forest cats and took the domestic cats instead.
2. HAIR CUT ON TUESDAY : In past days a large portion of the Indians were farmers. After a week of hard work, Monday was their resting day. Characteristically majority of them cleaned their homes and cut their hair on that day. So the Barber wouldn’t have much deal with Tuesdays and would close his shop. This practice is continued till date but the reason behind it is completely forgotten and lot misconceptions revolve around this.

3. OPENING AN UMBRELLA INSIDE THE HOUSE : Restriction of opening umbrella inside house had a sensible reason back in the days. The umbrellas were built with hard metal spokes and spring triggers, which could be dangerous to open. In fact, opening one indoors could pose a danger to people and fragile objects nearby.
Warning people not to open an umbrella indoors served to protect the health and safety of people and property indoors. Later this was considered as “bad luck” considering the injuries and broken objects, which often coincided with the umbrella’s opening.

4. HANGING LEMON AND SEVEN GREEN CHILLIES IN SHOPS AND BUSINESS PLACES :                                                                                                                                                                            Scientific ReasonThe cotton thread which is used to pierce the chillies and lemon absorbs the acid from the fruit whilst it is fresh. This smell keeps the pests and insects away from the shops. This is a simple pesticide which came into practice from ancient times, which is mislead now superstitiously as explained above.                                                                                                                                                    Superstitious belief goes like this: Alakshmi, god of misfortune brings bad luck to the shop owners or business. In order not to allow her entering the shops they hang these 7 chilies and lemon. Alakshmi likes sour, pungent and hot things. Therefore at the door, Alakshmi will only come up to the door and eat her favorite food and satisfy her hunger and leave without entering the shop. It is believed that after consuming lemon and green chillies, Alakshmi loses her urge to enter the house or shop. She will turn around without casting her vicious eye.

5. BREAKING MIRROR BRINGS SEVEN YEARS BAD LUCK :During old times, mirrors were not cheap and they were low quality and easily defected. In order to avoid negligence it was told that breaking a mirror brings seven years of bad luck. That was simple scare tactic. Romans were the one who tagged to the broken mirror a sign of seven years bad luck. The length of the prescribed misfortune came from the ancient Roman belief that it took seven years for life to renew itself. If the person looking into the mirror were not of good health, their image would break the mirror and the run of bad luck would continue for the period of seven years, at the end of which their life would be renewed, their body would be physically rejuvenated, and the curse would be ended.

6. CUTTING NAILS AND SHAVING AFTER SUNSET : In the olden days there was no electricity and shaving or cutting nails would result in cuts after sunset because of darkness. Hence our ancestors advised not to cut nails or shave after sunset. In Later days it was believed that the night spirits will be awaken and come in the search of flesh. People have been warned to get attacked by these evil spirits in the darkness of night if people cut nails or shave hair after sunset which continues as a superstition.

7. MENSTRUATING WOMEN ARE CONSIDERED IMPURE AND UNCLEAN : In India, menstruating women are considered impure and unclean. This, of course, gives rise to many superstitious beliefs. Women who are menstruating are not allowed to enter the kitchen. They are also supposed to stay away from temples, mosques and all religious spots in the house itself. A woman on her period is not allowed to perform regular household duties like cooking food. Some might argue that the reason behind this superstition is scientific, and that a woman menstruating loses a lot of blood and thus becomes weak and must refrain from strenuous activities. Others claim that there is nothing scientific in this belief and it is just another superstition created to subordinate the position of women in society. Anyway, there are many explanations about this which has got something to do with Draupadi and other history. Well, if you want to know more and get into the details of the history, check this out Why Menstruating Women Are Considered Impure In Hinduism?

8. DO NOT LEAVE A DEAD PERSON'S EYES OPEN: This is a very common superstitious belief in India,  if a dead person’s eyes is left open it is believed that the other soul around the dead body will be taken away with him through his eyes. But the real reason behind this is to make the dead person look as if he is sleeping peacefully and nothing more or less.

9. LIZARD FALLING ON HUMAN IS BAD LUCK : Every movement of the wall lizard holds some significance according to Gowli Shastra in India. The colour, spots, stripes, chirping or twittering of the lizard and where it falls on a person’s body are said to indicate future happenings. However the fact is that, lizards that are poisonous in nature release poisonous chemicals from their body in order to protect them from their enemies. If such lizard comes in contact of a person’s body or falls in a food item like milk etc. then is bound to make it contaminated. One should wash that particular spot and area to avoid infectious disease.

10. FRIDAY THE 13th AND NUMBER 13 IS UNLUCKY : The number 13 is considered an unlucky number in some countries. The superstitious sufferers try to avoid bad luck by keeping away from anything numbered or labelled thirteen. As a result, companies and manufacturers use another way of numbering or labelling to avoid the number, with hotels and tall buildings being conspicuous examples (thirteenth floor). It is also considered unlucky to have thirteen guests at a table. Friday the 13th has been considered the unluckiest day of the month.
One major reason is that, at Jesus Christ’s last supper, there were thirteen people around the table, counting Christ and the twelve apostles. Some believe this unlucky because one of those thirteen, Judas Iscariot, was the betrayer of Jesus Christ. Another major reason for Friday the 13, On Friday 13 October 1307, King Philip IV of France ordered the arrest of the Knights Templar, and most of the knights were tortured and killed.
11. FALLEN HAIR AROUND THE HOUSE WILL BRING FIGHT IN YOUR FAMILY : The myth is that if you throw fallen hair inside the house instead of binning it, soon you will see a fight within your family. Well, who would like to pick up a quarrel at home?
But the real reason behind this superstition is if you leave the fallen hair inside the house it may end up falling inside the food when the wind blows.

12. TWITCHING OF THE EYE IS INAUSPICIOUS : Twitching of the left eye is considered to be either a bad or a good omen, depending upon which culture we are referring to. These superstitions take into account the gender and the part of the eye in which the twitching is observed as well. Eye twitching or the sudden involuntary movement or spasms in the eyelids is a common condition. Although there is an established explanation for these constant or intermittent involuntary muscle twitches, including various medical reasons behind them. Apparently, these twitches are nature’s way of warning a person about some impending problem or indicative of some good news on the way.

13. ADDING ONE RUPEE TO A GIFT SUM IS AUSPICIOUS : It is common in India to give money for weddings and auspicious occasions. It is considered auspicious to add a rupee to the sum total.
There are various reasons, for some, it is a blessing, a token of love and luck. For some it is the beginning of a new cycle. For some it makes the sum an odd number and indivisible which is a good omen for the married couple. If the rupee is not added the sum total will be separable or it will end in zero which indicates the end, so adding the rupee will make the number odd hence assuring continuity.

14. DO NOT SWEEP THE HOUSE AFTER SUNSET : This is another common myth in India. If you sweep your house after sunset Lakshmi will walk out of the house and hence inviting poverty.
But the real reason behind this is back in the days when there was no electricity, light of lamp was not enough to spot any small gold ornaments while sweeping and hence chances of sweeping them away with the dust is high. Hence it was not advised to sweep after dark.
15. NOT EATING NON-VEG ON PARTICULAR DAYS IN A WEEK:  Hindus do not eat meat on particular days, not limited but including:
Mondays, Thursdays, and Saturdays of every week, many more auspicious days like Yekadashi,
Sankranti, Dussera, Sankashti Chaturthi, Angarki Chaturthi, Ekadashi, Gudhipadwa, Akshaytrutiya, Diwali (all the days).

Amongst these, the reason for not eating meat on some particular days excluding weekly days is purely religious. Killing of animals is considered as a sin in Hinduism. So, people avoid eating meat at least on those auspicious days to maintain sacredness of that particular day.
The reason behind not eating meat on weekdays including Mondays, Thursdays, and Saturdays is that as a human being we need only a little amount of meat to fulfill requirements of our body such as iron, vitamin B12 and other vital nutrients. But human being basically is also like an animal and we can get addicted to eating meat. As we all know eating excessive meat is not good for health.
It can cause diseases like piles, kidney stones, colon cancer, blood pressure, heart attack, etc.
Then also people cannot refrain themselves from eating flesh. Therefore, Hinduism has placed some restrictions by assigning the days to particular diet.
E.g. Monday is dedicated to Lord Shiva, Tuesday to Lord Hanuman, Thursday to Lord Dattatreya and Lord SaiBaba,  and Saturday to Lord Hanuman, Lord Venkateswara.

16. CONSUMING CURD AND SUGAR BEFORE HEADING OUT:   Curd contains calcium and proteins and a bit of natural sugar present in small quantities. Because it is easy on the stomach and the digestive system, it's a great option to consume it before stepping out. It also have the similar calming effect, to be consumed before any stressful activity!

17. BATHE AFTER ATTENDING A FUNERAL CEREMONY:  Contrary to the popular belief, bath after attending a funeral ceremony has nothing to do with evil spirits. Rather, once a person is dead, the body starts to decompose. The people who attend the funeral are exposed to the dead body and hence the bacteria that participate in the decomposition of a dead body. That is the reason why they are asked to bathe immediately after the funeral, before touching anything or anyone.

These are some of the interesting ones I could come up with. I think the question has been answered with appropriate points.

## These reasons are not something I made up or I specifically believe. I took the pain of searching the reason behind each superstition because I found the question interesting and I myself wanted to know. So, if you want the proof, search on the internet or if your parent is a doctor like mine, that'll help you in understanding too

Thankyou Sarthy TJ ji and Sumit Burnwal ji for the suggestions. I've added them

Source: Internet

Cheers!

Is there any history/logic behind the common superstitions followed/prevailed in India?

# As an Indian Muslim, what do you wish Hindus knew?

Date:15th April 2015

My dad came late from his job and switched on the TV.

He laid back on his favorite chair and started browsing different channels on television.

Finally he decided to stick some news channel. One of them was showing a report and a visual showing some Kashmiris shouting : " Meri jaan Meri jaan ….. Pakistan Pakistan…. "

Immediate reaction of my father : "Send these a**holes to Pakistan. They don't deserve to breath the air of this great land."

After that my respect for my Father increased by a zillion factor!!!!!

"A proud Indian"

As an Indian Muslim, what do you wish Hindus knew?