title: Fast Multiplication Method Without Using Multiplication Operator Russian Peasants Algorithm
signature: function fast_multiplication_method_without_using_multiplication_operator_russian_peasants_algorithm(a, b)
source_py: def fast_multiplication_method_without_using_multiplication_operator_russian_peasants_algorithm(a, b):
      res = 0
      while (b > 0):
          if (b & 1):
              res = (res + a)
          a = (a << 1)
          b = (b >> 1)
      return res
source_cpp: unsigned int fast_multiplication_method_without_using_multiplication_operator_russian_peasants_algorithm(unsigned int a, unsigned int b) {
    int res = 0;
    while ( b > 0 ) {
      if ( b & 1 ) res = res + a;
      a = a << 1;
      b = b >> 1;
    }
    return res;
  }
question_info.entry_fn_name: fast_multiplication_method_without_using_multiplication_operator_russian_peasants_algorithm
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(a, b, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(a, b) 
      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(4, 33, 132)
      print(string.format("TEST-0...%s",result))
  
      result = driver(36, 67, 2412)
      print(string.format("TEST-1...%s",result))
  
      result = driver(65, 52, 3380)
      print(string.format("TEST-2...%s",result))
  
      result = driver(55, 37, 2035)
      print(string.format("TEST-3...%s",result))
  
      result = driver(35, 76, 2660)
      print(string.format("TEST-4...%s",result))
  
      result = driver(69, 98, 6762)
      print(string.format("TEST-5...%s",result))
  
      result = driver(84, 62, 5208)
      print(string.format("TEST-6...%s",result))
  
      result = driver(5, 80, 400)
      print(string.format("TEST-7...%s",result))
  
      result = driver(15, 36, 540)
      print(string.format("TEST-8...%s",result))
  
      result = driver(67, 84, 5628)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 132, "inputs": {"a": 4, "b": 33}}, {"idx": 1, "outputs": 2412, "inputs": {"a": 36, "b": 67}}, {"idx": 2, "outputs": 3380, "inputs": {"a": 65, "b": 52}}, {"idx": 3, "outputs": 2035, "inputs": {"a": 55, "b": 37}}, {"idx": 4, "outputs": 2660, "inputs": {"a": 35, "b": 76}}, {"idx": 5, "outputs": 6762, "inputs": {"a": 69, "b": 98}}, {"idx": 6, "outputs": 5208, "inputs": {"a": 84, "b": 62}}, {"idx": 7, "outputs": 400, "inputs": {"a": 5, "b": 80}}, {"idx": 8, "outputs": 540, "inputs": {"a": 15, "b": 36}}, {"idx": 9, "outputs": 5628, "inputs": {"a": 67, "b": 84}}]