title: Check Large Number Divisible 13 Not
signature: function check_large_number_divisible_13_not(num)
source_py: def check_large_number_divisible_13_not(num):
      length = len(num)
      if ((length == 1) and (num[0] == '0')):
          return True
      if ((length % 3) == 1):
          num = (str(num) + '00')
          length += 2
      elif ((length % 3) == 2):
          num = (str(num) + '0')
          length += 1
      sum = 0
      p = 1
      for i in range((length - 1), (- 1), (- 1)):
          group = 0
          group += (ord(num[i]) - ord('0'))
          i -= 1
          group += ((ord(num[i]) - ord('0')) * 10)
          i -= 1
          group += ((ord(num[i]) - ord('0')) * 100)
          sum = (sum + (group * p))
          p *= (- 1)
      sum = abs(sum)
      return ((sum % 13) == 0)
source_cpp: bool check_large_number_divisible_13_not(string num) {
    int length = num . size ( );
    if ( length == 1 && num [ 0 ] == '0' ) return true;
    if ( length % 3 == 1 ) {
      num += "00";
      length += 2;
    }
    else if ( length % 3 == 2 ) {
      num += "0";
      length += 1;
    }
    int sum = 0, p = 1;
    for ( int i = length - 1;
    i >= 0;
    i -- ) {
      int group = 0;
      group += num [ i -- ] - '0';
      group += ( num [ i -- ] - '0' ) * 10;
      group += ( num [ i ] - '0' ) * 100;
      sum = sum + group * p;
      p *= ( - 1 );
    }
    sum = abs ( sum );
    return ( sum % 13 == 0 );
  }
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(num, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(num) 
      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("vzTUaItpCpLnjY", false)
      print(string.format("TEST-0...%s",result))
  
      result = driver("33855", true)
      print(string.format("TEST-1...%s",result))
  
      result = driver("0011110101011", true)
      print(string.format("TEST-2...%s",result))
  
      result = driver("MMQ", false)
      print(string.format("TEST-3...%s",result))
  
      result = driver("439340517954", true)
      print(string.format("TEST-4...%s",result))
  
      result = driver("000000000", true)
      print(string.format("TEST-5...%s",result))
  
      result = driver("UugAuRRJbjEgl", true)
      print(string.format("TEST-6...%s",result))
  
      result = driver("6406553695441", true)
      print(string.format("TEST-7...%s",result))
  
      result = driver("011001", true)
      print(string.format("TEST-8...%s",result))
  
      result = driver("yjFqEEvgiNjEX", true)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": false, "inputs": {"num": "vzTUaItpCpLnjY"}}, {"idx": 1, "outputs": true, "inputs": {"num": "33855"}}, {"idx": 2, "outputs": true, "inputs": {"num": "0011110101011"}}, {"idx": 3, "outputs": false, "inputs": {"num": "MMQ"}}, {"idx": 4, "outputs": true, "inputs": {"num": "439340517954"}}, {"idx": 5, "outputs": true, "inputs": {"num": "000000000"}}, {"idx": 6, "outputs": true, "inputs": {"num": "UugAuRRJbjEgl"}}, {"idx": 7, "outputs": true, "inputs": {"num": "6406553695441"}}, {"idx": 8, "outputs": true, "inputs": {"num": "011001"}}, {"idx": 9, "outputs": true, "inputs": {"num": "yjFqEEvgiNjEX"}}]
question_info.extension: lua
question_info.entry_fn_name: check_large_number_divisible_13_not
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__