title: Write A C Program To Find The Parity Of An Unsigned Integer
signature: pub fn write_a_c_program_to_find_the_parity_of_an_unsigned_integer(n: i32) -> i32 {
test_code: use std::collections::HashMap;
  use std::collections::HashSet;
  use std::cmp::*;
  use std::collections::*;
  use std::fmt::*; 
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  pub fn validate_solution(actual: i32, expected: i32)->bool{
  return actual==expected
  }
  pub fn driver(n: i32, expected: i32)->String{
      if validate_solution(PLACEHOLDER_FN_NAME(n), expected) {
        return "PASSED".to_string();
      };
      return "FAILED".to_string();
  
  }
  
  fn main() {
      println!("TEST-0...{}", driver(
        63, 
        0
      ));
      
      println!("TEST-1...{}", driver(
        64, 
        -1
      ));
      
      println!("TEST-2...{}", driver(
        85, 
        0
      ));
      
      println!("TEST-3...{}", driver(
        36, 
        0
      ));
      
      println!("TEST-4...{}", driver(
        20, 
        0
      ));
      
      println!("TEST-5...{}", driver(
        63, 
        0
      ));
      
      println!("TEST-6...{}", driver(
        42, 
        -1
      ));
      
      println!("TEST-7...{}", driver(
        19, 
        -1
      ));
      
      println!("TEST-8...{}", driver(
        62, 
        -1
      ));
      
      println!("TEST-9...{}", driver(
        97, 
        -1
      ));
      
  }
source_py: def write_a_c_program_to_find_the_parity_of_an_unsigned_integer(n):
      parity = 0
      while n:
          parity = (~ parity)
          n = (n & (n - 1))
      return parity
source_cpp: bool write_a_c_program_to_find_the_parity_of_an_unsigned_integer(unsigned int n) {
    bool parity = 0;
    while ( n ) {
      parity = ! parity;
      n = n & ( n - 1 );
    }
    return parity;
  }