-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbwf3.py
31 lines (20 loc) · 1.36 KB
/
bwf3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# On a chessboard, positions are marked with letters between a and h for the column and a
# number between 1 and 8 for the row. The first place on the board, a1, is black. The next
# is white, alternating across a row. Odd rows start with black, even rows start with white.
# Give a 2 character input string with a letter (a-h) and a number (1-8), print "Black" or
# "White" indicating if the square is black or white.
def par(n):
if n % 2 == 0:
return True
def impar(n):
if n % 2 != 0:
return True
inputStr = 'a1'
if par(int(inputStr[1])) and 'b' in inputStr or par(int(inputStr[1])) and 'd' in inputStr or par(int(inputStr[1])) and 'f' in inputStr or par(int(inputStr[1])) and 'h' in inputStr:
print("Black")
elif impar(int(inputStr[1])) and 'b' in inputStr or impar(int(inputStr[1])) and 'd' in inputStr or impar(int(inputStr[1])) and 'f' in inputStr or impar(int(inputStr[1])) and 'h' in inputStr:
print("White")
elif impar(int(inputStr[1])) and 'a' in inputStr or impar(int(inputStr[1])) and 'c' in inputStr or impar(int(inputStr[1])) and 'e' in inputStr or impar(int(inputStr[1])) and 'g' in inputStr:
print("Black")
elif par(int(inputStr[1])) and 'a' in inputStr or par(int(inputStr[1])) and 'c' in inputStr or par(int(inputStr[1])) and 'e' in inputStr or par(int(inputStr[1])) and 'g' in inputStr:
print("White")