We all know that a lot of exercises only affect one half of your body, so you have to do them twice, once for each side. Such exercises have two counterparts, one for the left side and one for the right. However, there's no need to execute the two counterparts consecutively, as long as the exercises for both sides are in the same order. You may as well switch between sides in your exercise program, but it wouldn't make sense to start some exercises with one side and some with the other.
Challenge
An exercise part is a list of non-zero integers, where its second half consists of the integers of the first half negated and in the same order, and the signs of the integers on each half are equal. The sign of the first half of an exercise part is its leading side.
An exercise set is zero or more exercise parts with the same leading side concatenated together.
Given a list of non-zero integers as input, determine if it is an exercise set. The integers aren't necessarily unique. The list's length isn't necessarily even.
Your solution may not use any of the standard loopholes. You may use any two different consistent values for output. This is code-golf, so the shortest solution wins.
Examples
[-5, -1, -7, -6, -5, 5, 1, 7, 6, 5]
is an example of an exercise part. The first half is [-5, -1, -7, -6, -5]
, and the last half is [5, 1, 7, 6, 5]
, which is each integer in the first half negated. Additionally, the first half's integers are all of the same sign. This exercise part's leading side is -1
.
[3, 6, 5, -3, -6, -5, 1, 6, 4, 3, -1, -6, -4, -3]
is an example of an exercise set. Its individual exercise parts are [3, 6, 5, -3, -6, -5]
and [1, 6, 4, 3, -1, -6, -4, -3]
, and they both have leading side 1
.
[4, -4, -5, 5]
, despite only consisting of valid exercise parts, isn't an exercise set, since the first part, [4, -4]
, has leading side 1
, while the second part, [-5, 5]
, has leading side -1
.
Test cases
Valid test cases:
[]
[1, -1]
[1, -1, 1, -1]
[-6, 6, -5, -4, -3, 5, 4, 3]
[-1, -5, -8, 1, 5, 8, -7, -6, -5, -3, 7, 6, 5, 3]
[-1, -5, -8, 1, 5, 8, -1, 1]
Invalid test cases:
[1]
[1, -2]
[1, 2, -3, -1, -2, 3]
[1, 2, 3, -3, -1, -2]
[-1, -5, -8, 1, 5, 8, 7, 6, 5, 3, -7, -6, -5, -3]
[1, 2, 3, 5, 1, 2, 3, 5]
[1, 2, -5, 4, -6, 5, 5, -6]
[1, 2, -1, 3, -2, -3]
[1, -2, 1]
[-1, -1, 1]
[1, -1, 1]