head of even length. Counting positions from zero, every even position holds an even number and every odd position holds an odd number.
Split the list into neighbouring pairs: nodes 0 and 1, nodes 2 and 3, and so on. Within each pair the two numbers duel:
- if the number at the odd position is larger, team "Odd" scores a point;
- if the number at the even position is larger, team "Even" scores a point.
Return the name of the team with more points, or "Tie" if the scores are equal.head=list_node([8, 3, 2, 9, 6, 1]) → 'Even'
The pairs are (8, 3), won by Even, (2, 9), won by Odd, and (6, 1), won by Even. Even wins 2 to 1.
head=list_node([10, 11, 12, 5]) → 'Tie'
(10, 11) gives Odd a point and (12, 5) gives Even a point. It is 1 to 1, so the answer is Tie.
head=list_node([2, 7]) → 'Odd'
head=list_node([8, 3, 2, 9, 6, 1])
'Even'
Run checks the first 3 tests in your browser. Submit checks all 91 tests on the server, hidden ones included.