Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 462059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:02:12+00:00 2026-05-12T23:02:12+00:00

Say we have a set of 3D (integer) coordinates from (0,0,0) to (100,100,100) We

  • 0

Say we have a set of 3D (integer) coordinates from (0,0,0) to (100,100,100)
We want to visit each possible coordinate (100^3 possible coordinates to visit) without visiting each coordinate more than once.

The sum of the differences between each coordinate in adjacent steps cannot be more than 2 (I don’t know if this is possible. If not, then minimized)
for example, the step from (0,2,1) to (2,0,0) has a total difference of 5 because |x1-x2|+|y1-y2|+|z1-z2| = 5

How do we generate such a sequence of coordinates?

for example, to start:
(0,0,0)
(0,0,1)
(0,1,0)
(1,0,0)
(1,0,1)
(0,0,2)
(0,1,1)
(0,2,0)
(1,1,0)
(2,0,0)
(3,0,0)
(2,0,1)
(1,0,2)
(0,0,3)
etc…

Anyone know an algorithm that will generate such a sequence to an arbitrary coordinate (x,y,z) where x=y=z or can prove that it is impossible for such and algorithm to exist? Thanks

Extra credit: Show how to generate such a sequence with x!=y!=z 😀

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:02:13+00:00Added an answer on May 12, 2026 at 11:02 pm

    One of the tricks (there are other approaches) is to do it one line [segment] at a time, one plane [square] at a time. Addressing the last part of the question, this approach works, even if the size of the volume visited is not the same in each dimension (ex: a 100 x 6 x 33 block).

    In other words:

    Start at (0,0,0), 
    move only on the Z axis till the end of the segment, i.e.
    (0,0,1), (0,0,2), (0,0,3), ... (0,0,100), 
    Then move to the next line, i.e.
    (0,1,100)
    and come backward on the line, i.e.
    (0,1,99), (0,1,98), (0,1,97), ... (0,1,0), 
    Next to the next line, going "forward"
    
    And repeat till the whole "panel is painted", i.e ending at
    ... (0,100,99), (0,100,100),
    Then move, finally, by 1, on the X axis, i.e.
    (1,100,100)
     and repeat on the other panel,but on this panel going "upward"
    etc. 
    

    Essentially, each move is done on a single dimension, by exactly one. It is a bit as if you were “walking” from room to room in a 101 x 101 x 101 building where each room can lead to any room directly next to it on a given axis (i.e. not going joining diagonally).

    Implementing this kind of of logic in a programming language is trivial! The only mildly challenging part is to deal with the “back-and-forth”, i.e. the fact that sometimes, some of the changes in a given dimension are positive, and sometimes negative).

    Edit: (Sid’s question about doing the same diagonally):
    Yes! that would be quite possible, since the problem states that we can have a [Manhattan] distance of two, which is what is required to go diagonally.
    The path would be similar to the one listed above, i.e. doing lines, back-and-forth (only here lines of variable length), then moving to the next “panel”, in the third dimension, and repeating, only going “upward” etc.

    (0,0,0) (0,0,1)
    (0,1,0)                  first diagonal, only 1 in lengh.
    (0,2,0)                  "turn around"
    (0,1,1) (0,0,2)          second diagonal: 2 in length
    (0,0,3)                  "turn around"
    (0,1,2) (0,2,1) (0,3,0)  third diagonal: 3 in length
    (0,4,0)                  turn around
    etc.
    

    It is indeed possible to mix-and-match these approaches, both at the level of complete “panel”, for example doing one diagonally and the next one horizontally, as well as within a given panel, for example starting diagonally, but when on the top line, proceeding with the horizontal pattern, simply stopping a bit earlier when looping on the “left” side, since part of that side has been handled with the diagonals.
    Effectively this allows a rather big (but obviously finite) number of ways to “paint” the whole space. The key thing is to avoid leaving (too many) non painted adjacent area behind, for getting back to them may either bring us to a dead-end or may require a “jump” of more than 2.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

let's say I have a huge set of non-overlapping rectangle with integer coordinates, who
I have a set of rows which I've fetched from a table. Let's say
I will have an integer calculated from datediff() let's say.. it is.. declare @earliestTime
Let's say I have a Set of Integers, and I want to increment every
let's say you have set of integer in the list. List Declare: @lists =
Say I have a set myset of custom objects that may be equal although
Lets say you have a set: foo = {1, 2, 3, 4, 5} In
let's say I have this set of HTML-markup and CSS #CSS .inputhelp_text { background:
I have set a cookie in my jsp page say(A). and set its path
Lets say I have model inheritance set up in the way defined below. class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.