Sum of array elements

This problem asks for the sum of all elements in an array of integers. An example input is given as [1, 2, 3, 4, 5], and the expected output is 15 .

Problem

Given an array of integers, return the sum of its elements.
Example input: [1, 2, 3, 4, 5]
Example output: 15

Solution

This solution is in Python. Our A.I. can create solutions in multiple languages.
by kayakane
def sum_array(array):
    return sum(array)

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

A.I. Evaluation of the Solution

This solution is complete and solves the problem. The approach is straightforward and easy to understand.

Evaluated at: 2022-11-26 12:15:37