title: Find A Rotation With Maximum Hamming Distance
signature: fun findARotationWithMaximumHammingDistance(arr: ArrayList<Int>, n: Int): Int {
source_py: def find_a_rotation_with_maximum_hamming_distance(arr, n):
      brr = ([0] * ((2 * n) + 1))
      for i in range(n):
          brr[i] = arr[i]
      for i in range(n):
          brr[(n + i)] = arr[i]
      maxHam = 0
      for i in range(1, n):
          currHam = 0
          k = 0
          for j in range(i, (i + n)):
              if (brr[j] != arr[k]):
                  currHam += 1
                  k = (k + 1)
          if (currHam == n):
              return n
          maxHam = max(maxHam, currHam)
      return maxHam
source_cpp: int find_a_rotation_with_maximum_hamming_distance(vector<int> arr, int n) {
    int brr [ 2 * n + 1 ];
    for ( int i = 0;
    i < n;
    i ++ ) brr [ i ] = arr [ i ];
    for ( int i = 0;
    i < n;
    i ++ ) brr [ n + i ] = arr [ i ];
    int maxHam = 0;
    for ( int i = 1;
    i < n;
    i ++ ) {
      int currHam = 0;
      for ( int j = i, k = 0;
      j < ( i + n );
      j ++, k ++ ) if ( brr [ j ] != arr [ k ] ) currHam ++;
      if ( currHam == n ) return n;
      maxHam = max ( maxHam, currHam );
    }
    return maxHam;
  }
question_info.test_list: [{"idx": 0, "outputs": 12, "inputs": {"arr": [1, 4, 18, 22, 28, 34, 35, 39, 44, 45, 67, 73, 75, 79, 81, 83, 89, 93, 96], "n": 12}}, {"idx": 1, "outputs": 0, "inputs": {"arr": [52, -28], "n": 1}}, {"idx": 2, "outputs": 1, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 21}}, {"idx": 3, "outputs": 0, "inputs": {"arr": [24], "n": 0}}, {"idx": 4, "outputs": 2, "inputs": {"arr": [-68, 14, 36, 62], "n": 2}}, {"idx": 5, "outputs": 6, "inputs": {"arr": [1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0], "n": 12}}, {"idx": 6, "outputs": 15, "inputs": {"arr": [7, 10, 19, 22, 24, 28, 29, 39, 46, 55, 62, 66, 68, 73, 74, 76, 83, 84, 85, 99], "n": 15}}, {"idx": 7, "outputs": 14, "inputs": {"arr": [-38, 56, 86, 12, 24, -90, -20, -46, 38, 92, -44, -74, 54, 50, 46, 50, -94, 64, 32, -84, 70], "n": 14}}, {"idx": 8, "outputs": 2, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1], "n": 8}}, {"idx": 9, "outputs": 2, "inputs": {"arr": [61, 89, 8], "n": 2}}]
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(arr: ArrayList<Int>, n: Int, expected:Int):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(arr, n), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(arrayListOf(1, 4, 18, 22, 28, 34, 35, 39, 44, 45, 67, 73, 75, 79, 81, 83, 89, 93, 96), 12, 12)
      println("TEST-0...${result}")
      
      result = driver(arrayListOf(52, -28), 1, 0)
      println("TEST-1...${result}")
      
      result = driver(arrayListOf(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), 21, 1)
      println("TEST-2...${result}")
      
      result = driver(arrayListOf(24), 0, 0)
      println("TEST-3...${result}")
      
      result = driver(arrayListOf(-68, 14, 36, 62), 2, 2)
      println("TEST-4...${result}")
      
      result = driver(arrayListOf(1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0), 12, 6)
      println("TEST-5...${result}")
      
      result = driver(arrayListOf(7, 10, 19, 22, 24, 28, 29, 39, 46, 55, 62, 66, 68, 73, 74, 76, 83, 84, 85, 99), 15, 15)
      println("TEST-6...${result}")
      
      result = driver(arrayListOf(-38, 56, 86, 12, 24, -90, -20, -46, 38, 92, -44, -74, 54, 50, 46, 50, -94, 64, 32, -84, 70), 14, 14)
      println("TEST-7...${result}")
      
      result = driver(arrayListOf(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1), 8, 2)
      println("TEST-8...${result}")
      
      result = driver(arrayListOf(61, 89, 8), 2, 2)
      println("TEST-9...${result}")
      
          
  }
  
  main()
question_info.entry_fn_name: findARotationWithMaximumHammingDistance
question_info.entry_cls_name: Solution
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: kotlinc -script __FILENAME__ -no-reflect -nowarn