title: Calculate Maximum Value Using Sign Two Numbers String
signature: fun calculateMaximumValueUsingSignTwoNumbersString(str: String): Int {
source_py: def calculate_maximum_value_using_sign_two_numbers_string(str):
      res = (ord(str[0]) - 48)
      for i in range(1, len(str)):
          if ((str[i] == '0') or (str[i] == '1') or (res < 2)):
              res += (ord(str[i]) - 48)
          else:
              res *= (ord(str[i]) - 48)
      return res
source_cpp: int calculate_maximum_value_using_sign_two_numbers_string(string str) {
    int res = str [ 0 ] - '0';
    for ( int i = 1;
    i < str . length ( );
    i ++ ) {
      if ( str [ i ] == '0' || str [ i ] == '1' || res < 2 ) res += ( str [ i ] - '0' );
      else res *= ( str [ i ] - '0' );
    }
    return res;
  }
question_info.test_list: [{"idx": 0, "outputs": 2176, "inputs": {"str": "pR"}}, {"idx": 1, "outputs": 368, "inputs": {"str": "9518"}}, {"idx": 2, "outputs": 1, "inputs": {"str": "1"}}, {"idx": 3, "outputs": 6272, "inputs": {"str": "3170487"}}, {"idx": 4, "outputs": 4, "inputs": {"str": "0100101010"}}, {"idx": 5, "outputs": -303, "inputs": {"str": "Z rONcUqWb"}}, {"idx": 6, "outputs": 5670, "inputs": {"str": "00419297"}}, {"idx": 7, "outputs": 0, "inputs": {"str": "00"}}, {"idx": 8, "outputs": 66, "inputs": {"str": "r"}}]
question_info.extension: kts
question_info.test_code: package main
  
  import kotlin.text.*
  import kotlin.math.*
  
  
  // SOLUTION CODE
  // ===================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE
  // ===================================
  fun validateSolution(actual:Int, expected:Int):Boolean{
    return actual.equals(expected)
  }
  fun driver(str: String, expected:Int):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(str), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver("pR", 2176)
      println("TEST-0...${result}")
      
      result = driver("9518", 368)
      println("TEST-1...${result}")
      
      result = driver("1", 1)
      println("TEST-2...${result}")
      
      result = driver("3170487", 6272)
      println("TEST-3...${result}")
      
      result = driver("0100101010", 4)
      println("TEST-4...${result}")
      
      result = driver("Z rONcUqWb", -303)
      println("TEST-5...${result}")
      
      result = driver("00419297", 5670)
      println("TEST-6...${result}")
      
      result = driver("00", 0)
      println("TEST-7...${result}")
      
      result = driver("r", 66)
      println("TEST-8...${result}")
      
          
  }
  
  main()
question_info.entry_fn_name: calculateMaximumValueUsingSignTwoNumbersString
question_info.entry_cls_name: Solution
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8
question_info.commands: kotlinc -script __FILENAME__ -no-reflect -nowarn