title: Count Set Bits In An Integer
signature: function countSetBitsInAnInteger(n: number): number {
test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: number, expected: number): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(n: number, expected:number): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(n),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver(58, 4);
    console.log(`TEST-0...${result}`);
  
    result = driver(92, 4);
    console.log(`TEST-1...${result}`);
  
    result = driver(73, 3);
    console.log(`TEST-2...${result}`);
  
    result = driver(52, 3);
    console.log(`TEST-3...${result}`);
  
    result = driver(24, 2);
    console.log(`TEST-4...${result}`);
  
    result = driver(14, 3);
    console.log(`TEST-5...${result}`);
  
    result = driver(58, 4);
    console.log(`TEST-6...${result}`);
  
    result = driver(11, 3);
    console.log(`TEST-7...${result}`);
  
    result = driver(8, 1);
    console.log(`TEST-8...${result}`);
  
    result = driver(52, 3);
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
source_py: def count_set_bits_in_an_integer(n):
      count = 0
      while n:
          count += (n & 1)
          n >>= 1
      return count
source_cpp: unsigned int count_set_bits_in_an_integer(unsigned int n) {
    unsigned int count = 0;
    while ( n ) {
      count += n & 1;
      n >>= 1;
    }
    return count;
  }