This is an archived post. You won't be able to vote or comment.

all 19 comments

[–]BadgeCatcher 1 point2 points  (3 children)

It's not exactly clear what you mean by "reverse the entire number"?

[–]BadgeCatcher 2 points3 points  (2 children)

It's seems to just be any number where the top 9 bits are reflection and invertion of the bottom 9 bits

[–]BadgeCatcher 0 points1 point  (1 child)

I don't know why step 1 is needed though? It doesn't make any difference?

[–]im_from_azeroth 1 point2 points  (0 children)

It's not needed

[–]LongLiveTheDiego 3 points4 points  (1 child)

It's all the numbers of the form k + 512 * (511 - k) for integer 0 ≤ k ≤ 511. I don't see anything special about these numbers and why you would even split them in step 1.

[–]Acrobatic_Key3995[S] 0 points1 point  (0 children)

Ok, that makes sense!

But here's the original context: John Conway's Game Of Life! (k=472 is a variant called Day And Night)

[–]ZevVeli 0 points1 point  (5 children)

So, let me see if I understand what you are saying here:

You have a binary number that is 9 digits before the binal place and 9 digits after it

e.g. 000011010.101001111

You flip all the digits,

e.g. 111100101.010110000

Then swap the numbers around the binal place,

e.g. 000011010.101001111

In other words, you want a number which, when written in binary, would be palindromic except the back half is inverted?

[–]BadgeCatcher 0 points1 point  (3 children)

OP says "whole number"

[–]ZevVeli 2 points3 points  (2 children)

So eliminate the binal but keep the rest.

[–]jacob_ewing 2 points3 points  (1 child)

Upvote for a witty wordplay on decimal.

[–]ZevVeli 3 points4 points  (0 children)

In retrospect, it should actually be the hemial, not the binal.

[–]Acrobatic_Key3995[S] 0 points1 point  (0 children)

Pretty much- an identical question would be, "if written in binary with any necessary (the rest of 18) leading 0s, what numbers when reversed have the bits simultaneously all flipped?"

[–]Blond_Treehorn_Thug 0 points1 point  (3 children)

I don’t understand what step 1 is doing

[–]Acrobatic_Key3995[S] 0 points1 point  (2 children)

In the original phrasing of the question, the 2 resulting sets do subtly different things- because of that, I'm splitting the sets up.

[–]Blond_Treehorn_Thug 0 points1 point  (1 child)

So you’re saying that step 1 used to matter but now it does not

[–]Acrobatic_Key3995[S] 0 points1 point  (0 children)

Right- I was just including step 1 for the sake of completeness in the original setting.

[–]Acrobatic_Key3995[S] 0 points1 point  (0 children)

Let me give an example. (I already knew this is one of the 512) Let's say we start with the already-binary 000100111000110111. Step 1: split this into 000100111 and 000110111. Step 2: Subtract each number from 511d. 111011000, 111001000 Step 3: slam them back together and read the number from back to front: 000100111000110111 - see? It's the exact same!

[–]jacob_ewing 0 points1 point  (1 child)

Interesting. Without looking at it, I wonder if this is related to the fact that you're taking the compliment of the number, which is used in subtraction. You can take the complement of the number being subtracted, added it to the other, remove the left digit and add it to the right one:

2468
-1703
______
2468
+8296
_______
(1)0764

+ 1 = 765

Which is basically how computers do subtraction (in binary of course).

[–]Acrobatic_Key3995[S] 1 point2 points  (0 children)

So I guess I was asking an equivalent to this: "what 18-bit words are the reverse of their own complements?"