title: Lexicographically Next String
signature: function lexicographically_next_string(s)
source_py: def lexicographically_next_string(s):
      if (s == ' '):
          return 'a'
      i = (len(s) - 1)
      while ((s[i] == 'z') and (i >= 0)):
          i -= 1
      if (i == (- 1)):
          s = (s + 'a')
      else:
          s = s.replace(s[i], chr((ord(s[i]) + 1)), 1)
      return s
source_cpp: string lexicographically_next_string(string s) {
    if ( s == "" ) return "a";
    int i = s . length ( ) - 1;
    while ( s [ i ] == 'z' && i >= 0 ) i --;
    if ( i == - 1 ) s = s + 'a';
    else s [ i ] ++;
    return s;
  }
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(s, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(s) 
      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("amKIRzPiqLTIy", "amKIRzPiqLTIz")
      print(string.format("TEST-0...%s",result))
  
      result = driver("68", "69")
      print(string.format("TEST-1...%s",result))
  
      result = driver("100", "110")
      print(string.format("TEST-2...%s",result))
  
      result = driver("f", "g")
      print(string.format("TEST-3...%s",result))
  
      result = driver("802205375", "802206375")
      print(string.format("TEST-4...%s",result))
  
      result = driver("0111", "0211")
      print(string.format("TEST-5...%s",result))
  
      result = driver("GRjRYIvYwgua", "GRjRYIvYwgub")
      print(string.format("TEST-6...%s",result))
  
      result = driver("8139910006809", "813:910006809")
      print(string.format("TEST-7...%s",result))
  
      result = driver("100101", "200101")
      print(string.format("TEST-8...%s",result))
  
      result = driver("rw", "rx")
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": "amKIRzPiqLTIz", "inputs": {"s": "amKIRzPiqLTIy"}}, {"idx": 1, "outputs": "69", "inputs": {"s": "68"}}, {"idx": 2, "outputs": "110", "inputs": {"s": "100"}}, {"idx": 3, "outputs": "g", "inputs": {"s": "f"}}, {"idx": 4, "outputs": "802206375", "inputs": {"s": "802205375"}}, {"idx": 5, "outputs": "0211", "inputs": {"s": "0111"}}, {"idx": 6, "outputs": "GRjRYIvYwgub", "inputs": {"s": "GRjRYIvYwgua"}}, {"idx": 7, "outputs": "813:910006809", "inputs": {"s": "8139910006809"}}, {"idx": 8, "outputs": "200101", "inputs": {"s": "100101"}}, {"idx": 9, "outputs": "rx", "inputs": {"s": "rw"}}]
question_info.extension: lua
question_info.entry_fn_name: lexicographically_next_string
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__