Tuesday, December 31, 2013

Puzzle Time

Its amazing that in day to day life in office and discussion with colleges churn out some really interesting knowledge bits and these bits sometimes vibrate quite a bit of threads in your head. Here are some of those bits.
** River crossing: she-goat, wolf and cabbage 


A farmer is returning from market, where he bought a she-goat, a wolf and cabbage. On the way home he must cross a river. His boat is little, allowing him to take only one of the three things. He can’t keep the she-goat and the cabbage together (because the she-goat would eat it), nor the she-goat with the wolf (because the she-goat would be eaten). How shall the farmer get everything on the other side (without any harm)?


farmer crosses with goat
farmer returns alone
farmer crosses with cabbage or wolf
farmer returns with goat
farmer crosses with whichever (cabbage or wolf) he didn’t take the first time
farmer returns alone
farmer crosses with goat
they are all on the other side

** Four glasses puzzle/ blind bartender's problem (


Four glasses or tumblers are placed on the corners of a square rotatable table. Some of the glasses are upright (up) and some upside-down (down). A blindfolded person is seated next to the rotatable table and is required to re-arrange the glasses so that they are all up or all down, either arrangement being acceptable, which will be signalled by the ringing of a bell.

The glasses may be re-arranged in turns subject to the following rules:
1. Any two glasses may be inspected in one turn and after feeling their orientation the person may reverse the orientation of either, neither or both glasses.
2. After each turn the table is rotated through a random angle.

The puzzle is to devise an algorithm which allows the blindfolded person to ensure that all glasses have the same orientation (either up or down) in a finite number of turns. The algorithm must be non-stochastic i.e. it must not depend on luck.


An algorithm that guarantees the bell will ring in at most five turns is as follows:
  1. On the first turn choose a diagonally opposite pair of glasses and turn both glasses up.
  2. On the second turn choose two adjacent glasses. At least one will be up as a result of the previous step. If the other is down, turn it up as well. If the bell does not ring, then there are now three glasses up and one down.
  3. On the third turn choose a diagonally opposite pair of glasses. If one is down, turn it up and the bell will ring. If both are up, turn one down. There are now two glasses down, and they must be adjacent.
  4. On the fourth turn choose two adjacent glasses and reverse both. If both were in the same orientation then the bell will ring. Otherwise there are now two glasses down and they must be diagonally opposite.
  5. On the fifth turn choose a diagonally opposite pair of glasses and reverse both. The bell will ring.

Tonsillitis: Symptoms, Causes, and Treatments

At the back of your throat, two masses of tissue called tonsils act as filters,trapping germs that could otherwise enter your airways and cause infection. They also produce antibodies to fight infection. But sometimes the tonsils themselves become infected. Overwhelmed by bacteria or viruses, they swell and become inflamed, a condition known as tonsillitis.

Tonsillitis is common, especially in children. The condition can occur occasionally or recur frequently.

Causes and Symptoms of Tonsillitis

Bacterial and viral infections can cause tonsillitis. A common cause is Streptococcus(strep) bacteria. Other common causes include:
  •     Adenoviruses
  •     Influenza virus
  •     Epstein-Barr virus
  •     Parainfluenza viruses
  •     Enteroviruses
  •     Herpes simplex virus
The main symptoms of tonsillitis are inflammation and swelling of the tonsils, sometimes severe enough to block the airways. Other symptoms include:
  •     Throat pain or tenderness
  •     Redness of the tonsils
  •     A white or yellow coating on the tonsils
  •     Painful blisters or ulcers on the throat
  •     Hoarseness or loss of voice
  •     Headache
  •     Loss of appetite
  •     Ear pain
  •     Difficulty swallowing or breathing through the mouth
  •     Swollen glands in the neck or jaw area
  •     Fever, chills
  •     Bad breath
In children, symptoms may also include:
  •     Nausea
  •     Vomiting
  •     Abdominal pain 

Treatments for Tonsillitis

Treatment for tonsillitis will depend in part on the cause. To determine the cause, your doctor may perform a rapid strep test or throat swab culture. Both tests involve gently swabbing the back of the throat close to the tonsils with a cotton swab. A lab test can detect a bacterial infection. A viral infection will not show on the test, but may be assumed if the test for bacteria is negative.

If tests reveal bacteria, treatment will consist of antibiotics to cure the infection. Antibiotics may be given as a single shot or taken 10 days by mouth. Although symptoms will likely improve within two or three days after starting the antibiotic, it's important to take all of the medication your doctor prescribes to make sure the bacteria are gone. Some people need to take a second course of antibiotics to cure the infection.

If the tonsillitis is caused by a virus, antibiotics won't work and your body will fight off the infection on its own. In the meantime, there are things you can do to feel better, regardless of the cause. They include:
  •     Get enough rest
  •     Drink warm or very cold fluids to ease throat pain
  •     Eat smooth foods, such as flavored gelatins, ice cream, or applesauce
  •     Use a cool-mist vaporizer or humidifier in your room
  •     Gargle with warm salt water
  •     Suck on lozenges containing benzocaine or other anesthetics
  •     Take over-the-counter pain relievers such as acetaminophen or ibuprofen.

 When Tonsillectomy Is Needed ?

Tonsils are an important part of the immune system throughout life, so it is best to avoid removing them.  However, if tonsillitis is recurrent or persistent, or if enlarged tonsils cause upper airway obstruction or difficulty eating, surgical removal of the tonsils, called tonsillectomy, may be necessary. Most tonsillectomies involve using a conventional scalpel to remove the tonsils; however there are many alternatives to this traditional method. Increasingly doctors are using techniques such as lasers, radio waves, ultrasonic energy, or electrocautery to cut, burn, or evaporate away enlarged tonsils.

As with all surgeries, each of these has benefits and drawbacks. When considering the procedure, it's important to discuss your options with the surgeon to select the most appropriate one for your child.

What to Expect After Surgery ?

Tonsillectomy is an outpatient procedure performed under general anesthesia and typically lasting between 30 minutes and 45 minutes. It is most commonly performed in children.

Most children go home about four hours after surgery and require a week to 10 days to recover from it. Almost all children will have throat pain, ranging from mild to severe, after surgery. Some may experience pain in the ears, jaw, and neck. Your child's doctor will prescribe or recommend medication to ease the pain.

During the recovery period, it's important for your child to get enough rest. It's also important to make sure your child gets plenty of fluids; however, you should avoid giving your child milk products for the first 24 hours after surgery. Although throat pain may make your child reluctant to eat, the sooner your child eats, the sooner he or she will recover.

For several days after surgery, your child may experience a low-grade fever and small specks of blood from the nose or saliva. If the fever is greater than 102 degrees Fahrenheit or if you see bright red blood, call your child's doctor right away. Prompt medical attention may be necessary.

Some Homemade Remedies from India: http://www.youtube.com/watch?feature=player_embedded&v=c0vJ4l2Hhyc

References: http://www.webmd.com/oral-health/guide/tonsillitis-symptoms-causes-and-treatments

Thursday, December 26, 2013

Enabling x86 Android Emulation

We all have experienced slow emulator on Mac, Linux and Windows (especially windows) because of which we use virtualization images of Android i.e. Genymotion, etc. So, if you are running your OS on Intel processor then you can use Intel HAXM (Hardware Acclerated Execution Manager) to speedup your emulator.

Following are the links which discuss as to how to implement HAXM:

For Windows and Linux: http://software.intel.com/en-us/articles/speeding-up-the-android-emulator-on-intel-architecture

For Mac: http://simonguest.com/2013/04/16/enabling-x86-android-emulation/