Index of First Element Greater Than Given Integer

Given a list of integers, this function returns the index of the first element that is greater than the given integer.

Problem

Given a list of integers, write a function that returns the index of the first element that is greater than the given integer.
Example input:
list = [1, 2, 3, 4, 5]
given integer = 3
Example output:
3

Solution

This solution is in Python. Our A.I. can create solutions in multiple languages.
by elrichendelgart
def find_index(list, integer):
    for i in range(len(list)):
        if list[i] > integer:
            return i
    return -1

print(find_index([1, 2, 3, 4, 5], 3))

A.I. Evaluation of the Solution

The candidate's solution correctly returns the index of the first element that is greater than the given integer. The candidate's approach is to iterate through the list and compare each element to the given integer. If the element is greater than the given integer, the index of that element is returned. If no element in the list is greater than the given integer, the candidate returns -1.

Evaluated at: 2022-11-07 01:02:30