title: Check If X Can Give Change To Every Person In The Queue
signature: function check_if_x_can_give_change_to_every_person_in_the_queue(notes, n)
source_py: def check_if_x_can_give_change_to_every_person_in_the_queue(notes, n):
      fiveCount = 0
      tenCount = 0
      for i in range(n):
          if (notes[i] == 5):
              fiveCount += 1
          elif (notes[i] == 10):
              if (fiveCount > 0):
                  fiveCount -= 1
                  tenCount += 1
              else:
                  return 0
          elif ((fiveCount > 0) and (tenCount > 0)):
              fiveCount -= 1
              tenCount -= 1
          elif (fiveCount >= 3):
              fiveCount -= 3
          else:
              return 0
      return 1
source_cpp: int check_if_x_can_give_change_to_every_person_in_the_queue(vector<int> notes, int n) {
    int fiveCount = 0;
    int tenCount = 0;
    for ( int i = 0;
    i < n;
    i ++ ) {
      if ( notes [ i ] == 5 ) fiveCount ++;
      else if ( notes [ i ] == 10 ) {
        if ( fiveCount > 0 ) {
          fiveCount --;
          tenCount ++;
        }
        else return 0;
      }
      else {
        if ( fiveCount > 0 && tenCount > 0 ) {
          fiveCount --;
          tenCount --;
        }
        else if ( fiveCount >= 3 ) {
          fiveCount -= 3;
        }
        else return 0;
      }
    }
    return 1;
  }
question_info.entry_fn_name: check_if_x_can_give_change_to_every_person_in_the_queue
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(notes, n, expected)
      local exec_result;
      local status, error_msg = pcall(function () 
          exec_result=PLACEHOLDER_FN_NAME(notes, 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({5, 5, 5, 10, 20}, 4, 1)
      print(string.format("TEST-0...%s",result))
  
      result = driver({5, 5, 5, 20, 10}, 5, 0)
      print(string.format("TEST-1...%s",result))
  
      result = driver({5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10}, 27, 1)
      print(string.format("TEST-2...%s",result))
  
      result = driver({10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 18}, 12, 0)
      print(string.format("TEST-3...%s",result))
  
      result = driver({5, 5, 20}, 2, 1)
      print(string.format("TEST-4...%s",result))
  
      result = driver({10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, 17, 0)
      print(string.format("TEST-5...%s",result))
  
      result = driver({5, 10, 20, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, 7, 0)
      print(string.format("TEST-6...%s",result))
  
      result = driver({-82, -10, -78, -84, 68, 62, 10, 20, -86, -98, 92, 70, 40, -12, -20, -36, 8, -70, 6, 8, 44, -24, 8, -18, 76, -54, -14, -94, -68, -62, -24, -36, -74, 92, 92, -80, 48, 56, 94}, 31, 0)
      print(string.format("TEST-7...%s",result))
  
      result = driver({10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5}, 25, 0)
      print(string.format("TEST-8...%s",result))
  
      result = driver({46, 46, 93, 57, 82, 34, 83, 80, 77, 36, 80, 85, 69, 28, 9, 56, 49, 27, 83, 25, 1, 80, 99, 14, 69, 82, 79, 71, 74, 34}, 20, 0)
      print(string.format("TEST-9...%s",result))
  
  end
  
  main()
question_info.test_list: [{"idx": 0, "outputs": 1, "inputs": {"notes": [5, 5, 5, 10, 20], "n": 4}}, {"idx": 1, "outputs": 0, "inputs": {"notes": [5, 5, 5, 20, 10], "n": 5}}, {"idx": 2, "outputs": 1, "inputs": {"notes": [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10], "n": 27}}, {"idx": 3, "outputs": 0, "inputs": {"notes": [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 18], "n": 12}}, {"idx": 4, "outputs": 1, "inputs": {"notes": [5, 5, 20], "n": 2}}, {"idx": 5, "outputs": 0, "inputs": {"notes": [10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], "n": 17}}, {"idx": 6, "outputs": 0, "inputs": {"notes": [5, 10, 20, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], "n": 7}}, {"idx": 7, "outputs": 0, "inputs": {"notes": [-82, -10, -78, -84, 68, 62, 10, 20, -86, -98, 92, 70, 40, -12, -20, -36, 8, -70, 6, 8, 44, -24, 8, -18, 76, -54, -14, -94, -68, -62, -24, -36, -74, 92, 92, -80, 48, 56, 94], "n": 31}}, {"idx": 8, "outputs": 0, "inputs": {"notes": [10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5], "n": 25}}, {"idx": 9, "outputs": 0, "inputs": {"notes": [46, 46, 93, 57, 82, 34, 83, 80, 77, 36, 80, 85, 69, 28, 9, 56, 49, 27, 83, 25, 1, 80, 99, 14, 69, 82, 79, 71, 74, 34], "n": 20}}]