title: Algorithm to find minimum number of weightings required to find defective ball from a set of n balls
body: <p>Okay here is a puzzle I come across a lot of times-
  Given a set of 12 balls , one of which is defective (it weighs either less or more) . You are allow to weigh 3 times to find the defective and also tell which weighs less or more.</p>
  
  <p>The solution to this problem exists, but I want to know whether we can algorithmically determine if given a set of 'n' balls what is the minimum number of times you would need to use a beam balance to determine which one is defective and how(lighter or heavier).</p>