title: Floor In A Sorted Array 1
signature: def floor_in_a_sorted_array_1(arr, low, high, x):
source_py: def floor_in_a_sorted_array_1(arr, low, high, x):
      if (low > high):
          return (- 1)
      if (x >= arr[high]):
          return high
      mid = int(((low + high) / 2))
      if (arr[mid] == x):
          return mid
      if ((mid > 0) and (arr[(mid - 1)] <= x) and (x < arr[mid])):
          return (mid - 1)
      if (x < arr[mid]):
          return floor_in_a_sorted_array_1(arr, low, (mid - 1), x)
      return floor_in_a_sorted_array_1(arr, (mid + 1), high, x)
source_cpp: int floor_in_a_sorted_array_1(vector<int> arr, int low, int high, int x) {
    if ( low > high ) return - 1;
    if ( x >= arr [ high ] ) return high;
    int mid = ( low + high ) / 2;
    if ( arr [ mid ] == x ) return mid;
    if ( mid > 0 && arr [ mid - 1 ] <= x && x < arr [ mid ] ) return mid - 1;
    if ( x < arr [ mid ] ) return floor_in_a_sorted_array_1 ( arr, low, mid - 1, x );
    return floor_in_a_sorted_array_1 ( arr, mid + 1, high, x );
  }
question_info.test_code: import array
  import bisect
  import collections
  import datetime
  import functools
  import heapq
  import itertools
  import math
  import queue
  import re
  import string
  import sys
  from typing import Any, Dict, List, Optional, Set
  
  
  # SOLUTION CODE
  # ============================================
  PLACEHOLDER_CODE_BODY
  
  # TESTING CODE 
  # ============================================
  def validate_solution(actual, expected):
      return actual == expected
  
  def driver(arr, low, high, x, expected):
      try:
          if validate_solution(PLACEHOLDER_FN_NAME(
              arr, low, high, x),
              expected
          ):
              return "PASSED"
          return "FAILED"
      except Exception as exception_obj:
          return type(exception_obj).__name__
      
  if __name__ == "__main__":
      result = driver([5, 11, 20, 42, 42, 55, 58, 98, 99], 5, 7, 6, -1)
      print(f"TEST-0...{result}")
  
      result = driver([50, -90, -38, -46, -10, -22, -66, 72, -52, 38, 90, 34, -12, -44, -6, 0, -20, -38, 86, 26, 64, -24, 40, 90, -26, -2, -28, 12, 22, -14], 26, 28, 23, 28)
      print(f"TEST-1...{result}")
  
      result = driver([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1], 11, 9, 18, -1)
      print(f"TEST-2...{result}")
  
      result = driver([69, 28, 68, 98, 24, 67, 86, 2, 18, 22, 44, 77, 52, 62, 24, 46], 15, 11, 13, -1)
      print(f"TEST-3...{result}")
  
      result = driver([-96, -94, -88, -84, -68, -60, -52, -52, -42, -34, -32, -16, -12, -6, -6, -4, -2, 0, 16, 18, 38, 58, 70, 72, 76, 78, 90, 92, 98], 22, 27, 20, -1)
      print(f"TEST-4...{result}")
  
      result = driver([0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0], 24, 15, 26, -1)
      print(f"TEST-5...{result}")
  
      result = driver([1, 6, 7, 9, 10, 11, 19, 19, 22, 22, 26, 34, 36, 37, 37, 38, 39, 40, 49, 54, 60, 62, 65, 67, 71, 76, 78, 79, 82, 82, 89, 95, 97], 22, 26, 25, -1)
      print(f"TEST-6...{result}")
  
      result = driver([76, -32, -98, -18, -80, 74, -22, -82, 40, -64, 58, -18, -64, 34, -44, -82, -46, 62, -80, -76, 32, 44, -32, 98, -26, 62, 16, 86, -52, -72, -90, -30, 6], 28, 31, 24, 31)
      print(f"TEST-7...{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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 28, 29, 30, 29)
      print(f"TEST-8...{result}")
  
      result = driver([81, 69, 15, 52, 49, 54, 18, 92, 33, 21, 91, 21, 5, 25, 77, 92, 26, 58, 72, 55, 76, 18, 13, 59, 9, 12, 31, 24, 36, 33, 71, 87, 55, 19, 42, 25], 35, 19, 33, -1)
      print(f"TEST-9...{result}")
  
      sys.exit(0)
question_info.test_case_ids: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
question_info.entry_fn_name: floor_in_a_sorted_array_1
question_info.test_list: [{"idx": 0, "outputs": -1, "inputs": {"arr": [5, 11, 20, 42, 42, 55, 58, 98, 99], "low": 5, "high": 7, "x": 6}}, {"idx": 1, "outputs": 28, "inputs": {"arr": [50, -90, -38, -46, -10, -22, -66, 72, -52, 38, 90, 34, -12, -44, -6, 0, -20, -38, 86, 26, 64, -24, 40, 90, -26, -2, -28, 12, 22, -14], "low": 26, "high": 28, "x": 23}}, {"idx": 2, "outputs": -1, "inputs": {"arr": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1], "low": 11, "high": 9, "x": 18}}, {"idx": 3, "outputs": -1, "inputs": {"arr": [69, 28, 68, 98, 24, 67, 86, 2, 18, 22, 44, 77, 52, 62, 24, 46], "low": 15, "high": 11, "x": 13}}, {"idx": 4, "outputs": -1, "inputs": {"arr": [-96, -94, -88, -84, -68, -60, -52, -52, -42, -34, -32, -16, -12, -6, -6, -4, -2, 0, 16, 18, 38, 58, 70, 72, 76, 78, 90, 92, 98], "low": 22, "high": 27, "x": 20}}, {"idx": 5, "outputs": -1, "inputs": {"arr": [0, 1, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0], "low": 24, "high": 15, "x": 26}}, {"idx": 6, "outputs": -1, "inputs": {"arr": [1, 6, 7, 9, 10, 11, 19, 19, 22, 22, 26, 34, 36, 37, 37, 38, 39, 40, 49, 54, 60, 62, 65, 67, 71, 76, 78, 79, 82, 82, 89, 95, 97], "low": 22, "high": 26, "x": 25}}, {"idx": 7, "outputs": 31, "inputs": {"arr": [76, -32, -98, -18, -80, 74, -22, -82, 40, -64, 58, -18, -64, 34, -44, -82, -46, 62, -80, -76, 32, 44, -32, 98, -26, 62, 16, 86, -52, -72, -90, -30, 6], "low": 28, "high": 31, "x": 24}}, {"idx": 8, "outputs": 29, "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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "low": 28, "high": 29, "x": 30}}, {"idx": 9, "outputs": -1, "inputs": {"arr": [81, 69, 15, 52, 49, 54, 18, 92, 33, 21, 91, 21, 5, 25, 77, 92, 26, 58, 72, 55, 76, 18, 13, 59, 9, 12, 31, 24, 36, 33, 71, 87, 55, 19, 42, 25], "low": 35, "high": 19, "x": 33}}]
question_info.entry_cls_name: Solution