title: Program Find Smallest Difference Angles Two Parts Given Circle
signature: function program_find_smallest_difference_angles_two_parts_given_circle(arr, n)
source_py: def program_find_smallest_difference_angles_two_parts_given_circle(arr, n):
      l = 0
      _sum = 0
      ans = 360
      for i in range(n):
          _sum += arr[i]
          while (_sum >= 180):
              ans = min(ans, (2 * abs((180 - _sum))))
              _sum -= arr[l]
              l += 1
          ans = min(ans, (2 * abs((180 - _sum))))
      return ans
source_cpp: int program_find_smallest_difference_angles_two_parts_given_circle(vector<int> arr, int n) {
    int l = 0, sum = 0, ans = 360;
    for ( int i = 0;
    i < n;
    i ++ ) {
      sum += arr [ i ];
      while ( sum >= 180 ) {
        ans = min ( ans, 2 * abs ( 180 - sum ) );
        sum -= arr [ l ];
        l ++;
      }
      ans = min ( ans, 2 * abs ( 180 - sum ) );
    }
    return ans;
  }
question_info.entry_fn_name: program_find_smallest_difference_angles_two_parts_given_circle
question_info.entry_cls_name: Solution
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
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(arr, n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(arr, n) 
      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({4, 4, 5, 5, 13, 14, 14, 16, 19, 20, 30, 31, 32, 33, 35, 38, 38, 42, 44, 44, 48, 48, 52, 58, 60, 64, 65, 66, 68, 69, 70, 70, 71, 72, 73, 79, 81, 83, 83, 84, 86, 87, 88, 88, 91, 92, 95, 95, 98}, 27, 2)
      print(string.format("TEST-0...%s",result))
  
      result = driver({-56, 88, -50, 70, 20, 58, 42, -56, -52, -78, 98, 20, -26, 4, 20, -66, -46, -58, 74, 74, -72, 2, 16, -78, -4, 10, 58, 60, -46, -2, 32, -96, 24, -6, 90, -64, -24, -38, 26, 66, -42, -86, 48, 92, 28, 6, -54, -6}, 29, 16)
      print(string.format("TEST-1...%s",result))
  
      result = driver({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}, 25, 340)
      print(string.format("TEST-2...%s",result))
  
      result = driver({52, 67, 62}, 1, 256)
      print(string.format("TEST-3...%s",result))
  
      result = driver({-56, -22, 32, 42, 66}, 4, 360)
      print(string.format("TEST-4...%s",result))
  
      result = driver({1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0}, 10, 354)
      print(string.format("TEST-5...%s",result))
  
      result = driver({38, 46, 58, 72}, 2, 192)
      print(string.format("TEST-6...%s",result))
  
      result = driver({16, 62, 90, 40, 30, -56, -92, -56, 60, 42, -64, 92, -30, -70, 42, -48, -54, 54, 48, 94, -44, -46, 10, 48, 22, -24, -62, 34, 60, 24, -60, 50, 40, 34}, 20, 24)
      print(string.format("TEST-7...%s",result))
  
      result = driver({0, 0, 0, 0, 0, 0, 0, 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}, 37, 340)
      print(string.format("TEST-8...%s",result))
  
      result = driver({86, 43, 74, 84, 86, 14, 45, 7, 92, 36, 79, 13, 67, 18, 96, 77, 13, 22, 28, 36, 57, 56, 99, 57, 8, 48, 5, 79, 65, 64, 96, 6, 36, 91, 53, 55, 11, 12, 80, 99, 50, 40, 4, 9, 52, 41}, 40, 0)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 2, "inputs": {"arr": [4, 4, 5, 5, 13, 14, 14, 16, 19, 20, 30, 31, 32, 33, 35, 38, 38, 42, 44, 44, 48, 48, 52, 58, 60, 64, 65, 66, 68, 69, 70, 70, 71, 72, 73, 79, 81, 83, 83, 84, 86, 87, 88, 88, 91, 92, 95, 95, 98], "n": 27}}, {"idx": 1, "outputs": 16, "inputs": {"arr": [-56, 88, -50, 70, 20, 58, 42, -56, -52, -78, 98, 20, -26, 4, 20, -66, -46, -58, 74, 74, -72, 2, 16, -78, -4, 10, 58, 60, -46, -2, 32, -96, 24, -6, 90, -64, -24, -38, 26, 66, -42, -86, 48, 92, 28, 6, -54, -6], "n": 29}}, {"idx": 2, "outputs": 340, "inputs": {"arr": [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], "n": 25}}, {"idx": 3, "outputs": 256, "inputs": {"arr": [52, 67, 62], "n": 1}}, {"idx": 4, "outputs": 360, "inputs": {"arr": [-56, -22, 32, 42, 66], "n": 4}}, {"idx": 5, "outputs": 354, "inputs": {"arr": [1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 0], "n": 10}}, {"idx": 6, "outputs": 192, "inputs": {"arr": [38, 46, 58, 72], "n": 2}}, {"idx": 7, "outputs": 24, "inputs": {"arr": [16, 62, 90, 40, 30, -56, -92, -56, 60, 42, -64, 92, -30, -70, 42, -48, -54, 54, 48, 94, -44, -46, 10, 48, 22, -24, -62, 34, 60, 24, -60, 50, 40, 34], "n": 20}}, {"idx": 8, "outputs": 340, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 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], "n": 37}}, {"idx": 9, "outputs": 0, "inputs": {"arr": [86, 43, 74, 84, 86, 14, 45, 7, 92, 36, 79, 13, 67, 18, 96, 77, 13, 22, 28, 36, 57, 56, 99, 57, 8, 48, 5, 79, 65, 64, 96, 6, 36, 91, 53, 55, 11, 12, 80, 99, 50, 40, 4, 9, 52, 41], "n": 40}}]