title: Sum Two Large Numbers
signature: class Solution {
  
      public string SumTwoLargeNumbers(string str1, string str2) {
test_code: using System;
  using System.Numerics;
  using System.Diagnostics;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Security.Cryptography;
  using System.Web.UI;
  using System.Web.Script.Serialization;
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  namespace EvaluatePrediction {
      class TestRunner {
          public bool ValidateSolution(string actual, string expected){
              return new JavaScriptSerializer().Serialize(actual) == new JavaScriptSerializer().Serialize(expected);
          }
  
          public string driver(string str1, string str2, string expected){
              try{
                PLACEHOLDER_CLS_NAME solution_cls = new PLACEHOLDER_CLS_NAME();
                string pred_result = solution_cls.PLACEHOLDER_FN_NAME(str1, str2); 
                if (ValidateSolution(
                      pred_result,
                      expected)){
                  return "PASSED";
                }
                return "FAILED";
              } 
              catch (Exception exception_obj)
              {
                return exception_obj.GetType().FullName;
              }
          }
          static void Main(string[] args) {
              TestRunner runner = new TestRunner();
              String result;
              result = runner.driver(
                  "VkfzrPG", "rKZ", 
                  "44527855"
              );
              Console.WriteLine(string.Format(
                  "TEST-0...{0}",
                  result)
              );result = runner.driver(
                  "0526110506447", "903", 
                  "0526110507350"
              );
              Console.WriteLine(string.Format(
                  "TEST-1...{0}",
                  result)
              );result = runner.driver(
                  "011010010", "110100000", 
                  "121110010"
              );
              Console.WriteLine(string.Format(
                  "TEST-2...{0}",
                  result)
              );result = runner.driver(
                  "sPAwZACc ", "liYMsojPiinOV", 
                  "66153436372942"
              );
              Console.WriteLine(string.Format(
                  "TEST-3...{0}",
                  result)
              );result = runner.driver(
                  "3", "611", 
                  "614"
              );
              Console.WriteLine(string.Format(
                  "TEST-4...{0}",
                  result)
              );result = runner.driver(
                  "0101", "01110101011", 
                  "01110101112"
              );
              Console.WriteLine(string.Format(
                  "TEST-5...{0}",
                  result)
              );result = runner.driver(
                  "VTtNu", "Wsmc", 
                  "469530"
              );
              Console.WriteLine(string.Format(
                  "TEST-6...{0}",
                  result)
              );result = runner.driver(
                  "2317170", "898421173423", 
                  "898423490593"
              );
              Console.WriteLine(string.Format(
                  "TEST-7...{0}",
                  result)
              );result = runner.driver(
                  "111111000010", "01100001110111", 
                  "01211112110121"
              );
              Console.WriteLine(string.Format(
                  "TEST-8...{0}",
                  result)
              );result = runner.driver(
                  "Ktt", "CTbbVX wGBkE", 
                  "2315420138859"
              );
              Console.WriteLine(string.Format(
                  "TEST-9...{0}",
                  result)
              );
          }
      }
  }
  
source_py: def sum_two_large_numbers(str1, str2):
      if (len(str1) > len(str2)):
          t = str1
          str1 = str2
          str2 = t
      str = ''
      n1 = len(str1)
      n2 = len(str2)
      str1 = str1[::(- 1)]
      str2 = str2[::(- 1)]
      carry = 0
      for i in range(n1):
          sum = ((ord(str1[i]) - 48) + ((ord(str2[i]) - 48) + carry))
          str += chr(((sum % 10) + 48))
          carry = int((sum / 10))
      for i in range(n1, n2):
          sum = ((ord(str2[i]) - 48) + carry)
          str += chr(((sum % 10) + 48))
          carry = int((sum / 10))
      if carry:
          str += chr((carry + 48))
      str = str[::(- 1)]
      return str
source_cpp: string sum_two_large_numbers(string str1, string str2) {
    if ( str1 . length ( ) > str2 . length ( ) ) swap ( str1, str2 );
    string str = "";
    int n1 = str1 . length ( ), n2 = str2 . length ( );
    reverse ( str1 . begin ( ), str1 . end ( ) );
    reverse ( str2 . begin ( ), str2 . end ( ) );
    int carry = 0;
    for ( int i = 0;
    i < n1;
    i ++ ) {
      int sum = ( ( str1 [ i ] - '0' ) + ( str2 [ i ] - '0' ) + carry );
      str . push_back ( sum % 10 + '0' );
      carry = sum / 10;
    }
    for ( int i = n1;
    i < n2;
    i ++ ) {
      int sum = ( ( str2 [ i ] - '0' ) + carry );
      str . push_back ( sum % 10 + '0' );
      carry = sum / 10;
    }
    if ( carry ) str . push_back ( carry + '0' );
    reverse ( str . begin ( ), str . end ( ) );
    return str;
  }