Rohan, you should never hard code so many results. They are error prone.
Not in real life code, not in competitions.
Regards, Atif

 Tue, 21 Apr, 2020, 9:51 PM Rohan Shukla, <[email protected]> wrote:

> Thanks Matt.
>
> I completely messed up the directions.
> The loop logic was right. It was the directions.
> Made the necessary changes, it passed all test cases.
>
> Thanks!
>
> On Tuesday, April 21, 2020 at 4:05:31 AM UTC+5:30, Matt Fenlon wrote:
>>
>> Some of the hardcoded conditions/appends are out of whack. For example,
>> X1==4 and Y1==1 should be SNE, not NSE. Also, down below these conditions,
>> when X<0, we need to change E and W, not N and S. The opposite is true for
>> when Y<0. When all these get corrected, the code passes Test Set 1. For
>> Test Set 2, I imagine there is something up with the logic in the loop when
>> X>4 and Y>4. I leave it to you to check out the Analysis and work it out:
>> https://codingcompetitions.withgoogle.com/codejam/round/000000000019fef2/00000000002d5b62
>>
>> Best,
>> Matt
>>
>> On Monday, April 20, 2020 at 12:38:32 PM UTC-4, Rohan Shukla wrote:
>>>
>>> Just attempted the GCJ 2020 : Round 1B. I was able to solve Blindfolded
>>> Bullseye but my code for Expogo gave wrong answer. Would have got a good
>>> score if I could have cracked this as well.
>>> Here's my python3 code.
>>>
>>> T = int(input())
>>> t = 1
>>> while(t <= T):
>>>     res = ""
>>>     Y = input().split(" ")
>>>     X = int(Y[0])
>>>     Y = int(Y[1])
>>>     X1 = abs(X)
>>>     Y1 = abs(Y)
>>>     while(X1 > 4 or Y1 > 4):
>>>         if((X1+Y1)%2 == 0):
>>>             res = "IMPOSSIBLE"
>>>             break
>>>         else:
>>>             if(X1 % 2 != 0):
>>>                 c1 = (X1+1)//2 + (Y1)//2
>>>                 c2 = (X1-1)//2 + (Y1)//2
>>>                 if(c1 % 2 == 0):
>>>                     res += "E"
>>>                     X1 = (X1-1)//2
>>>                 else:
>>>                     res += "W"
>>>                     X1 = (X1+1)//2
>>>                 Y1 //= 2
>>>             elif(Y1 % 2 != 0):
>>>                 c1 = (Y1+1)//2 + (X1)//2
>>>                 c2 = (Y1-1)//2 + (X1)//2
>>>                 if(c1 % 2 == 0):
>>>                     res += "S"
>>>                     Y1 = (Y1-1)//2
>>>                 else:
>>>                     res += "N"
>>>                     Y1 = (Y1+1)//2
>>>                 X1 //= 2
>>>             else:
>>>                 break
>>>     if(X1 == 0 and Y1 == 1):
>>>         res += "S"
>>>     elif(X1 == 1 and Y1 == 0):
>>>         res += "E"
>>>     elif(X1 == 0 and Y1 == 3):
>>>         res += "SS"
>>>     elif(X1 == 3 and Y1 == 0):
>>>         res += "EE"
>>>     elif(X1 == 1 and Y1 == 2):
>>>         res += "ES"
>>>     elif(X1 == 2 and Y1 == 1):
>>>         res += "SE"
>>>     elif(X1 == 2 and Y1 == 3):
>>>         res += "SEN"
>>>     elif(X1 == 3 and Y1 == 2):
>>>         res += "ESW"
>>>     elif(X1 == 1 and Y1 == 4):
>>>         res += "WES"
>>>     elif(X1 == 4 and Y1 == 1):
>>>         res += "NSE"
>>>     elif(X1 == 3 and Y1 == 4):
>>>         res += "EES"
>>>     elif(X1 == 4 and Y1 == 3):
>>>         res += "SSE"
>>>     else:
>>>         res = "IMPOSSIBLE"
>>>     if(res != "IMPOSSIBLE"):
>>>         l = list(res)
>>>         if(X < 0):
>>>             for i in range(len(l)):
>>>                 if(l[i] == "S"):
>>>                     l[i] = 'N'
>>>                 elif(l[i] == 'N'):
>>>                     l[i] = 'S'
>>>         if(Y < 0):
>>>             for i in range(len(l)):
>>>                 if(l[i] == "E"):
>>>                     l[i] = 'W'
>>>                 elif(l[i] == 'W'):
>>>                     l[i] = 'E'
>>>         res = ''.join([str(elem) for elem in l])
>>>     print("Case #{}: {}".format(t,res))
>>>     t += 1
>>>
>>> Would be great if someone could point out my mistake.
>>>
>>> Thanks in advance!
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/eed7128e-aeb5-4f9b-9d6e-e4a170109a9a%40googlegroups.com
> <https://groups.google.com/d/msgid/google-code/eed7128e-aeb5-4f9b-9d6e-e4a170109a9a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CAHri%2BDwpToB6XJADxoeCro6y7%3DpyKC6k-KOqxhqvFMdYYR9J%2BQ%40mail.gmail.com.

Reply via email to