title: Count Set Bits In An Integer 1
signature: fun countSetBitsInAnInteger1(n: Int): Int {
test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Int, expected:Int):Boolean{
    return actual.equals(expected)
  }
  fun driver(n: Int, expected:Int):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(n), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(43, 4)
      println("TEST-0...${result}")
      
      result = driver(94, 5)
      println("TEST-1...${result}")
      
      result = driver(72, 2)
      println("TEST-2...${result}")
      
      result = driver(86, 4)
      println("TEST-3...${result}")
      
      result = driver(42, 3)
      println("TEST-4...${result}")
      
      result = driver(33, 2)
      println("TEST-5...${result}")
      
      result = driver(8, 1)
      println("TEST-6...${result}")
      
      result = driver(74, 3)
      println("TEST-7...${result}")
      
      result = driver(29, 4)
      println("TEST-8...${result}")
      
      result = driver(34, 2)
      println("TEST-9...${result}")
      
          
  }
  
  main()
source_py: def count_set_bits_in_an_integer_1(n):
      if (n == 0):
          return 0
      else:
          return ((n & 1) + count_set_bits_in_an_integer_1((n >> 1)))
source_cpp: int count_set_bits_in_an_integer_1(int n) {
    if ( n == 0 ) return 0;
    else return ( n & 1 ) + count_set_bits_in_an_integer_1 ( n >> 1 );
  }