Even vs Odd
Problem Statement
You are given an array consisting of N integers and are tasked with finding the power of even and the power of odd. The power of even is calculated as the sum of indices of the array (0 to N-1) when the element at that index is even. The power of odd is calculated as the sum of indices of the array (0 to N-1) when the element at that index is odd.
Input Format
- The first line contains an integer
T
, the number of test cases. - Each test case consists of two lines:
- The first line contains an integer
N
, the number of elements in the array. - The second line contains N space-separated integers representing the elements of the array.
- The first line contains an integer
Output Format
- For each test case, print “Even” if the even power dominates (is greater than) the odd power, “Odd” if the odd power dominates, and “Even Odd” if they are equal.
Constraints
- 1 <= T <= 100
- 1 <= N <= 100
- The elements of the array are integers.
Sample Input
Sample Output
Solution
even_vs_odd.py
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
evenSum, oddSum = 0, 0
for i in range(n):
if a[i] & 1:
oddSum += i
else:
evenSum += i
if oddSum > evenSum:
print("Odd")
elif oddSum == evenSum:
print("Even Odd")
else:
print("Even")