title: Check String Can Obtained Rotating Another String 2 Places
signature: function check_string_can_obtained_rotating_another_string_2_places(str1, str2)
source_py: def check_string_can_obtained_rotating_another_string_2_places(str1, str2):
      if (len(str1) != len(str2)):
          return False
      clock_rot = ''
      anticlock_rot = ''
      l = len(str2)
      anticlock_rot = ((anticlock_rot + str2[(l - 2):]) + str2[0:(l - 2)])
      clock_rot = ((clock_rot + str2[2:]) + str2[0:2])
      return ((str1 == clock_rot) or (str1 == anticlock_rot))
source_cpp: bool check_string_can_obtained_rotating_another_string_2_places(string str1, string str2) {
    if ( str1 . length ( ) != str2 . length ( ) ) return false;
    string clock_rot = "";
    string anticlock_rot = "";
    int len = str2 . length ( );
    anticlock_rot = anticlock_rot + str2 . substr ( len - 2, 2 ) + str2 . substr ( 0, len - 2 );
    clock_rot = clock_rot + str2 . substr ( 2 ) + str2 . substr ( 0, 2 );
    return ( str1 . compare ( clock_rot ) == 0 || str1 . compare ( anticlock_rot ) == 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(str1, str2, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(str1, str2) 
      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("amazon", "azonam", true)
      print(string.format("TEST-0...%s",result))
  
      result = driver("onamaz", "amazon", true)
      print(string.format("TEST-1...%s",result))
  
      result = driver("amazon", "azoman", false)
      print(string.format("TEST-2...%s",result))
  
      result = driver("ab", "ab", true)
      print(string.format("TEST-3...%s",result))
  
      result = driver("737009", "239119", false)
      print(string.format("TEST-4...%s",result))
  
      result = driver("000110", "01111", false)
      print(string.format("TEST-5...%s",result))
  
      result = driver("l", "YVo hqvnGxow", false)
      print(string.format("TEST-6...%s",result))
  
      result = driver("4420318628", "52856", false)
      print(string.format("TEST-7...%s",result))
  
      result = driver("11011111000000", "10", false)
      print(string.format("TEST-8...%s",result))
  
      result = driver(" pvFHANc", "xBIDFbiGb", false)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": true, "inputs": {"str1": "amazon", "str2": "azonam"}}, {"idx": 1, "outputs": true, "inputs": {"str1": "onamaz", "str2": "amazon"}}, {"idx": 2, "outputs": false, "inputs": {"str1": "amazon", "str2": "azoman"}}, {"idx": 3, "outputs": true, "inputs": {"str1": "ab", "str2": "ab"}}, {"idx": 4, "outputs": false, "inputs": {"str1": "737009", "str2": "239119"}}, {"idx": 5, "outputs": false, "inputs": {"str1": "000110", "str2": "01111"}}, {"idx": 6, "outputs": false, "inputs": {"str1": "l", "str2": "YVo hqvnGxow"}}, {"idx": 7, "outputs": false, "inputs": {"str1": "4420318628", "str2": "52856"}}, {"idx": 8, "outputs": false, "inputs": {"str1": "11011111000000", "str2": "10"}}, {"idx": 9, "outputs": false, "inputs": {"str1": " pvFHANc", "str2": "xBIDFbiGb"}}]
question_info.extension: lua
question_info.entry_fn_name: check_string_can_obtained_rotating_another_string_2_places
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: lua __FILENAME__