title: Lower Insertion Point
signature: fun lowerInsertionPoint(arr: ArrayList<Int>, n: Int, x: Int): Int {
source_py: def lower_insertion_point(arr, n, X):
      if (X < arr[0]):
          return 0
      elif (X > arr[(n - 1)]):
          return n
      lowerPnt = 0
      i = 1
      while ((i < n) and (arr[i] < X)):
          lowerPnt = i
          i = (i * 2)
      while ((lowerPnt < n) and (arr[lowerPnt] < X)):
          lowerPnt += 1
      return lowerPnt
source_cpp: int lower_insertion_point(vector<int> arr, int n, int X) {
    if ( X < arr [ 0 ] ) return 0;
    else if ( X > arr [ n - 1 ] ) return n;
    int lowerPnt = 0;
    int i = 1;
    while ( i < n && arr [ i ] < X ) {
      lowerPnt = i;
      i = i * 2;
    }
    while ( lowerPnt < n && arr [ lowerPnt ] < X ) lowerPnt ++;
    return lowerPnt;
  }
question_info.test_list: [{"idx": 0, "outputs": 8, "inputs": {"arr": [1, 2, 5, 5, 16, 16, 20, 26, 32, 35, 39, 39, 41, 44, 48, 48, 51, 59, 59, 62, 66, 66, 70, 74, 75, 78, 80, 86, 86, 96], "n": 17, "x": 29}}, {"idx": 1, "outputs": 14, "inputs": {"arr": [-76, 80, -6, -2, 50, 72, 84, -56, 70, 8, 48, 6, -24, -50, -72], "n": 14, "x": 9}}, {"idx": 2, "outputs": 8, "inputs": {"arr": [0, 0, 0, 0, 0, 1, 1, 1, 1], "n": 8, "x": 4}}, {"idx": 3, "outputs": 0, "inputs": {"arr": [74, 65, 84, 71], "n": 2, "x": 3}}, {"idx": 4, "outputs": 19, "inputs": {"arr": [-96, -92, -90, -86, -84, -76, -76, -62, -58, -54, -50, -50, -44, -42, -38, -34, -14, -8, 6, 12, 24, 38, 40, 50, 62, 84, 86, 92], "n": 19, "x": 19}}, {"idx": 5, "outputs": 12, "inputs": {"arr": [1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1], "n": 12, "x": 17}}, {"idx": 6, "outputs": 8, "inputs": {"arr": [6, 10, 14, 14, 16, 19, 23, 23, 25, 26, 29, 34, 42, 42, 43, 45, 47, 49, 50, 51, 51, 56, 59, 65, 69, 72, 75, 78, 79, 80, 82, 82, 82, 84, 85, 91, 98], "n": 31, "x": 24}}, {"idx": 7, "outputs": 2, "inputs": {"arr": [-90, -2, 22, -2, 58, -2, 96, 38, 36, -66, -98, 22, -80, -32, 22, 0, -34, -16, 82, 76, 12, 84, 66, 8, 32, 18, -98, -10], "n": 22, "x": 16}}, {"idx": 8, "outputs": 3, "inputs": {"arr": [0, 0, 0, 1, 1, 1, 1], "n": 3, "x": 5}}, {"idx": 9, "outputs": 0, "inputs": {"arr": [85, 59, 22, 52, 93, 14, 42, 71, 69, 15, 52, 78, 35, 61, 92, 90, 70, 48, 47, 72, 74, 46, 22, 74, 83, 32, 14, 24, 18, 27, 18, 68, 29, 31], "n": 19, "x": 33}}]
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, x: Int, expected:Int):String {
      try{
        if (validateSolution(PLACEHOLDER_FN_NAME(arr, n, x), expected)) {
                return "PASSED"
        }
        return "FAILED"
      } catch (e: Exception){
        return e::class.simpleName as String
      }
  
  }
  
  fun main() {
      var result: String = ""
      result = driver(arrayListOf(1, 2, 5, 5, 16, 16, 20, 26, 32, 35, 39, 39, 41, 44, 48, 48, 51, 59, 59, 62, 66, 66, 70, 74, 75, 78, 80, 86, 86, 96), 17, 29, 8)
      println("TEST-0...${result}")
      
      result = driver(arrayListOf(-76, 80, -6, -2, 50, 72, 84, -56, 70, 8, 48, 6, -24, -50, -72), 14, 9, 14)
      println("TEST-1...${result}")
      
      result = driver(arrayListOf(0, 0, 0, 0, 0, 1, 1, 1, 1), 8, 4, 8)
      println("TEST-2...${result}")
      
      result = driver(arrayListOf(74, 65, 84, 71), 2, 3, 0)
      println("TEST-3...${result}")
      
      result = driver(arrayListOf(-96, -92, -90, -86, -84, -76, -76, -62, -58, -54, -50, -50, -44, -42, -38, -34, -14, -8, 6, 12, 24, 38, 40, 50, 62, 84, 86, 92), 19, 19, 19)
      println("TEST-4...${result}")
      
      result = driver(arrayListOf(1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1), 12, 17, 12)
      println("TEST-5...${result}")
      
      result = driver(arrayListOf(6, 10, 14, 14, 16, 19, 23, 23, 25, 26, 29, 34, 42, 42, 43, 45, 47, 49, 50, 51, 51, 56, 59, 65, 69, 72, 75, 78, 79, 80, 82, 82, 82, 84, 85, 91, 98), 31, 24, 8)
      println("TEST-6...${result}")
      
      result = driver(arrayListOf(-90, -2, 22, -2, 58, -2, 96, 38, 36, -66, -98, 22, -80, -32, 22, 0, -34, -16, 82, 76, 12, 84, 66, 8, 32, 18, -98, -10), 22, 16, 2)
      println("TEST-7...${result}")
      
      result = driver(arrayListOf(0, 0, 0, 1, 1, 1, 1), 3, 5, 3)
      println("TEST-8...${result}")
      
      result = driver(arrayListOf(85, 59, 22, 52, 93, 14, 42, 71, 69, 15, 52, 78, 35, 61, 92, 90, 70, 48, 47, 72, 74, 46, 22, 74, 83, 32, 14, 24, 18, 27, 18, 68, 29, 31), 19, 33, 0)
      println("TEST-9...${result}")
      
          
  }
  
  main()
question_info.entry_fn_name: lowerInsertionPoint
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