in reply to Re: More simple math.
in thread More simple math.

Huh! How on earth did you come up with that?

Weirdly (or not) it adapts to the variables in my use case.

Splitting the sequence into 2 parts or 8 parts is a logical extension:

[0] Perl> print join ' ', map $_^14, 0..15;; 14 15 12 13 10 11 8 9 6 7 4 5 2 3 0 1 [0] Perl> print join ' ', map $_^8, 0..15;; 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7

And works for longer sequences (provided they are powers of two; which is a distinct possibility for my purpose):

[0] Perl> print join ' ', map $_^8, 0..31;; 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 24 25 26 27 28 29 30 31 16 17 18 + 19 20 21 22 23 [0] Perl> print join ' ', map $_^16, 0..31;; 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0 1 2 3 4 5 6 7 8 9 10 + 11 12 13 14 15 [0] Perl> print join ' ', map $_^24, 0..31;; 24 25 26 27 28 29 30 31 16 17 18 19 20 21 22 23 8 9 10 11 12 13 14 15 +0 1 2 3 4 5 6 7 [0] Perl> print join ' ', map $_^28, 0..31;; 28 29 30 31 24 25 26 27 20 21 22 23 16 17 18 19 12 13 14 15 8 9 10 11 +4 5 6 7 0 1 2 3 [0] Perl> print join ' ', map $_^30, 0..31;; 30 31 28 29 26 27 24 25 22 23 20 21 18 19 16 17 14 15 12 13 10 11 8 9 +6 7 4 5 2 3 0 1

Just a shame it produces out-of-bounds values for non-powers-of-two:

[0] Perl> print join ' ', map $_^10, 0..19;; 10 11 8 9 14 15 12 13 2 3 0 1 6 7 4 5 26 27 24 25

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Replies are listed 'Best First'.
Re^3: More simple math.
by hdb (Monsignor) on Mar 12, 2015 at 18:32 UTC

    Step 1: this is obviously a problem to be solved in base 4, so translate both rows into base 4.

    Step 2: last digit is the same between rows, first one is reversed

    Step 3: reversing first digit is XOR with 0b1100 which is 12

      The explanation is almost better than the solution :) Thanks.

      There's a thread around here asking for uses of xor, you should add this one.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
      In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked