Voici le code que je souhaite raccourcir.
n=input()
while n:
s=raw_input()
x,r,g,b=(int(x) for x in s.split())
a=x/r%2
c=x/g%2
d=x/b%2
r=((a*10+c)*10)+d
if r==0:e="black"
elif r==100:e="red"
elif r==1:e="blue"
elif r==10:e="green"
elif r==101:e="magenta"
elif r==11:e="cyan"
elif r==110:e="yellow"
else:e="white"
print(e)
n-=1
Entrée: 3
4643 5913 4827 9752
5583 5357 5120 9400
2025 5475 4339 8392
Production:
black
yellow
black