[SOLVED] Logical error ! A Codechef Problem !
https://www.codechef.com/problems/GIFTSRC SEE this problem And see the second rest case and third also What do you think about that , i think the second test case must give out 0,0 But i wonder how it is outputting -1 1 according to Codechef Here's My Try https://code.sololearn.com/cv9jq8y0y1eN/?ref=app I wanna You to explain me how the second and third test case over there gone that way
3/24/2020 10:22:21 AM
Monkey D. Luffy
11 Answers
New AnswerAaditay Garg read the problem carefully. It says that if consecutive moves are along SAME AXIS then it will not move which means LLRRU will only be treated as as LU.
Check line 31 : ``` if moves[i] == moves[i-1] : ``` I think you were trying to check whether a charecter is equal to charecter preceding it. range(len(moves)) will generate iterable with elements starting from 0 upto len(moves)-1 so during first iteration counter `i` will be 0 and when you compare moves[i] with moves[i-1] you are comparing first element with last. (list[-1] gives last element of list) You can try using range(1,len(moves)). I don't know whether it works , that site requires me to create account for submitting code.
Oh thanks i interpreted LLLRUUD as LRUD and thus arrived at 0,0 Thanks Guys Arsenic Oma Falk ๐ฎ๐ณOmkar๐.isActive = ![ ];
๐ฎ๐ณOmkar๐.isActive = ![ ]; Wow! thanks for finding that loophole And fixing it out also
Aaditay Garg I used C++ to solve this problem. But I think you will understand my logic behind it just by looking at the code only(do let me know if you don't understand it)๐ https://code.sololearn.com/coRsaIEEzBGg/?ref=app EDIT:- now I have done commenting in the code to make it more understandable to you๐จ๐ผโ๐ป๐
Arsenic Oma Falk https://code.sololearn.com/cv9jq8y0y1eN/?ref=app This is what i have done to deal with SAME axis But this is not working, I don't think that Using ascii is ideal way to deal with this So , i wanna hear from you what way would you use to deal with same ? ๐ค