Human-written demonstration (OpenAssistant volunteers)· OpenAssistant (human-written)
OpenAssistant Conversations (oasst2)
Напиши код функции на языке Python для нахождения локальных максимумов и минимумов…
In OpenAssistant data, “assistant” turns were written by human volunteers as demonstrations. They are not model outputs.
- User
Напиши код функции на языке Python для нахождения локальных максимумов и минимумов одномерной функции заданной списком чисел.
- Assistant
def max_min(arr): lmax = [] for ind, x in enumerate(arr[1:-1]): if x > arr[ind+1] and x > arr[ind-1]: lmax.append(ind) lmin = [] for ind, x in enumerate(arr[1:-1]): if x < arr[ind+1] and x < arr[ind-1]: lmin.append(ind) lmin = [] return (lmax, lmin)
maxmin = max_min([1, 2, 3, 4, 3, 2, 4, 3, 2]) local_maximum = maxmin[0] # Список локальных максимумов local_minimum = maxmin[1] # Список локальных минимумов
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.