Advertisement
Guest User

Untitled

a guest
Dec 8th, 2022
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. Programming Problem
  2.  
  3. Introduction
  4. Design & implement a solution using C# to solve the problem described below. The objective of the problem is to allow the candidate to demonstrate their design principles and development skills. The problem is provided with sample data to be used for testing and the candidate should be able to demonstrate their solution using the supplied data in the form of a unit test or a simple user interface.
  5.  
  6. Expected Outcome
  7. On completion of this task, we expect to receive an architecture & design overview describing your application design of the entire solution. Specifically, we are interested in seeing:
  8. • List of assumptions that you made
  9. • An estimate of how long this would take if you were asked to build the entire solution for a customer
  10. • Source code (including any automated tests)
  11.  
  12. Problem: Martian Robots
  13. The surface of Mars can be modelled by a rectangular grid around which robots are able to move according to instructions provided from Earth. You are to write a program that determines each sequence of robot positions and reports the final position of the robot.
  14. A robot position consists of a grid coordinate (a pair of integers: x-coordinate followed by y-coordinate) and an orientation (N, S, E, W for north, south, east, and west).
  15. A robot instruction is a string of the letters “L”, “R”, and “F” which represent, respectively, the instructions:
  16. • Left: the robot turns left 90 degrees and remains on the current grid point.
  17. • Right: the robot turns right 90 degrees and remains on the current grid point.
  18. • Forward: the robot moves forward one grid point in the direction of the current orientation and maintains the same orientation. The direction North corresponds to the direction from grid point (x, y) to grid point (x, y+1). There is also a possibility that additional command types maybe required in the future and provision should be made for this.
  19. Since the grid is rectangular and bounded, a robot that moves “off” an edge of the grid is lost forever. However, lost robots leave a robot “scent” that prohibits future robots from dropping off the world at the same grid point. The scent is left at the last grid position the robot occupied before disappearing over the edge. An instruction to move “off” the world from a grid point from which a robot has been previously lost is simply ignored by the current robot.
  20.  
  21. Input
  22. The first line of input is the upper-right coordinates of the rectangular world, the lower-left coordinates are assumed to be 0,0.
  23. The remaining input consists of a sequence of robot positions and instructions (two lines per robot).
  24. A position consists of two integers specifying the initial coordinates of the robot and an orientation (N, S, E, W), all separated by white space on one line. A robot instruction is a string of the letters “L”, “R”, and “F” on one line.
  25. Each robot is processed sequentially, i.e., finishes executing the robot instructions before the next robot begins execution.
  26. The maximum value for any coordinate is 50. All instruction strings will be less than 100 characters in length.
  27.  
  28. Output
  29. For each robot position/instruction in the input, the output should indicate the final grid position and orientation of the robot. If a robot falls off the edge of the grid the word “LOST” should be printed after the position and orientation.
  30.  
  31. Sample Input
  32. 5 3
  33. 1 1 E
  34. RFRFRFRF
  35. 3 2 N
  36. FRRFLLFFRRFLL
  37. 03 W
  38. LLFFFLFLFL
  39.  
  40. Sample Output
  41. 11 E
  42. 3 3 N LOST
  43. 2 3 S
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement