Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Game of Piles Version 2 codechef solution

for _ in range(int(input())):
    n = int(input())
    arr = list(map(int,input().split()))[:n]
    b = 0
    c = 0
    d = 0
    e = 0
    f = 0
    for i in range(n):
        if arr[i] == 1:
            d += 1
        else:

            if arr[i] == 2:
                c += 1
            e += arr[i]
            f += 1
            if arr[i]%2 != 0:
                b += 1

    if d == 1:
        if b%2 == 0:
            print("CHEF")
            continue
        if c == 0:
            print("CHEFINA")
            continue
        e -= 2
        f -= 1
        if (e-f)%2 != 0:
            print("CHEFINA")
            continue
        else:
            print("CHEF")
            continue
    elif d>1:
        if (e-f)%2 != 0:
            print("CHEF")
            continue
        else:
            print("CHEFINA")
            continue
    if b%2 != 0:
        print("CHEF")
        continue
    else:
        print("CHEFINA")
        continue
 
PREVIOUS NEXT
Tagged: #Game #Piles #Version #codechef #solution
ADD COMMENT
Topic
Name
9+8 =