title: Permute Two Arrays Sum Every Pair Greater Equal K
signature: permute_two_arrays_sum_every_pair_greater_equal_k <- function(a, b, n, k) {
test_code: 
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  validate_solution <- function(actual, expected) {
      toString(actual)==toString(expected)
  }
  
  driver <- function(a, b, n, k, expected){
      if (validate_solution(PLACEHOLDER_FN_NAME(a, b, n, k), expected)){
          "PASSED"
      } else{
          "FAILED"
      }
  }
  
  main <- function() {
      cat(sprintf("TEST-0...%s\n",driver(
          list(99L, 97L, 90L, 88L, 87L, 70L, 52L, 52L, 43L, 40L, 27L, 25L, 16L, 12L, 9L), list(4L, 7L, 11L, 20L, 34L, 35L, 36L, 44L, 46L, 71L, 72L, 78L, 85L, 85L, 91L), 10L, 7L, 
          TRUE
      )))
  
      cat(sprintf("TEST-1...%s\n",driver(
          list(94L, 92L, 92L, 88L, 74L, 72L, 70L, 56L, 42L, 42L, 30L, 30L, 20L, 18L, 14L, 12L, 10L, 8L, 6L, -14L, -26L, -28L, -42L, -44L, -48L, -68L, -74L, -74L, -76L, -78L, -80L, -84L, -86L, -90L, -90L, -90L, -92L, -94L, -96L, -96L, -98L, -98L), list(-98L, -86L, -84L, -80L, -80L, -78L, -76L, -76L, -74L, -72L, -56L, -50L, -48L, -44L, -44L, -42L, -32L, -32L, -32L, -22L, -20L, -18L, -14L, 8L, 16L, 16L, 18L, 24L, 30L, 40L, 44L, 50L, 60L, 62L, 62L, 68L, 70L, 76L, 84L, 94L, 94L, 96L), 40L, 38L, 
          FALSE
      )))
  
      cat(sprintf("TEST-2...%s\n",driver(
          list(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L), 11L, 15L, 
          FALSE
      )))
  
      cat(sprintf("TEST-3...%s\n",driver(
          list(97L, 77L, 75L, 72L, 71L, 70L, 69L, 65L, 59L, 55L, 51L, 48L, 47L, 42L, 35L, 31L, 26L, 18L, 16L, 15L, 15L, 13L, 11L, 6L, 3L, 2L), list(4L, 11L, 12L, 12L, 14L, 15L, 20L, 21L, 36L, 37L, 38L, 44L, 45L, 46L, 48L, 51L, 60L, 62L, 65L, 73L, 78L, 79L, 81L, 88L, 89L, 98L), 25L, 16L, 
          TRUE
      )))
  
      cat(sprintf("TEST-4...%s\n",driver(
          list(94L, 92L, 90L, 90L, 84L, 84L, 74L, 72L, 68L, 58L, 56L, 56L, 54L, 52L, 36L, 32L, 18L, 18L, 16L, 16L, 4L, 2L, -2L, -4L, -4L, -20L, -34L, -40L, -42L, -46L, -48L, -52L, -52L, -52L, -64L, -66L, -70L, -72L), list(-94L, -76L, -74L, -56L, -54L, -50L, -46L, -38L, -26L, -24L, -24L, -22L, -16L, -10L, -6L, -4L, -4L, 0L, 0L, 6L, 12L, 12L, 18L, 20L, 38L, 50L, 52L, 52L, 54L, 64L, 64L, 72L, 72L, 72L, 76L, 90L, 96L, 96L), 26L, 30L, 
          FALSE
      )))
  
      cat(sprintf("TEST-5...%s\n",driver(
          list(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 13L, 13L, 
          FALSE
      )))
  
      cat(sprintf("TEST-6...%s\n",driver(
          list(98L, 96L, 96L, 94L, 93L, 92L, 87L, 82L, 80L, 80L, 80L, 79L, 72L, 72L, 66L, 66L, 64L, 58L, 53L, 48L, 44L, 37L, 34L, 32L, 23L, 21L, 18L, 17L, 8L), list(11L, 15L, 17L, 19L, 23L, 23L, 26L, 27L, 36L, 43L, 46L, 47L, 55L, 59L, 63L, 66L, 77L, 79L, 79L, 82L, 85L, 86L, 86L, 91L, 91L, 94L, 94L, 97L, 99L), 20L, 14L, 
          TRUE
      )))
  
      cat(sprintf("TEST-7...%s\n",driver(
          list(94L, 80L, 78L, 62L, 52L, 50L, 32L, 28L, 24L, 24L, 22L, 18L, 18L, 14L, 14L, 10L, 10L, -8L, -14L, -14L, -16L, -20L, -22L, -28L, -38L, -48L, -50L, -66L, -78L, -78L, -80L, -82L, -88L, -88L, -98L), list(-96L, -82L, -80L, -80L, -66L, -54L, -46L, -44L, -40L, -30L, -16L, -14L, 2L, 6L, 12L, 20L, 24L, 32L, 36L, 38L, 42L, 46L, 52L, 56L, 62L, 66L, 70L, 88L, 88L, 90L, 90L, 96L, 96L, 98L, 98L), 31L, 24L, 
          FALSE
      )))
  
      cat(sprintf("TEST-8...%s\n",driver(
          list(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L), list(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), 31L, 30L, 
          FALSE
      )))
  
      cat(sprintf("TEST-9...%s\n",driver(
          list(92L, 91L, 85L, 75L, 72L, 67L, 65L, 58L, 53L, 45L, 39L, 33L, 31L, 13L, 10L, 10L), list(7L, 12L, 19L, 21L, 28L, 34L, 39L, 40L, 41L, 69L, 71L, 71L, 74L, 78L, 91L, 92L), 14L, 8L, 
          TRUE
      )))
  
  }
  
  main()
source_py: def permute_two_arrays_sum_every_pair_greater_equal_k(a, b, n, k):
      a.sort(reverse=True)
      b.sort()
      for i in range(n):
          if ((a[i] + b[i]) < k):
              return False
      return True
source_cpp: bool permute_two_arrays_sum_every_pair_greater_equal_k(vector<int> a, vector<int> b, int n, int k) {
    sort(a.begin(), a.end());
    sort(b.begin(), b.end(), greater < int > ( ) );
    for ( int i = 0;
    i < n;
    i ++ ) if ( a [ i ] + b [ i ] < k ) return false;
    return true;
  }