Codeforces 913 (Div 3) A

A. Rook


Problem : https://codeforces.com/contest/1907/problem/A

Code :

cols = ["a","b","c","d","e","f","g","h"]

n = int(input())
for case in range(n):
    cols_input = input() # d5
    c = cols.index(list(cols_input)[0]) + 1 # 3 + 1 = 4
    cr = int(list(cols_input)[1]) # 5
    
    for i in range(1,9):
        for j in range(1,9):
            if i == cr and j == c:
                continue
            else:
                if i == cr:
                    print(cols[j-1]+str(i))
                if j == c:
                    print(cols[j-1]+str(i))
        

Submission link : https://codeforces.com/contest/1907/submission/240064733



© 2024 by Chiranjeevi Karthik