12
2
Here is the code which I want to shorten.
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
Input: 3
4643 5913 4827 9752
5583 5357 5120 9400
2025 5475 4339 8392
Output:
black
yellow
black
2Mind explaining what exactly what this is for, and what you're doing? – Okx – 2017-10-15T18:47:43.413
This is off topic imo. There is no "winner" and tips are more general. – Christopher – 2017-10-15T19:04:27.677
8@Christopher2EZ4RTZ we had many questions like that one before. they are not off topic, this had been discussed for a long time – Uriel – 2017-10-15T19:05:03.907
13
For the close voters, golfing tips questions are perfectly on-topic here, as decided on meta
– caird coinheringaahing – 2017-10-15T19:07:24.9271Can you give us the problem statement? – xnor – 2017-10-15T19:12:46.833
Does this even work? Doesn’t the input have to be made into an int? – Tim – 2017-10-15T23:29:42.563
@Tim Although the question doesn't state it, the code is in Python 2, where
input()
is equivalent toeval(input())
in Python 3. – totallyhuman – 2017-10-15T23:44:17.890