title: Compute Modulus Division By A Power Of 2 Number
signature: function compute_modulus_division_by_a_power_of_2_number(n, d)
source_py: def compute_modulus_division_by_a_power_of_2_number(n, d):
      return (n & (d - 1))
source_cpp: unsigned int compute_modulus_division_by_a_power_of_2_number(unsigned int n, unsigned int d) {
    return ( n & ( d - 1 ) );
  }
question_info.entry_fn_name: compute_modulus_division_by_a_power_of_2_number
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
question_info.test_code: 
  
  -- SOLUTION CODE
  -- ============================================
  PLACEHOLDER_CODE_BODY
  
  -- TESTING CODE 
  -- ============================================
  function isCorrect(actual, expected)
      if type(expected) ~= type(actual) then
          return false
      end
      
      if type(expected) == 'table' then
          for k,v_expected in pairs(expected) do
              
              if actual[k] == nil then
                  return false
              end
              local v_actual = actual[k]
              if not isCorrect(v_actual, v_expected) then
                  return false
              end
              actual[k]=nil
          end
      
          if next(actual) then 
              return false
          end
          return true
      else
          return actual == expected
      end
  end
  
  function validateSolution(actual, expected)
      return isCorrect(actual,expected)
  end
  
  function driver(n, d, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(n, d) 
      end)
      if status then
          if validateSolution(exec_result,expected) then
              return "PASSED"
          end
          return "FAILED"
      else
          return string.format("ERROR=%s",string.gsub(error_msg,".*:[%d]+: ",""))
      end
  end
      
  function main()
      result = driver(54, 59, 50)
      print(string.format("TEST-0...%s",result))
  
      result = driver(39, 84, 3)
      print(string.format("TEST-1...%s",result))
  
      result = driver(35, 81, 0)
      print(string.format("TEST-2...%s",result))
  
      result = driver(9, 60, 9)
      print(string.format("TEST-3...%s",result))
  
      result = driver(62, 68, 2)
      print(string.format("TEST-4...%s",result))
  
      result = driver(16, 16, 0)
      print(string.format("TEST-5...%s",result))
  
      result = driver(93, 96, 93)
      print(string.format("TEST-6...%s",result))
  
      result = driver(32, 38, 32)
      print(string.format("TEST-7...%s",result))
  
      result = driver(39, 62, 37)
      print(string.format("TEST-8...%s",result))
  
      result = driver(63, 16, 15)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 50, "inputs": {"n": 54, "d": 59}}, {"idx": 1, "outputs": 3, "inputs": {"n": 39, "d": 84}}, {"idx": 2, "outputs": 0, "inputs": {"n": 35, "d": 81}}, {"idx": 3, "outputs": 9, "inputs": {"n": 9, "d": 60}}, {"idx": 4, "outputs": 2, "inputs": {"n": 62, "d": 68}}, {"idx": 5, "outputs": 0, "inputs": {"n": 16, "d": 16}}, {"idx": 6, "outputs": 93, "inputs": {"n": 93, "d": 96}}, {"idx": 7, "outputs": 32, "inputs": {"n": 32, "d": 38}}, {"idx": 8, "outputs": 37, "inputs": {"n": 39, "d": 62}}, {"idx": 9, "outputs": 15, "inputs": {"n": 63, "d": 16}}]