Firstly, I start with sorted trial data:
[[ 2, 4, 9, 10, 11],
[ 2, 6, 7, 8, 14],
[ 3, 6, 8, 8, 11],
[ 4, 6, 10, 11, 13],
[ 2, 3, 3, 5, 6],
[ 3, 5, 12, 12, 13],
[ 2, 2, 3, 9, 11],
[ 2, 5, 11, 11, 13],
[ 3, 5, 7, 9, 10],
[ 2, 6, 7, 8, 14]]
Then my goal is return a True or False in the place of each array within and then print out the number of True (contiguous arrays)
So far, I have done this:
def isStraight(arr, n):
for i in range(1,n):
if (arr[i] - arr[i-1] > 1) :
return 0
return 1
but it returns an error saying
The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
So I am not sure how to implement another for loop to iterate through the internal arrays. Any help would be appreciated.