Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Game of Piles Version 2

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
Comment

PREVIOUS NEXT
Code Example
Python :: python slice notation 
Python :: how to make python file executable 
Python :: vim run python current file 
Python :: numpy expand_dims 
Python :: filter in pandas 
Python :: map and filter in python 
Python :: tensorflow matrix multiplication 
Python :: xargs to copy file from text files to another directory 
Python :: Python numpy.broadcast_to() Function Example 
Python :: How to know size of Python list 
Python :: loop indexing 
Python :: python turtle jupyter notebook 
Python :: digit sum codechef 
Python :: python find file name 
Python :: group by pandas count 
Python :: break all loops 
Python :: python negative indexing 
Python :: Error: The file/path provided (flaskr) does not appear to exist. Please verify the path is correct. If app is not on PYTHONPATH, ensure the extension is .py 
Python :: python md5sum 
Python :: python generate list 
Python :: list files in python 
Python :: oversampling using smote 
Python :: python how to show package version 
Python :: combination without repetition python 
Python :: subset a list python 
Python :: python pd.Timestamp add days 
Python :: queue using linked list in python 
Python :: split pandas dataframe in two 
Python :: split list on every nth element python 
Python :: input pythhon 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =