title: Number Visible Boxes Putting One Inside Another
signature: fun numberVisibleBoxesPuttingOneInsideAnother(arr: ArrayList<Int>, n: Int): Int {
source_py: def number_visible_boxes_putting_one_inside_another(arr, n):
      q = collections.deque([])
      arr.sort()
      q.append(arr[0])
      for i in range(1, n):
          now = q[0]
          if (arr[i] >= (2 * now)):
              q.popleft()
          q.append(arr[i])
      return len(q)
source_cpp: int number_visible_boxes_putting_one_inside_another(vector<int> arr, int n) {
    queue < int > q;
    sort(arr.begin(), arr.end());
    q . push ( arr [ 0 ] );
    for ( int i = 1;
    i < n;
    i ++ ) {
      int now = q . front ( );
      if ( arr [ i ] >= 2 * now ) q . pop ( );
      q . push ( arr [ i ] );
    }
    return q . size ( );
  }
question_info.test_list: [{"idx": 0, "outputs": 7, "inputs": {"arr": [2, 3, 17, 17, 18, 28, 28, 29, 34, 43, 44, 52, 54, 80, 84, 84, 91, 92, 97], "n": 12}}, {"idx": 1, "outputs": 2, "inputs": {"arr": [-94, -90, -90, -78, -34, -26, -10, 4, 24, 28, 64, 70, 72, 74, 80, 82], "n": 10}}, {"idx": 2, "outputs": 15, "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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 40}}, {"idx": 3, "outputs": 3, "inputs": {"arr": [2, 3, 5, 8, 12, 16, 20, 30, 37, 53, 55, 62, 76, 81, 83, 87, 88, 96], "n": 9}}, {"idx": 4, "outputs": 4, "inputs": {"arr": [-94, -92, -60, -58, -54, -42, -36, -12, -8, -2, 8, 14, 18, 20, 26, 32, 38, 56, 58, 60, 70, 78, 80, 86, 98], "n": 18}}, {"idx": 5, "outputs": 4, "inputs": {"arr": [0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 9}}, {"idx": 6, "outputs": 13, "inputs": {"arr": [1, 1, 2, 3, 3, 11, 16, 18, 19, 21, 21, 22, 22, 24, 27, 28, 29, 43, 43, 52, 55, 57, 60, 62, 62, 63, 65, 66, 70, 70, 73, 77, 78, 79, 79, 80, 85, 85, 86, 88, 89, 90, 97, 98], "n": 30}}, {"idx": 7, "outputs": 1, "inputs": {"arr": [-94, -82, -80, -78, -68, -60, -58, -44, -44, -42, -30, -30, -22, -18, -18, -14, -14, -10, -8, -6, 4, 4, 6, 12, 12, 14, 18, 30, 44, 48, 50, 52, 54, 80, 86, 88, 88], "n": 21}}, {"idx": 8, "outputs": 3, "inputs": {"arr": [0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 7}}, {"idx": 9, "outputs": 17, "inputs": {"arr": [3, 5, 5, 10, 12, 16, 22, 31, 31, 32, 39, 43, 43, 47, 49, 50, 51, 52, 52, 56, 59, 59, 62, 69, 69, 71, 75, 81, 82, 83, 83, 86, 89, 90, 90, 96], "n": 28}}]
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(2, 3, 17, 17, 18, 28, 28, 29, 34, 43, 44, 52, 54, 80, 84, 84, 91, 92, 97), 12, 7)
      println("TEST-0...${result}")
      
      result = driver(arrayListOf(-94, -90, -90, -78, -34, -26, -10, 4, 24, 28, 64, 70, 72, 74, 80, 82), 10, 2)
      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, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), 40, 15)
      println("TEST-2...${result}")
      
      result = driver(arrayListOf(2, 3, 5, 8, 12, 16, 20, 30, 37, 53, 55, 62, 76, 81, 83, 87, 88, 96), 9, 3)
      println("TEST-3...${result}")
      
      result = driver(arrayListOf(-94, -92, -60, -58, -54, -42, -36, -12, -8, -2, 8, 14, 18, 20, 26, 32, 38, 56, 58, 60, 70, 78, 80, 86, 98), 18, 4)
      println("TEST-4...${result}")
      
      result = driver(arrayListOf(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), 9, 4)
      println("TEST-5...${result}")
      
      result = driver(arrayListOf(1, 1, 2, 3, 3, 11, 16, 18, 19, 21, 21, 22, 22, 24, 27, 28, 29, 43, 43, 52, 55, 57, 60, 62, 62, 63, 65, 66, 70, 70, 73, 77, 78, 79, 79, 80, 85, 85, 86, 88, 89, 90, 97, 98), 30, 13)
      println("TEST-6...${result}")
      
      result = driver(arrayListOf(-94, -82, -80, -78, -68, -60, -58, -44, -44, -42, -30, -30, -22, -18, -18, -14, -14, -10, -8, -6, 4, 4, 6, 12, 12, 14, 18, 30, 44, 48, 50, 52, 54, 80, 86, 88, 88), 21, 1)
      println("TEST-7...${result}")
      
      result = driver(arrayListOf(0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1), 7, 3)
      println("TEST-8...${result}")
      
      result = driver(arrayListOf(3, 5, 5, 10, 12, 16, 22, 31, 31, 32, 39, 43, 43, 47, 49, 50, 51, 52, 52, 56, 59, 59, 62, 69, 69, 71, 75, 81, 82, 83, 83, 86, 89, 90, 90, 96), 28, 17)
      println("TEST-9...${result}")
      
          
  }
  
  main()
question_info.entry_fn_name: numberVisibleBoxesPuttingOneInsideAnother
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