You have two robots. Currently, the robots are standing on two different points on an infinite two-dimensional plane. You are given the ints x1, y1, x2, and y2. These are the initial coordinates of both robots: one is located at (x1,y1), the other one is at (x2,y2).
The robots know four instructions: U, D, L, and R. These represent moving 1 unit up, down, left, and right. More formally, U increases the robot's y coordinate by 1, D decreases the y coordinate by 1, L decreases the x coordinate by 1, and R increases the x coordinate by 1.
You are going to send both robots the same sequence of instructions at the same time. This sequence of instructions is given in the String instructions.
Both robots are going to execute this sequence of instructions. They will spend exactly one second executing each instruction. Unfortunately, your robots are a bit buggy. It is possible that they will ignore some instructions and spend the corresponding seconds just standing in place. Each robot has its own bugs and therefore the two robots may ignore different subsets of instructions. (It is possible that a robot will ignore all instructions, and it is also possible that a robot will execute all instructions it was given.)
The robots will explode if they ever occupy the same point at the same time.
Return the String "Explosion" if it is possible that your two robots will explode. Otherwise, return "Safe".
|
No comments:
Post a Comment