Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Get the reflection of numbers

  1. Sep 7, 2011 #1

    I've this board, like shown in attachment, that has 2 rows. Each rows have 4 places. I'm trying to find a general function that gives me the reflection of the numbers.

    I've 2 questions, so I put each question in a item.

    a) Like shown in case a) of the attachment, If I write the number 1, my function must return the number 4. If I write the number 2, the function must return the number 3. If I write the number 5, must return the number 8, and if I write the number 7, it must return the number 6. And the opposite. If I write the number 4, I'll the number 1, etc...

    As you can see, I've divided the card in half, and I'm trying to get the number that is on the opposition position of the card. I'm looking for a general equation, that answers me this for any row of any size. In this example, I've use a row with 4 position, but it could have been 7, 10, 15, etc...

    Anyone can help me?

    b) On the case b) it's a little different. I'm doing a kind of displacement. If I write the number 1, I'll get the number 3. If I write the number 2, I get the number 4, and the opposite. I'm also looking for a general function that returns me the correspondent value for any size of the row.

    Any help?

  2. jcsd
  3. Sep 7, 2011 #2
    Here is the attachment.

    Attached Files:

  4. Sep 7, 2011 #3


    User Avatar
    Science Advisor

    Here's your function for (a): {(1, 4), (2, 3), (4, 1), (3, 2), (5, 8), (6, 7), (8, 5), (7, 6)}.
  5. Sep 7, 2011 #4
    I was looking for an equation, and not a function full of constants.

    Answer for a):
    I think the answer for a) is


    The [itex]\underline{}[/itex] means floor.

    The only problem with this equation is that, when (x%z+3)%z == 0, it gives x-1. For this case I've to create an exception.

    Ideally, I would like to find a general equation for all the cases, but it's not possible.

    Still missing answer for b).
    Last edited: Sep 7, 2011
  6. Sep 7, 2011 #5
    The answer in the first row is 5-the input number:

    Put in 1, get out 5-1=4
    Put in 2, get out 5-2=3

    For the second row its the same but the input numbers are 4 higher

    Put in 5, minus 4=1, 5-1=4, plus 4=8
    Put in 6, minus 4=2, 5-2=3, plus 4=7

    This can be extended to any length row and column.
  7. Sep 7, 2011 #6
    Thanks superg33k , your answer is better.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook