title: Replace Character C1 C2 C2 C1 String S
signature: function replaceCharacterC1C2C2C1StringS(s: string, c1: string, c2: string): string {
source_py: def replace_character_c1_c2_c2_c1_string_s(s, c1, c2):
      l = len(s)
      for i in range(l):
          if (s[i] == c1):
              s = ((s[0:i] + c2) + s[(i + 1):])
          elif (s[i] == c2):
              s = ((s[0:i] + c1) + s[(i + 1):])
      return s
source_cpp: string replace_character_c1_c2_c2_c1_string_s(string s, char c1, char c2) {
    int l = s . length ( );
    for ( int i = 0;
    i < l;
    i ++ ) {
      if ( s [ i ] == c1 ) s [ i ] = c2;
      else if ( s [ i ] == c2 ) s [ i ] = c1;
    }
    return s;
  }
question_info.test_list: [{"idx": 0, "outputs": "IZTSMw j", "inputs": {"s": "IZTSMw j", "c1": "W", "c2": "k"}}, {"idx": 1, "outputs": "7288334", "inputs": {"s": "7288334", "c1": "6", "c2": "9"}}, {"idx": 2, "outputs": "010110000", "inputs": {"s": "010110000", "c1": "1", "c2": "1"}}, {"idx": 3, "outputs": "b gJX", "inputs": {"s": "b gJX", "c1": "t", "c2": "P"}}, {"idx": 4, "outputs": "734", "inputs": {"s": "734", "c1": "4", "c2": "4"}}, {"idx": 5, "outputs": "1", "inputs": {"s": "1", "c1": "1", "c2": "1"}}, {"idx": 6, "outputs": "xCaUKdhA", "inputs": {"s": "xCaUKdhA", "c1": "X", "c2": "S"}}, {"idx": 7, "outputs": "4370992544981", "inputs": {"s": "4370992644981", "c1": "5", "c2": "6"}}, {"idx": 8, "outputs": "10101", "inputs": {"s": "01010", "c1": "0", "c2": "1"}}, {"idx": 9, "outputs": "ZNIFGshaWA", "inputs": {"s": "ZNIFGshaWA", "c1": "Q", "c2": "x"}}]
question_info.entry_cls_name: Solution
question_info.test_code: 
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
  
  // TESTING CODE 
  // ============================================
  function convertToString(value: any): string{
      return JSON.stringify(value, function (key, val) {
          if (val instanceof Set) {
              return Array.from(val);
          } return val;});
  }
  
  function validateSolution(actual: string, expected: string): boolean {
      return convertToString(actual) === convertToString(expected);
  }
  
  function driver(s: string, c1: string, c2: string, expected:string): string {
      try{
          if (validateSolution(PLACEHOLDER_FN_NAME(s, c1, c2),expected)){
              return "PASSED";
          }
          return "FAILED";
      } catch (error) {
        return error.name;
      }
      
  }
      
  function main(){
    let result = '';
    result = driver("IZTSMw j", 'W', 'k', "IZTSMw j");
    console.log(`TEST-0...${result}`);
  
    result = driver("7288334", '6', '9', "7288334");
    console.log(`TEST-1...${result}`);
  
    result = driver("010110000", '1', '1', "010110000");
    console.log(`TEST-2...${result}`);
  
    result = driver("b gJX", 't', 'P', "b gJX");
    console.log(`TEST-3...${result}`);
  
    result = driver("734", '4', '4', "734");
    console.log(`TEST-4...${result}`);
  
    result = driver("1", '1', '1', "1");
    console.log(`TEST-5...${result}`);
  
    result = driver("xCaUKdhA", 'X', 'S', "xCaUKdhA");
    console.log(`TEST-6...${result}`);
  
    result = driver("4370992644981", '5', '6', "4370992544981");
    console.log(`TEST-7...${result}`);
  
    result = driver("01010", '0', '1', "10101");
    console.log(`TEST-8...${result}`);
  
    result = driver("ZNIFGshaWA", 'Q', 'x', "ZNIFGshaWA");
    console.log(`TEST-9...${result}`);
  
  };
  
  main();
question_info.extension: ts
question_info.entry_fn_name: replaceCharacterC1C2C2C1StringS
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: tsc --target es2020 --lib es5,dom,es2015,es2020 __FILENAME__
question_info.commands: node __FILENAME__.js