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

  • SEARCH
  • Home
  • 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 9004609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:56:03+00:00 2026-06-16T00:56:03+00:00

We have a two-dimensional array with the number 0 in the upper left corner.

  • 0

We have a two-dimensional array with the number 0 in the upper left corner. The rest of the array is then filled with numbers so that each index contains the smallest positive integer possible that already exists neither on the same row or column.

Example:

  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17
  1  0  3  2  5  4  7  6  9  8 11 10 13 12 15 14 17 16
  2  3  0  1  6  7  4  5 10 11  8  9 14 15 12 13 18 19
  3  2  1  0  7  6  5  4 11 10  9  8 15 14 13 12 19 18
  4  5  6  7  0  1  2  3 12 13 14 15  8  9 10 11 20 21
  5  4  7  6  1  0  3  2 13 12 15 14  9  8 11 10 21 20
  6  7  4  5  2  3  0  1 14 15 12 13 10 11  8  9 22 23
  7  6  5  4  3  2  1  0 15 14 13 12 11 10  9  8 23 22
  8  9 10 11 12 13 14 15  0  1  2  3  4  5  6  7 24 25
  9  8 11 10 13 12 15 14  1  0  3  2  5  4  7  6 25 24
 10 11  8  9 14 15 12 13  2  3  0  1  6  7  4  5 26 27
 11 10  9  8 15 14 13 12  3  2  1  0  7  6  5  4 27 26
 12 13 14 15  8  9 10 11  4  5  6  7  0  1  2  3 28 29
 13 12 15 14  9  8 11 10  5  4  7  6  1  0  3  2 29 28
 14 15 12 13 10 11  8  9  6  7  4  5  2  3  0  1 30 31
 15 14 13 12 11 10  9  8  7  6  5  4  3  2  1  0 31 30
 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31  0  1
 17 16 19 18 21 20 23 22 25 24 27 26 29 28 31 30  1  0

Given the row and the column in such array, I need to be able to find the number in the specified index in less than one second on a relatively new desktop PC (for row and column less than a million). My brute-force attempts so far have been so futile that it’s clearly not the way I want to go with this. Presumably there must be a way to find out the number in question, in linear time (?), that doesn’t require computing all the preceding numbers in the array.

  • 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-06-16T00:56:04+00:00Added an answer on June 16, 2026 at 12:56 am

    Observation shows that the operator is the bitwise XOR (represent each operand as a binary number, XOR together the corresponding bits, read as binary).

    Now on to prove it is the XOR:


    Since the XOR with one argument fixed is a bijection on the other argument, the “that exists neither on the same row or column” is satisfied.

    Now it just suffices to prove the “smallest” part, namely that any lower value already occurs if we reduce either operand:

    foreach A >= 0, B >= 0, F >= 0:
      (A xor B > F) => (exists D: D xor B = F) or (exists E: A xor E = F)
    

    or equivalently

    foreach 0 <= A, 0 <= B, 0 <= F < (A XOR B)
      (exists D: D xor B = F) or (exists E: A xor E = F)
    

    Note that we are no longer concerned about our operator, we’re proving the minimality of XOR.

    Define C = A xor B

    if A = 0, B = 0, then minimality is satisfied.

    Now, if A and B have the same magnitude (the same bit length), then clearing the top bit of both will not change C. Clearing the top bit is a translation towards the origin in the matrix, so if a smaller value exists above or to the left after translation, it is at the same relative position before the translation.

    A and B must have a different magnitude to be a counter-example. XOR (as well as the operator under consideration) are symmetric, so assume A > B.

    If F is of greater magnitude than A, then it’s not smaller, and thus it’s not a counter-example.

    If F has the same magnitude as A, then clear the highest bit in A and in F. This is a translation in the table. It changes the values, but not their ordering, so if a smaller value exists above or to the left after translation, it is at the same relative position before the translation.

    If F has a smaller magnitude than A, then, by the pigeonhole principle and the properties of XOR, there exists a D with a smaller magnitude than A such that D xor B = F.


    summary: The proof that XOR satisfies the conditions imposed onto the solution follows from the symmetries of XOR, its magnitude-preserving properties and its bijection properties. We can find each smaller element than A xor B by reducing A, B and the challenge until they’re all zero or of different magnitude (at which point we apply the pigeonhole principle to prove the challenge can be countered without actually countering it).

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

Sidebar

Related Questions

I have two-dimensional array of integers. First index indicates the number of channels. The
I have a two dimensional JSON array where each element contains several attributes. The
I have a two dimensional array in php that I need to express as
I have to make a two-dimensional array based on the number of lets say
I have some code that works with a two-dimensional grid (array) and I ended
I have a two dimensional array with a variable number of rows and two
I have a two-dimensional array. When I print/dump this I get the following My
I have a two dimensional array with the following output Array ( [0] =>
I have a two dimensional array public class TwoDimensions { public static void main(String[]
I have the following three arrays and need to create a new two-dimensional array

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.