Python Forum
Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Neighbors of a grid
#1
Imagine that the user specifies the width and height of a grid, as well as two tiles. You will return either "True" or "False" depending on whether or not the two tiles are neighbors by sharing at least one point. For example, on a 7x10 grid,

1 2 3 4 5 6 7
8
15
22 23 24 25 26 27 28
29 30
36
43
50
57
64

tiles 1 and 2 are neighbors. Tiles 24 and 30 are also neighbors.
A tile CANNOT be a neighbor of itself.

You may use the following formulas in your solution as needed:

row = (tile - 1) // width

col = (tile - 1) % width
Reply
#2
You need to try something, and then tell us clearly how it doesn't work. We're not going to write it for you, but we will help you fix problems you run into.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
Very similar, for others reading: https://python-forum.io/Thread-Mirror-of-a-grid
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Method of k-nearest neighbors qwerty 1 2,906 May-07-2017, 06:42 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020