I need help in coding a function that tells if two tiles(tile1 & tile2) in a rec
ID: 3550583 • Letter: I
Question
I need help in coding a function that tells if two tiles(tile1 & tile2) in a rectangular grid are adjacent or not. If they are adjacent, it will return True. If they are not adjacent or don't share the same point in the grid, it will return False. Tiles must be unique in order to be adjacent. The function is "def neighborTile(width, height, tile1, tile2)" The second function will find the shortest distance between two tiles in a rectangular grid. Here is a picture of an example of 4x3 rectangular grid. ex--neighborTile(4, 3, 1,2)...return True and neignborTile(4,3,1,7) return False..Explanation / Answer
See this: http://ideone.com/sKhZiz
Updated code: http://ideone.com/ee1j5U
It has both sourcecode and output when executed.
I assumed that 1 and 6 are adjacent.
If you have any questions or want to change something, please let me know in the comments.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.