text:
Complementary colors
Given an input of a color in #rrggbb hex format, output its RGB complement in
the same format.
The RGB complement R2G2B2 of any color
R1G1B1 is defined as the color with
R2 value 255 - R1, B2 value 255 -
B1, and G2 value 255 - G1.
Hex digits may be either in uppercase (#FFAA20) or lowercase (#ffaa20). The
case of the input and output need not be consistent (so you may take input in
lowercase but output in uppercase, and vice versa).
Since this is code-golf, the shortest code in bytes wins.
Test cases (note that since giving your program/function its own output should
result in the original input (it is
involutory), the test
cases should work in both directions):
In/Out   Out/In
----------------
#ffffff  #000000
#abcdef  #543210
#badcab  #452354
#133742  #ecc8bd
#a1b2c3  #5e4d3c
#7f7f80  #80807f

I'm sorry, but sRGB doesn't work that way. You should convert to linear space first, which hex-codes aren't in.

@JanDvorak Oh well. The state of the challenge will reflect my ignorance, then, since I can't really change it now. :P

Averaging two values in sRGB could be a decent separate challenge, though. sRGB = RGB^0.45 over most of the range, but linear near the bottom of the range.

Pyth, 9 8 bytes
Thanks to @isaacg for -1 byte!
sXz.HM16

Subtracting a certain color's value from 255 is equivalent to subtracting each of its hexadecimal digits from 15. Say a number is 16a+b. Then the value of the number created by subtracting its digits from 15 is 16(15-a) + (15-b) = 255 - (16a+b).
sXz.HM16     implicit: z=input()
      16
   .HM        map hex representation over range
   .HM16     '0123456789abcdef'
  z           the input string
 X            Translate characters in x1 present in x2 to reversed x2
              that is, '0' becomes f, '1' becomes 'e', and so on.
              The initial '#' is unchanged.
s             That produced a list, so join into a string by reducing +

Try it here. Test suite.

Nice answer! I borrowed your idea of using '0123456789abcdef' to convert to hex (instead of dec2hex function)

I think your link is incorrect. (Copy-paste FTW.)

@Pietu1998 Whoops; I'll fix it.

The U is unnecessary - it's implicitly filled in by M.

Retina, 13 10 bytes
T`w`G-A9-0

There are three parts to the code, separated by backticks (`): T specifies transliterate mode, which replaces each character in the second part with its corresponding character in the third part.
w is the same as traditional regex's \w, or _0-9A-Za-z, which is expanded to _0123456789ABCDEFGH....
The second part is expanded to GFEDCBA9876543210, thanks to Retina's nifty ability to expand in reverse order. Put these on top of each other, and we get:
_0123456789ABCDEFGH...
GFEDCBA987654321000...
 ^^^^^^^^^^^^^^^^

Note that the last character, 0, is repeated to fit the length of the longer string, but we only care about the hexadecimal characters, shown by carets.
Thanks to Martin Büttner for suggesting this approach.
Try the test suite online.

Did R not exist at the time? In 0.8.2 you can use Rd instead of 9-0, saving a byte. You can also write T`dA-F`Ro for the same 9 bytes.

Julia 0.6, 74 49 bytes
h->"#"join([hex(15-parse(Int,i,16))for i=h[2:7]])

Try it online!
Pretty long at the moment but it's a start. This is a lambda function that accepts a string and returns a string. The output will be in lowercase but the input can be in either.
As Thomas noted, subtracting each 2-digit color component from 255 is equivalent to subtracting each individual digit in the hexadecimal input from 15. Looping over the input string, excluding the leading #, we convert 15 - the parsed digit to hexadecimal. We join all of these then tack on a # and call it good.

JavaScript ES6, 61 bytes 66 68 48 53 64
Saves quite a few bytes thanks to @Cᴏɴᴏʀ O'Bʀɪᴇɴ, @NinjaBearMonkey, and @nderscore
s=>"#"+(1e5+(8**8+~('0x'+s.slice(1))).toString(16)).slice(-6)

Takes advantage of auto-type-casting. Fixing the zeros killed the byte count

Use eval(`0x${s.slice(1)}`) instead of parseInt

@CᴏɴᴏʀO'Bʀɪᴇɴ That's the same length?

@CᴏɴᴏʀO'Bʀɪᴇɴ thanks, I  used -  instead of eval which saved even more bytes

Oh, forgot about auto type casting :D

Try it with the input #FFFFFF. Returns #0.

@CᴏɴᴏʀO'Bʀɪᴇɴ thanks, didn't see that but it's fix killed the byte cubit

@Doᴡɴɢᴏᴀᴛ Yeah, sorry. Noticed it when working on a Jolf answer.

You should be able to use 1e5 instead of the string of zeroes.

-5 bytes using 1e5 and bitflip ~: s=>"#"+(1e5+(8**8+~('0x'+s.slice(1))).toString(16)).slice(-6)

Sure, but that's now ES7.

You don't have to fiddle around with zeros. Simply use 8**9 and you guarantee a leading 8 which you simply slice off: s=>'#'+(8**9+~('0x'+s.slice(1))).toString(16).slice(1) (54 bytes); ES6 version: s=>'#'+(~('0x'+s.slice(1))<<4>>>4).toString(16).slice(1) (56 bytes).

Marbelous, 41 bytes
00@0
\\]]\/
-W/\@0
-W
~~
<A+700
+O//]]
+O

Online Interpreter here. Input should be in uppercase.
Explanation
The 00 and ]] at the bottom will fetch the first character (the #) and it will fall to the bottom and be outputted before anything else.
The first 3 lines are a loop to fetch all the remaining characters.
First we need to convert the hex digit characters to 0-15, by doing x -= 48, x -= x > 9 ? 7 : 0 (since 'A' - '9' is 8).
To find the complement, we simply need to convert every digit x to 15-x. This is equivalent to (for 8-bit values) (~x)+16 = ~(x-16).
Finally, we have to convert these numbers back into hex digits, by doing x += x > 9 ? 7 : 0, x += 48.
So now we have x -= 48, x -= x > 9 ? 7 : 0, x = ~(x - 16), x += x > 9 ? 7 : 0, x += 48.
Note that if we remove the expression with the first ternary operator, then input digits A-F will result in a negative x after negation.
Thus we can change the previous expression to: x -= 48, x -= 16, x = ~x, x += (x > 9 || x < 0) ? 7 : 0, x += 48, which is equal to x -= 64, x = ~x, x += (x > 9 || x < 0) ? 7 : 0, x += 48.
The above code is just an implementation of the last expression. -W is x -= 32 and +O is x += 24. Since Marbelous uses unsigned 8-bit arithmetic, the condition <A covers both the case of x > 9 and x < 0.

Did you create Marbelous?

@RikerW Marbelous was created/fleshed out by several PPCG users including myself: See here.

Okay. Thanks for letting me know.

JavaScript ES6, 63 58 52 49 bytes
c=>c.replace(/\w/g,x=>(15-`0x${x}`).toString(16))

Thanks to nderscore for saving 11 bytes!

-5 bytes: c=>"#"+[...c].map(x=>"fedcba9876543210"[+('0x'+x)]).join\``

@nder exactly, thought about it already :) Thanks. Was going to use it, but with "eval".

ah, I've got one more -6: c=>c.replace(/\w/g,x=>"fedcba9876543210"[+('0x'+x)])

c=>c.replace(/\w/g,x=>('0x'+x^15).toString(16))

Vyxal, 4 bytes
k6ḂĿ

Try it Online!
k6ḂĿ
k6   # Hex chars - "012356789abcdef"
  Ḃ  # Bifurcate - push its reverse without popping
   Ŀ # Transliterate the input from the hex chars to the reverse hex chars

Jolf, 17 bytes
pq#-w^88C Li1~560
pq                pad
         _Li1     the input, w/out the first char
        C    ~5   parsed as a base-16 integer (~5 = 16)
    w^88          8 ^ 8 - 1 (the magic number)
   -              subtract the parsed input from said number
  #               convert result to hexadecimal
               60 pad the result with 6 0's

Try it here!, Test suite (Use full run, which now works.)

Japt, 35 32 22 20 16 15 bytes
¡Y?(F-XnG)sG :X

Explanation:
¡                 //Take input and map (shortcut to "Um@"). Input should in the form of "#123456"
 Y?               //if Y is not 0, then return (F-XnG)sG, otherwise last step...
    F-XnG           //Subtract X, converted from hexadecimal (G is 16) to decimal, from 15
          sG        //convert decimal to hexadecimal
             :X   //...otherwise return X unchanged (happens only with #, the first char)

Nice one! I saw this last night and said to myself, "Tomorrow I'll help to golf it down." But by now you've golfed it further than I thought possible. :)

Perl, 30 bytes
includes +1 for -p
s/\w/sprintf"%x",15&~hex$&/eg

usage: echo #000000 | perl -p file.pl
or echo #000000 | perl -pe 's/\w/sprintf"%x",15&~hex$&/eg'.

MATL, 21 bytes
35,5Y216,j6L)!16ZA-)h

This uses release 6.0.0 of the language/compiler, which is earlier than the challenge.
Input digits should be uppercase.
Example
This has been executed on Octave:
>> matl
 > 35,5Y216,j6L)!16ZA-)h
 >
> #FFAA20
#0055DF

Edit (June 12, 2016)
The code can now be tried online. Commas need to be replaced by spaces, and 6L by 4L, to conform to changes in the language.
Explanation
35,             % number literal: ASCII code of '#'
5Y2             % '0123456789ABCDEF'
16,             % number literal
j               % input string
6L)             % remove first element
!               % transpose
16ZA            % convert from hex to dec
-               % subtract from 16
)               % index into '0123456789ABCDEF' to convert back to hex
h               % prepend 35, which gets automatically converted into '#'

x86-16 machine code, IBM PC DOS, 60 41 32 bytes
Binary:
00000000: be82 00ac cd29 b106 ac3c 397e 022c 272c  .....)...<9~.,',
00000010: 30f6 d03c f976 0204 2704 40cd 29e2 e9c3  0..<.v..'.@.)...

Unassembled listing:
BE 0082     MOV  SI, 82H            ; command line input set to string
AC          LODSB                   ; load first '#' char
CD 29       INT  29H                ; write it to console
B1 06       MOV  CL, 6              ; loop 6 chars
        INLOOP:
AC          LODSB                   ; load next ASCII hex char into AL
3C 39       CMP  AL, '9'            ; is char an alpha (a-f)?
7E 02       JLE  NOHEX_IN           ; if not, is numeric
2C 27       SUB  AL, 'f'-'9'-6      ; otherwise ASCII adjust a-f
        NOHEX_IN:
2C 30       SUB  AL, '0'            ; ASCII to decimal convert
F6 D0       NOT  AL                 ; complement the color (magic happens here)
3C F9       CMP  AL, 0F9H           ; is char <= 9?
76 02       JBE  NOHEX_OUT          ; if not, is numeric
04 27       ADD  AL, 'f'-'9'-6      ; otherwise ASCII adjust a-f
        NOHEX_OUT:
04 40       ADD  AL, '0'+10H        ; decimal convert to ASCII
CD 29       INT  29H                ; write char to console
E2 E9       LOOP INLOOP             ; keep looping
C3          RET                     ; return to DOS

So nearly all of this code is brute-force conversion from an ASCII hex string into a numeric value and then back again.  No CPU instructions on x86-16 to help with that I'm afraid!
I/O:
Standalone PC DOS executable.  Input via command line, output to STDOUT.

Japt v2.0a0, 9 bytes
r\wÈnG'nF

Try it
r\wÈnG'nF     :Implicit input of string
r             :Replace
 \w           :  RegEx /[0-9a-z]/gi
   È          :  Pass each match through the following function
    n         :    Toggle base
     G        :      16
      'n      :    Subtracting intermediate result from
        F     :      15

Java, 95 90 bytes
String f(String v){return v.format("#%06x",0xFFFFFF^Integer.parseInt(v.substring(1),16));}

Bitwise XOR.

sed, 48 bytes
y/0123456789ABCDEFabcdef/fedcba9876543210543210/

Or 36 bytes if you only need to support one case.

You don't need to support both lowercase and uppercase.

@MartinBüttner the question seems to require support for both cases in the input, but not in the output.  Like my bash+tr solution, this solution supports both on input but only writes lower-case output.

You've got an extra 0 in your code, between the 9 and A (byte count is correct though, must be a copying error).

The question says you can choose which case your input and output are.

Pyth, 20 19 bytes
1 byte thanks to xnor.
%"#%06x"-t^8 8itz16

Try it online. Test suite.
Explanation

z is the input
tz removes the #
itz16 parses as a hexadecimal number
t^8 8 calculates 88 - 1
-t^8 8itz16 calculates 88 - 1 - input
%"#%06x"-t^2 24itz16 formats it into a zero-padded 6-character hex string and adds the #

How about 8^8 for 2^24?

Mathematica, 69 60 bytes
"#"<>IntegerString[8^8-#~StringDrop~1~FromDigits~16-1,16,6]&

Once again, it's the string processing that kills me here.

Haskell, 85 bytes
My first submission, it will probably be the longest (85 bytes) but hey, you got to start somewhere.
In Haskell:
import Numeric;f=('#':).concatMap((flip showHex)"".(15-).fst.head.readHex.(:[])).tail

It's using the same subtract from 15 trick I saw other people use.
I also tried using printf along with the other trick (subtract 8^8 - 1) and it works in ghci but for some reason it doesn't compile:
g=printf "#%06x" .(8^8-1-).fst.head.readHex.tail

If someone could make this work that would be great!

Welcome to Programming Puzzles and Code Golf. These are very good answers (better than I could do in Haskell!). However, there is a common answer format for code-golf challenges which lets the Leaderboard snippet put your answer in the leaderboard. I'll edit it in for you; you can accept or deny the edit.

To reply to other users' comments, type @username.

@wizzwizz4 Many thanks for your assistance.

Any time! Do you want to have a go at some of my challenges? Analyse your chair and Map string to Hilbert Curve are my favourites, although the Hilbert curve one is really hard.

@wizzwizz4 Certainly, I'll see what I can do.

C, 94 bytes
t(char*b){for(int i;i=*b;++b)*b=i>96&i<103?150-i:i>64&i<71|i>47&i<54?118-i:i>53&i<58?111-i:i;}

Function takes in a char array, returns inverse value. Produces uppercase letters for response. The code flips each ASCII hex character to its inverse if it's valid, ignores it otherwise.

You can save some space by globally declaring i before the function: i;

 2, 18 chars / 34 bytes
ïē/\w⌿,↪(ḏ-`ᶍ⦃$}”ⓧ

Try it here (Firefox only).
Using a version created after the challenge.
Explanation
ïē/\w⌿,↪(ḏ-`ᶍ⦃$}”ⓧ // implicit: ï=input, ḏ=15
ïē/\w⌿,             // replace all alphanumeric chars in ï with:
       ↪(ḏ-`ᶍ⦃$}”ⓧ // (15 - char's decimal form) converted to hex
                    // implicit output

Non-competitive solution, 15 chars / 29 bytes
ïē/\w⌿,↪(ḏ-`ᶍ⦃$}”ⓧ

Uses transliteration.

Can you add a competitive version as well, so we can see how the language stacks up?

Sure. See new edit.

Nice use of the APL symbol ⌿.

Hehe, that symbol was the one that made the most sense for /g.

Python, 96
x=input()
print("#")
for i in range(3):
    print(hex(255-int(x[(1+2*i)]+x[(2+2*i)],16))[2:4])

First code golf, please give opinions :)

You are allowed to require the input be in "quotes" btw, so input() works. You don't need the newline and indent on the for loop, and range works just fine. There are also a couple spaces you can remove.

int("ff", 16) can be replaced with just 255.

Do you need the parentheses inside the brackets after each x?

C (clang), 53 49 bytes
p(*s){printf("#%06x",0xffffff-wcstol(s+1,0,16));}

Try it online!
-4 thanks to @jdt

suggest using wide chars for -4 bytes

Befunge-98, 37 bytes
~,v>v
~f<^ s
>,^ >-:9w>'0+
^+W'    ]^

This takes input in lowercase, outputs the answer in lowercase, then enters an infinite loop.
Try it online!
40 byte version that terminates
Explanation
~,v

This gets the first character of the input (which is always #), outputs it unchanged, and enters the loop.

~f<  s

At the start of the loop, f pushes 15 onto the stack, ~ gets the next character of the input, and s puts that character one space to its left in the source code (without executing it).
   >v
   ^I

(I'm using I to represent the character from the input that is now in the source code.) This section loops back around to execute that character. Every character in the range 0-9 or a-f pushes the corresponding hex value on the stack.

    >-:9w

The hex value is subtracted from 15 (the previous top of the stack) to get its complement. :9w creates a copy of the complement, and compares the copy with 9, with the IP going down, up or right depending on whether it is greater, less than, or equal.

         >
        ]^

If the complement is greater than 9, the IP goes down and hits the ] ("turn right") from above, turning to move left. If the copy was less than 9, the IP goes up and hits the ] from below, turning to move right. In that case, it gets redirected back to the third line. If the copy was exactly 9, the IP goes right and hits the > immediately.

          '0+

If the complement is less than or equal to 9 (i.e. a digit), it is added to ASCII 48 (0) to produce the correct digit.

^+W'

If the complement is greater than 9, it is added to ASCII 87 (W) to produce the correct character (in the range a-f).

  <
>,^

In all cases, the character corresponding to the complement is printed and the IP moves back to the start of the loop.
The loop repeats, outputting the complement of every hex digit in the input.
After we print the answer, the input has been completely used up. Once EOF is reached, ~ reflects the IP. This means that ~f< is now an infinite loop that pushes 15 on the stack forever. This doesn't produce any effects (except for possibly crashing), so we don't care about it.

Julia 1.0, 46 bytes
h->'#'repr(~parse(UInt,h[2:7];base=16))[13:18]

Try it online!
Julia 0.6, 40 bytes
h->"#"hex(~parse(UInt,h[2:7],16))[11:16]

Try it online!
Simply a bitwise not (~) on the full number, in hex, the rest around is to parse and print the numbers in hexadecimal and keeping the last 6 numbers

Nibbles, 8 bytes (16 nibbles)
`($+.$hex- 15hex

`($+.$hex- 15hex
`($                 # output the first element of input (the '#')
                    # and save the rest;
    .$              # now, map over the rest
             hex    #   convert from hex,
         - 15       #   subtract from 15,
      hex           #   and convert back to hex
   +                # and convert the resulting list of characters to a string
                    # (which is implicitly output after the '#')

Go, 111 bytes
import(."strconv";."fmt")
func f(s string)string{n,_:=ParseInt(s[1:],16,64)
return Sprintf("#%06x",0xffffff-n)}

Attempt This Online!

CJam, 16 bytes
qA,'G,65>+s_W%er

This is fairly long because CJam handles base changes differently, so it was shorter to just do transliteration. See my Retina answer for more on transliteration.
Try it online.
Explanation
q      e# Get the input
A,     e# Push [0 1 ... 8 9]
'G,65> e# Push "ABCDEF"
+s     e# Combine and convert to string
_W%    e# Make a copy and reverse it
er     e# Replace each character in the first string with
       e# the corresponding character in the second

Python 3, 44 bytes
Originally I used 256^3, then 16^6. Then I saw Pietu1998's 8^8 and now this solution uses that instead.
"#{:06x}".format(8**8-1-int(input()[1:],16))

Bash + tr, 35 bytes
tr 0-9A-Fa-f fedcba9876543210543210

Output is always lowercase.
Unfortunately "tr" does not take ranges in reverse order so I had to spell them out.

TeaScript, 24 bytes
"#"+S(8**8-1-xS1)t16))x6

Bugs in the interpreter aren't letting me get this shorter :(
Try it online

Downvote explanation? It works for all the test cases

PowerShell, 48 bytes
param($a)"#{0:x6}"-f(16MB-1-("0x"+$a.Trim('#')))

Necessarily takes input via param($a) as a string, delimited with ' or ", since C:\Tools\Scripts\Golfing> .\complementary-colors #a1b2c3 on the PowerShell command line will treat #a1b2c3 as a comment and summarily ignore it.
Left-to-right, the "#{0:x6}"-f(...) formats our output calculations back into hexadecimal with a guaranteed 6 characters (to account for input #ffffff). Inside the parens, we subtract our input number from 0xffffff. We do this by leveraging the fact that PowerShell parses hexadecimal numbers in format 0xNNN, so we construct a proper-format hex number from our input number $a. (Note that concatenation plus .Trim() is shorter than .Replace() here by one byte.) We also leverage the MB unary operator via 16MB-1 to construct 16777215 instead of 0xffffff.

C, 147 bytes
void p(char s[]){char c[3];int i=1;printf("#");while(i<6){strncpy(c,s+i++,2);i++;int x=255-strtol(c,NULL,16);x<10?printf("0%x",x):printf("%x",x);}}

Used strtol to convert from hex string to int then subtracted the number from 255 to get the compliment like the original post said. I am, however, wondering if there is a way to pass a range of characters from s to strtol so I don't have to waste a bunch of bytes copying to a new string?

I don't think compilers usually enforce function returns and default to int, so you an probably omit the void return type?

R, 62 bytes
f=function(a)sprintf('#%06x',(8^8-1)-strtoi(substr(a,2,7),16))

PHP, 37 bytes
printf('#%06x',8**8-1-hexdec($argn));

Try it online!
Or if you prefer to be more bit-wise (and byte-foolish) about it:
PHP, 38 bytes
printf('#%06x',~hexdec($argn)&8**8-1);

Try it online!

Thunno 2, 4 bytes
kfḲṆ

Try it online!
Thunno 2 j, 11 bytes
ḣ²Hɠ⁻_Ḥ2ṛ'#

Try it online!
Explanation
kfḲṆ  # Implicit input
kf    # Hexadecimal characters: "0123456789ABCDEF"
  Ḳ   # Bifurcate: duplicate and reverse
   Ṇ  # Transliterate: [0-9A-F] -> [F-A9-0]
      # Implicit output

ḣ²Hɠ⁻_Ḥ2ṛ'#  '# Implicit input
ḣ             # Remove the leading "#"
 ²            # Split into pairs
  H           # Convert each from hexadecimal
   ɠ⁻_        # Subtract each from 255
      Ḥ       # Convert each to hexadecimal
       2ṛ     # Pad with 0s to length 2
         '#  '# Push "#" to the stack
              # Implicit output of joined stack

Ruby, 31 bytes
->s{"#%6x"%(8**8-1-s[1..].hex)}

Attempt This Online!

05AB1E, 6 bytes
15ÝhÂ‡

Try it online or verify all test cases.
Or with the more straight-forward approach (15 bytes):
ćs2ôH₅αh2jð0:J«

Try it online or verify all test cases.
Explanation:
15Ý         # Push a list in the range [0,15]
   h        # Convert each integer to a hexadecimal character
    Â       # Bifurcate this list; short for Duplicate & Reverse copy
     ‡      # Transliterate the (implicit) input-string using these two lists
            # (after which the result is output implicitly)

ć           # Extract head of the (implicit) input-string; push remainder-string and
            # first item separately to the stack
s           # Swap so the remainder-string is at the top
 2ô         # Split it into pairs
        H   # Convert each string in the triplet from hexadecimal to an integer
         ₅α # Take the absolute difference with 255
        h   # Convert it back to hexadecimal
   2jð0:    # Pad leading 0s to single hexadecimal characters if necessary:
   2j       #  Pad potential leading spaces to make all strings of length 2
     ð0:    #  Then replace all spaces with 0s
 J          # Join the triplet of pairs back to a string
«           # Append it back to the "#" that's on the stack
            # (after which the result is output implicitly)


text:
Chinese Zodiac of the year
2015 was the year of the goat! In this challenge, you will figure out which animal represents the year. To avoid making this challenge to complex you won't need to calculate Chinese new year.
Because they are only 12 animals in the Zodiac, your code will need to be as short as possible.
Examples
Your program must get the system year, the first line is just for reference
2015
Goat

1924
Rat

1923
Pig

2008
Rat

Specification
The order of the Zodiac is:
Rat, Ox, Tiger, Rabbit, Dragon, Snake, Horse, Goat, Monkey, Rooster, Dog, Pig

Rat starts at 2008, Pig is 2007, Ox at 2009, etc. at the end this loops back around.
Output must be correctly capitalized.

Is anything before 2008 is assumed to be Rat?

@ZachGates no, that's just an example. I'll update

Can it use the year in the user's timezone?

@LegionMammal978 yes, of course

Related.

I am confused by the system year requirement. So there is no input? So in 2015, it would have printed goat, and now, it should print Monkey?

@TanMath yes, there is no input, your program should get the year from system time. For 2016, it should print Monkey, for 2017, Roster, then Dog for 2018, then 2019 would be Pig, then back to Rat in 2020

For actual usage: Chinese Zodiac consider a year starts at 立春 (transcription: lichun, literal: start of spring). Lichun is the day when the Sun is exactly at the celestial longitude of 315°, which is typically around Feb 4th. So for example, 2008-02-04 ~ 2009-02-02 is the year of Rat instead of 2008-01-01 ~ 2008-12-31. And there also be some people treat a year starts by Chinese new year. If so, the year of Rat is 2008-02-07 ~ 2009-01-25.

Pyth, 54 bytes
@rR3c."ayÖÚ©*ÐPk<`eüµÜxþ!¬Ì ¾½hÑðÙBwp"\c.d3

Try it online: Demonstration
You can replace the last 3 chars .d3 with any year number to test the other Zodiac animals.
Explanation:
     ."ayö..."        packed string, decrypts to "monkeycroostercdogcpig..."
    c         \c      split this string at "c"s
 rR3                  make the first letter of each animal uppercase
                .d3   current year
@                     take the correct animal of the list and print

Pyth - 65 bytes
@c." y=CÅQ¯@îR
°©ÀáëªfÞ#[õNqÀN8Ô'¼ô,n7Ë¶~fB").d3

Try it online here.
@                     Modular indexing
 c           )        Split string, use default of spaces
  ."ajs&^asd"         Packed string to compress space separated zodicas
 .d3                  Current year

Can you add an explanation?

@TanMath its really simple, but sure

You can save at least 3 bytes by narrowing down the character space. demo Also, you might want to post the unprintable code as a hexdump and include a printable version.

JavaScript ES6, 106 105 104 103 bytes
Saved 1 byte thanks to Maltysen, 1 byte to insertusernamehere, and 1 byte to edc65!
x=>"RatOxTigerRabbitDragonSnakeHorseGoatMonkeyRoosterDogPig".match(/.[a-z]+/g)[new Date().getYear()%12]

Pretty self explanatory.

I feel like that string could use some btoa and atob. (You can also change the byte encoding, if that's allowed).

@ןnɟuɐɯɹɐןoɯ btoas result looks to be 1.5x or more the length of the hardcoded string.

No, use atob to encode, and btoa to decode.

@ןnɟuɐɯɹɐןoɯ Oh. That's cool.

You would do btoa\[encoded gibberish here]``, which should save at least 20 bytes.

@ןnɟuɐɯɹɐןoɯ It will save 20 characters but the encoded string is 66 bytes E«t;«Ñn+t¶ ¢}©Ðz+±í¡«t2ä{-¢-z½¢ which is the same as the non-encoded so it's actually worse when you add btoa\``.

That's why I recommended that the byte encoding be changed to ISO-8859-1 if possible.

You can save 1 byte: Remove the 0 as separator and use this regex to split the string: /(?=[A-Z])/. Happy New Year. :)

@insertusernamehere Nice regex! (I though of using .match(/[A-Z][a-z]+/g) but yours is 3 bytes shorter.)

match(/.[a-z]+/g) instead of split (added value: split with capture is not ES6, is a FireFox only feature)(and 1 byte shorter)

Japt, 72 65 bytes
`Mkey RooÐP Dog Pig R Ox Tig Rabb Dg Snake HÆ  Go`¸gÐ i %C

Try it online!

Umm... this is pretty good, but there's definitely some unprintables in there. Could you give us a link?

@Eth eh, didn't account that unprintable are stripped. Gonna restore it :D

BTW, instead of $[$Ð i -4 %12], you can use g(Ð i -4 %C.

@Eth ok, and i'll dispose of -4 also, by changing the element order.

@Eth Wait, your fix doesn't appear to work, outputs NaN...

Yeah, I messed it up slightly. Try this: gÐ i %C

@Eth Yup, this one works.

C equals 12 ;)

@Eth lol ok, golfing another answer now :D

CJam, 82 80 75 bytes
This is was a direct port of my Milky Way answer.
"Monkey Rooster Dog Pig Rat Ox Tiger Rabbit Dragon Snake Horse Goat"S/et0==

Saved 7 bytes thanks to NinjaBearMonkey.

You can use S as a variable for space.

Even shorter: "Monkey Rooster Dog Pig Rat Ox Tiger Rabbit Dragon Snake Horse Goat"S/et0==

CJam, 69 bytes
"SKiN<lEz=2)aFBY8H[$h-0|4=K`T2Cp%-a)o6"132b26b'`f+'`/et0==(eu\

Contains a bunch of unprintables. Try it here.

You can't take a year as input, it has to use the current system time.

Ah, fixed. @Maltysen

Python 3, 126 116 112 bytes
Edit: I'm keeping the other answer because it's cool, but this is shorter.
from time import*
"Monkey Rooster Dog Pig Rat Ox Tiger Rabbit Dragon Snake Goat".split()[localtime().tm_year%12]

If trailing whitespace is ok, then it's 126 bytes. If not, it's 134 bytes after adding .strip() to the end of the code.
from datetime import*
"MRDPROTRDSHGoooiaxiarnoonoggt gbaaraks    ebgkstet    rioee ye     tn    r"[datetime.now().year%12::12]

Milky Way 1.6.1, 101 96 bytes
M" "\=A12n"Goat Horse Snake Dragon Rabbit Tiger Ox Rat Pig Dog Rooster Monkey"" "\;>=<&{~1-;^};!

Saved 5 bytes thanks to a reminder by Luis Mendo.

Explanation
The code modulos the system year by 12 and outputs the proper animal.

Usage
./mw <path-to-code>

Maybe you can avoid 2008- by rearranging the string as in my answer?

Oh, I think you already do that in your CJam answer

You're right! I can use the string from my CJam answer in reverse. Thanks for reminding me @LuisMendo

MATL, 85 bytes
'Rooster Dog Pig Rat Ox Tiger Rabbit Dragon Snake Horse Goat Monkey'YbZ'10H$XOU12X\)

Uses release 6.0.0 of the language/compiler. Works in Octave.
Example
>> matl
 > 'Rooster Dog Pig Rat Ox Tiger Rabbit Dragon Snake Horse Goat Monkey'YbZ'10H$XOU12X\)
 >
Monkey

Explanation
Note that the initial string is cyclically displaced by 3 to avoid a subtraction.
'Rooster Dog Pig Rat Ox Tiger Rabbit Dragon Snake Horse Goat Monkey'
Yb                    % split at spaces
Z'                    % number representing current date and time
10H$XO                % get year as a string
U                     % convert to number
12X\                  % modulo 12, with 0 converted to 12
)                     % index (and implicitly print)

R, 119 bytes
scan(t="Monkey Rooster Dog Pig Rat Ox Tiger Rabbit Dragon Snake Horse Goat",w="")[(format(Sys.Date(),"%Y"):1)[1]%%12+1]

format(Sys.Date(),"%Y") returns the year as a character string, (format(Sys.Date(),"%Y"):1)[1] is the shortest way i could think of to coerce it into an integer so that we can apply %% to it (the sequence generator : indeed coerces automatically to integer). +1 because R indices are 1-based and not 0-based.

PHP >= 5.6, 84 bytes
Very straight forward:
<?=[Monkey,Rooster,Dog,Pig,Rat,Ox,Tiger,Rabbit,Dragon,Snake,Horse,Goat][date(Y)%12];

Python 129 126 bytes
EDIT: I just learnt s.split(' ')=s.split()
Although this isn't the shortest method, here is an alternative answer to @Sherlock9's one:
from datetime import*
print 'Monkey Rooster Dog Pig Rat Ox Tiger Rabbit Dragon Snake Horse Goat'.split()[date.today().year%12]

Try it here

Wow. I just edited my answer and that was pretty close to what I edited it to. I'm going to try something with time next.

PowerShell, 92 bytes
(-split"Monkey Rooster Dog Pig Rat Ox Tiger Rabbit Dragon Snake Horse Goat")[(date).Year%12]

Similar in spirit to other answers, added here only for sake of cataloging. This takes the string "Monkey ... Goat" and -splits it on spaces to create an array, which is cheaper than specifying the elements individually with ("Monkey","Rooster",...). We index into that array with the current year mod 12, which outputs the result. Nothing too fancy.

C# 159
using System;class P{static void Main(){Console.Write("Monkey;Rooster;Dog;Pig;Rat;Ox;Tiger;Rabbit;Dragon;Snake;Horse;Goat".Split(';')[DateTime.Now.Year%12]);}}

Readable / ungolfed version
using System;
class Program
{
    static void Main(string[] args)
    {
        Console.Write("Monkey;Rooster;Dog;Pig;Rat;Ox;Tiger;Rabbit;Dragon;Snake;Horse;Goat".Split(';')[DateTime.Now.Year % 12]);
    }
}

J, 78 bytes
(>;:'Monkey Rooster Dog Pig Rat Ox Tiger Rabbit Dragon Snake Horse Goat'){~12|

Usage:
    (>;:'Monkey Rooster Dog Pig Rat Ox Tiger Rabbit Dragon Snake Horse Goat'){~12| 2015
 Goat

Explanation:
;:      separates the string into boxed array according to the spaces
>       opens the boxed array so that it becomes a normal array
x {~ y  is choose the y-th element from x.
        the ~ reverses the argument, so x { y is choose the x-th element from y.
12|     is the residue when the year is divided by 12

Vyxal, 49 bytes
`⌊ẇ ₃¼ Roos≠∴ •∞ Ḣ⟩ ₀⌊ Ox ṗȦ ₈Ė ėɾ Ċṅ ½√`⌈kD⌊12%i

Try it Online!
`...`         # Compressed  string of names
     ⌈        # Split on spaces
      kD⌊     # Current year
         12%  # Modulo 12
            i # Index into list of names

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Mine for 2016 in Bitcoins! PCG.SE New Year's Puzzle 2016
In the Bitcoin protocol, 2016 is a very special number. The "difficulty" of finding a hash to create a new block is adjusted every 2,016 blocks to approximate changing once every two weeks.
This number was chosen is because the difficulty adjusts itself so that every block takes about 10 minutes to be found, and in two weeks, there are 2 × 7 × 24 × 6 = 2,016 ten-minute periods.

To commemorate this numerical coincidence, this year's New Year's problem is about Bitcoin — specifically, the hashing algorithm it uses to sign blocks, SHA-256.
Your task is to create a program that will take byte input (in at least ASCII) and output a nonce in bytes (in the format of your choice) that will produce a SHA-256 hash containing 2016 in its base64 representation when appended to the original byte input.
Here are some examples of valid solutions, courtesy of the engines people have already generated, as well as the hashes they produced:
> foo
Nonce: 196870
SHA256 hash: OCUdDDtQ42wUlKz2016x+NROo8P2lbJf8F4yCKedTLE=

> bar
Nonce: 48230
SHA256 hash: CNcaOCQgT7bnlQzQPXNwuBu8/LYEdk2016khRaROyZk=

> happynewyear
Nonce: 1740131
SHA256 hash: XsKke6z2016BzB+wRNCm53LKJ6TW6ir66GwuC8oz1nQ=

> 2016
Nonce: 494069
SHA256 hash: rWAHW2YFhHCr22016zw+Sog6aW76eImgO5Lh72u6o5s=

(note: the nonces don't actually have to be ASCII numbers; you can do
 any byte input you find convenient.)

The only pre-built library (other than standard input and output functions) your program may use is a SHA256(bytes) function that takes byte input and returns a SHA256 hash, in any format including base64.
The program to do this in the fewest bytes of source code wins.

Call me crazy, but isn't this bitcoin mining by another name?

Also, define a "pre-built library". My language's SHA-256 function produces the hash, but not the Base64 hash. Therefore, I would also need to use conversion to bytes, then conversion into characters, then conversion into Base64.

@LegionMammal978 A "pre-built library" would be any function defined outside the code that counts for this challenge. So you can create a base64 wrapper function for your SHA-256 function, in order to use it in this problem.

@Codefun64 This is a code problem that simulates the procedure used in Bitcoin mining, but does not itself mine for bitcoins.

Perl 5.10+, 39 + 18 = 57 bytes
sha256_base64($_.++$i)!~2016?redo:say$i

This needs to be run with the -nMDigest::SHA=/./ command line switch, which is included in the byte count.  It also uses the Perl 5.10+ say feature, and so needs to be run with the -M5.010 (or -E) command line switch, which is considered free.  The input should be provided on stdin, without a trailing newline (unless you want the newline to be considered part of the input).
Examples:
$ echo -n foo | perl -nMDigest::SHA=/./ -E 'sha256_base64($_.++$i)!~2016?redo:say$i'
196870
$ echo -n bar | perl -nMDigest::SHA=/./ -E 'sha256_base64($_.++$i)!~2016?redo:say$i'
48230
$ echo -n happynewyear | perl -nMDigest::SHA=/./ -E 'sha256_base64($_.++$i)!~2016?redo:say$i'
1740131
$ echo -n 2016 | perl -nMDigest::SHA=/./ -E 'sha256_base64($_.++$i)!~2016?redo:say$i'
494069

Mathematica, 94
(For[i=0,IntegerDigits[4Hash[#<>ToString@++i,"SHA256"],64]~SequenceCount~{54,52,53,58}<1,];i)&

This function will try positive integers as candidates. It takes over 4 minutes on my laptop to get the correct answer.
%["foo"]
(* 196870 *)

Longer however faster (~5x) implementation makes use of parallelization:
f[k_]:=
    Do[If[Length@#>0,Return[i+#[[1,1]]]]&@
        Position[ParallelMap[IntegerDigits[4Hash[k<>ToString@#,"SHA256"],64]
            ~SequenceCount~{54,52,53,58}&,i+Range@1*^4],1]
        ,{i,0,∞,1*^4}]

We should create a golfing version of Wolfram Language, with every command replaced by one or two characters. Actually, given the number of commands, we might need to use three characters for some of the less common ones.

@MichaelStern I cannot agree more.

@MichaelStern Did that.

@LegionMammal978 Fantastic! Btw, why not consider a better name like "WOLF"?

Ruby, 87 86 bytes
I'm not sure if I understood the challenge correctly, but it finds 196870 in a few seconds if you input foo.
require"digest"
gets.chop!
$.+=1until/2016/=~Digest::SHA256.base64digest("#$_#$.")
p$.

PowerShell, 150 152 153 bytes
while([Convert]::ToBase64String([Security.Cryptography.SHA256]::Create().ComputeHash([Text.Encoding]::UTF8.GetBytes("$args$i")))-notmatch2016){$i++}$i

Example
PS > .\BitCoin.ps1 foo
196870

PS > .\BitCoin.ps1 bar
48230

PS > .\BitCoin.ps1 happynewyear
1740131

PS > .\BitCoin.ps1 2016
494069

C#, 179 bytes
s=>{int i=0;while(!System.Convert.ToBase64String(System.Security.Cryptography.SHA256.Create().ComputeHash(System.Text.Encoding.UTF8.GetBytes(s+i))).Contains("2016"))i++;return i;}

Similar to the PowerShell solution, just longer.

That's a lot of keywords.

@JoeZ. That's C# for you.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Xorting an array
Conceptually, this challenge is really simple. You're given a list of non-negative integers ai. If possible, find a non-negative integer N, such that the list consisting of bi = ai XOR N is sorted. If no such N exists, output should be anything that can't be mistaken for a valid N, e.g. a negative number, nothing at all, an error etc.
Here is an example:
[4, 7, 6, 1, 0, 3]

If we take every element in this list XOR 5, we get
[1, 2, 3, 4, 5, 6]

which is sorted. (Note that it is not a requirement for the resulting list to have unique elements and contain no gaps. If the result of such an operation was [0, 1, 1, 3] that would still be valid.) On the other hand for the list
[4, 7, 1, 6, 0, 3]

no such N exists.
You may write a program or function, taking input via STDIN (or closest alternative), command-line argument or function argument and outputting the result via STDOUT (or closest alternative), function return value or function (out) parameter.
Input may be in any convenient list or string format. You may assume that the ai are less than 231 each and that the list contains at least one element.
Your code must handle any of the test cases (especially the four large ones) in a matter of a few seconds.
Standard code-golf rules apply.
Test Cases
For every test case which doesn't return -1 there's an infinite number of correct answers. The one listed here is the smallest one. Additional solutions exist by additionally setting bits which are the same across all integers in the input (notably those which are larger than the most-significant bit in the largest number of the list).
[4 7 6 1 0 3] => 5
[4 7 1 6 0 3] => -1
[0 1 3 4 6 7] => 0
[4 2 3 1] => 6
[2 3 0 0 7 7 4 5 11 11] => 2
[2 3 0 0 7 7 5 4 11 11] => -1
[1086101479 748947367 1767817317 656404978 1818793883 1143500039] => -1
[180522983 1885393660 751646477 367706848 331742205 724919510 850844696 2121330641 869882699 1831158987 542636180 1117249765 823387844 731663826 1762069894 240170102 1020696223 1212052937 2041219958 712044033 195249879 1871889904 1787674355 1849980586 1308879787 1743053674 1496763661 607071669 1987302942 178202560 1666170841 1035995406 75303032 1755269469 200581873 500680130 561748675 1749521426 1828237297 835004548 934883150 38711700 1978960635 209243689 1355970350 546308601 590319412 959613996 1956169400 140411967 112601925 88760619 1977727497 672943813 909069787 318174568 385280382 370710480 809689639 557034312 865578556 217468424 346250334 388513751 717158057 941441272 437016122 196344643 379529969 821549457 97008503 872313181 2105942402 603939495 143590999 1580192283 177939344 853074291 1288703007 1605552664 162070930 1325694479 850975127 681702163 1432762307 1994488829 780869518 4379756 602743458 1963508385 2115219284 1219523498 559301490 4191682 1918142271 169309431 346461371 1619467789 1521741606 1881525154] => -1
[37580156 64423492 87193676 91914964 93632157 96332899 154427982 176139560 184435039 228963836 230164674 279802291 301492375 309127664 345705721 370150824 380319820 403997410 410504675 416543032 418193132 424733526 428149607 435596038 477224208 515649925 519407995 525469350 614538124 624884850 642649261 653488151 679260270 685637235 690613185 739141066 825795124 832026691 832633584 833213619 852655299 913744258 917674993 921902522 925691996 931307936 954676047 972992595 997654606 1020009811 1027484648 1052748108 1071580605 1108881241 1113730139 1122392118 1154042251 1170901568 1180031842 1180186856 1206428383 1214066097 1242934611 1243983997 1244736049 1262979035 1312007069 1312030297 1356274316 1368442960 1377432523 1415342434 1471294243 1529353536 1537868913 1566069818 1610578189 1612277199 1613646498 1639183592 1668015280 1764022840 1784234921 1786654280 1835593744 1849372222 1875931624 1877593764 1899940939 2007896363 2023046907 2030492562 2032619034 2085680072 2085750388 2110824853 2123924948 2131327206 2134927760 2136423634] => 0
[1922985547 1934203179 1883318806 1910889055 1983590560 1965316186 2059139291 2075108931 2067514794 2117429526 2140519185 1659645051 1676816799 1611982084 1736461223 1810643297 1753583499 1767991311 1819386745 1355466982 1349603237 1360540003 1453750157 1461849199 1439893078 1432297529 1431882086 1427078318 1487887679 1484011617 1476718655 1509845392 1496496626 1583530675 1579588643 1609495371 1559139172 1554135669 1549766410 1566844751 1562161307 1561938937 1123551908 1086169529 1093103602 1202377124 1193780708 1148229310 1144649241 1257633250 1247607861 1241535002 1262624219 1288523504 1299222235 840314050 909401445 926048886 886867060 873099939 979662326 963003815 1012918112 1034467235 1026553732 568519178 650996158 647728822 616596108 617472393 614787483 604041145 633043809 678181561 698401105 776651230 325294125 271242551 291800692 389634988 346041163 344959554 345547011 342290228 354762650 442183586 467158857 412090528 532898841 534371187 32464799 21286066 109721665 127458375 192166356 146495963 142507512 167676030 236532616 262832772] => 1927544832
[1922985547 1934203179 1883318806 1910889055 1983590560 1965316186 2059139291 2075108931 2067514794 2117429526 2140519185 1659645051 1676816799 1611982084 1736461223 1810643297 1753583499 1767991311 1819386745 1355466982 1349603237 1360540003 1453750157 1461849199 1439893078 1432297529 1431882086 1427078318 1487887679 1484011617 1476718655 1509845392 1496496626 1583530675 1579588643 1609495371 1559139172 1554135669 1549766410 1566844751 1562161307 1561938937 1123551908 1086169529 1093103602 1202377124 1193780708 1148229310 1144649241 1257633250 1241535002 1247607861 1262624219 1288523504 1299222235 840314050 909401445 926048886 886867060 873099939 979662326 963003815 1012918112 1034467235 1026553732 568519178 650996158 647728822 616596108 617472393 614787483 604041145 633043809 678181561 698401105 776651230 325294125 271242551 291800692 389634988 346041163 344959554 345547011 342290228 354762650 442183586 467158857 412090528 532898841 534371187 32464799 21286066 109721665 127458375 192166356 146495963 142507512 167676030 236532616 262832772] => -1

Finally, here are four very large test cases to ensure that submissions are sufficiently efficient:

Test Case 1 should yield -1.
Test Case 2 should yield 0.
Test Case 3 should yield 1096442624.
Test Case 4 should yield -1.

Why would anyone do this?
It occurred to me the other day that a XOR operation can "sort" an array, which makes it possible to perform a binary search on the array in O(log n) without having to sort it first. It appears to be possible to determine N in pseudolinear time, which would make this a faster alternative to most sorting algorithms, and it doesn't have the memory requirements of radix sort. Of course, a straight linear search through the unsorted array will be faster, but if you want to search the same array many times, a single linear pre-computation can bring down the time required for each search significantly.
Unfortunately, the class of lists this works on is rather limited (uniformly random distributions are unlikely to admit an N).
An interesting question is whether there are other bijective functions which are easier to check and/or are applicable for a wider class of lists.

"Xorting" is a really cool name for that.

@insertusernamehere Credits for that go to randomra.

If it wasn't for the timing limitation this would be {^.max .first: {[<=] $_ X+^ @_}} in Perl 6

An extremely interesting challenge!

This is not sorting! Your example creates a list of increasing values, but the original elements are lost. A sort operation orders elements while keeping its key values.

As the OP wrote: cite 1: It occurred to me the other day that a XOR operation can "sort" an array, ...; cite 2: If we take every element in this list XOR 5, we get [1, 2, 3, 4, 5, 6] which is sorted. => It's transformed in an ordered list but not sorted.

Paebbels: presuming you have the Xorting key, it is possible to calculate the original value. For the purposes here (a binary search), you would XOR the input with the key and then check it exists in the 'sorted' array. It is certainly a sort, but the relation/function you're sorting over is chosen s.t. the position of each element remains the same.

@Paebbels I never claimed that this is sorting. I called it by a made-up word and the paragraph you cite has "sort" in quotes for a reason. My point was that this is a bijective transformation which allows the array to be treated as is if it was sorted for certain operations (like a binary search) without actually having to sort it.

Ok, it's a good question (as always) ... but 4 answers, top answer 10 votes, question a whopping 45 votes! I maintain my point http://meta.codegolf.stackexchange.com/questions/7683/increase-reputation-awarded-for-questions?cb=1

As to "applicable for a wider class of lists", for any given bijective function f, a list of size N with all elements unique will have N! orderings, and only one of those will be correctly ordered after applying f. So if you parameterize your function (like you do with XOR, where the parameter is the number you're XORing with), the magnitude of that parameter has to be on the order, roughly, of N!, to have a good chance of a match. I think that'd be prohibitive for most applications

@BenAaronson That's a very good insight. I suppose you'd actually need to know your data very well to be able to use this in practice for any operation with a reasonably-sized parameter.

@MartinBüttner It's still an interesting question whether there's any parameterized function where you can construct the parameter in some reasonable time rather than having to search that N!-sized space, and where (unlike XOR) there's guaranteed to be a valid parameter. My  intuition is "no", but I don't know how you'd go about proving it

Jelly, 25 bytes
ṡ2Zµ^/Bo1Ḅ‘×>/|/H
Ç-¹^Ç¥?

The latest commits postdate this challenge, but the above code works with this revision, which predates it. Try it online!
To run the large test cases, depending on your shell, it may be necessary to wrap the above code in a program that reads input from STDIN. Try it online!
Test cases
$ xxd -c 13 -g 1 xort-prog.jelly
0000000: ae 32 5a 8c 5e 2f 42 6f 31 a4 b6 94 3e  .2Z.^/Bo1...>
000000d: 2f 7c 2f 48 0a 92 2d 8e 5e 92 84 3f     /|/H..-.^..?
$ ./jelly f xort-prog.jelly '[4, 7, 6, 1, 0, 3]'; echo
5
$ ./jelly f xort-prog.jelly '[4, 7, 1, 6, 0, 3]'; echo
-1
$ ./jelly f xort-prog.jelly '[0, 1, 3, 4, 6, 7]'; echo
0
$ ./jelly f xort-prog.jelly '[4, 2, 3, 1]'; echo
6
$ ./jelly f xort-prog.jelly '[2, 3, 0, 0, 7, 7, 4, 5, 11, 11]'; echo
2
$ ./jelly f xort-prog.jelly '[2, 3, 0, 0, 7, 7, 5, 4, 11, 11]'; echo
-1
$
$ wget -q http://pastebin.com/raw/{P96PNi79,zCNLMsx9,GFLBXn5b,6F1Yn3gG}
$ xxd -c 14 -g 1 xort-func.jelly
0000000: ae 32 5a 8c 5e 2f 42 6f 31 a4 b6 94 3e 2f  .2Z.^/Bo1...>/
000000e: 7c 2f 48 0a 92 2d 8e 5e 92 84 3f 0a a0 92  |/H..-.^..?...
$ tr \  , < P96PNi79 | time -f '\n%es' ./jelly f xort-func.jelly
-1
3.69s
$ tr \  , < zCNLMsx9 | time -f '\n%es' ./jelly f xort-func.jelly
0
2.78s
$ tr \  , < GFLBXn5b | time -f '\n%es' ./jelly f xort-func.jelly
1096442624
2.73s
$ tr \  , < 6F1Yn3gG | time -f '\n%es' ./jelly f xort-func.jelly
-1
2.70s

Idea
This uses a the same approach as @Jakube's answer, but my implementation is a bit different.
Jelly has no sorting yet, so we compute a xorting candidate, XOR the input list with it, compute a xorting candidate of the XORed list, and check if the new candidate is zero. If it is, we print the first candidate; otherwise, we print -1.
Also, Jelly seems to have no sane way to cast to integer yet (even integer division can return floats), so I had to come up with a rather creative way of rounding a list of numbers down to the next power of 2. Rather than log-floor-pow, I convert all integers to binary, replace all binary digits with 1, convert back to integer, add 1, and divide by 2.
Code
ṡ2Zµ^/Bo1Ḅ‘×>/|/H  Helper link. Argument: M (list of integers)

ṡ2                 Yield all overlapping slices of length 2 (pairs) of M.
  Z                Zip to group first and second coordinates.
   µ               Begin a new, monadic chain.
    ^/             XOR the corresponding coordinates.
      B            Convert all results to binary.
       o1          OR (logical) all binary digits with 1.
         Ḅ         Convert back to integer.
          ‘        Increment all integers.
           ×>/     Multiply each rounded (a ^ b) by (a > b).
                   This replaces (a ^ b) with 0 unless a > b.
              |/   OR all results.
                H  Halve the result.

Ç-¹^Ç¥?            Main link. Input: L (list of integers)

Ç                  Call the helper link on L. Result: C (integer)
     ¥             Create a dyadic chain:
   ^                 XOR the elements of L with C.
    Ç                Call the helper link on the result.
      ?            If the result in non-zero:
 -                   Yield -1.
  ¹                Else, yield C.

Pyth, 40 36 31 30 bytes
Ju.|G^2slHxMf>FT.:Q2Z|tSIxRJQJ

Try it online: Demonstration or Test Suite
Each of the big test-cases finishes in a couple of seconds.
Explanation:
First I'll explain the method and why it works. I'll do this with the example list: [7, 2, 13, 9].
The first two numbers are already wrong (7 > 2). We want to xor with some number to change that inequality symbol (7 xor X < 2 xor X). Since xor operates on the binary representations, lets look at them.
7 = 1 1 1
2 =   1 0

When we apply xor with some number to each number, the value at some positions will change. If you change the values at the first position (2^0), the inequality symbol doesn't change. The same thing happens, when we change the values at the second position (2^1). Also the symbol won't change if we change values at the fourth, fifth, ... positions (2^3, 2^4, ...). The inequality symbol only changes direction, if we change the third position (2^2).
7 xor 2^0 = 1 1 0   7 xor 2^1 = 1 0 1   7 xor 2^2 =   1 1   7 xor 2^3 = 1 1 1 1
2 xor 2^0 =   1 1   2 xor 2^1 =     0   2 xor 2^2 = 1 1 0   2 xor 2^3 = 1 0 1 0
     6 > 3               5 > 0               3 < 6               15 > 10

If we change multiple positions at once, of course the same thing happens. If any of the positions we change is the third, than the inequality symbol changes, otherwise not.
The next pair is already sorted: 2 < 13. If we look at the binary representation, we notice, that we can xor anything to it and the inequality symbol is still correct, except when we change the fourth position (2^3).
 2 =     1 0    2 xor 2^3 = 1 0 1 0
13 = 1 1 0 1   13 xor 2^3 =   1 0 1
   2 < 13            10 > 5

So we don't want to change the fourth position. For the next pair we want to change something, since 13 > 9. Here we again have to change the third position.
13 = 1 1 0 1   13 xor 2^2 = 1 0 0 1
 9 = 1 0 0 1    9 xor 2^2 = 1 1 0 1
   13 > 9            9 < 13

Now recap: To end up in a sorted list, we again have to change the third position and don't want to change the fourth position. All other positions doesn't matter. The smallest number is simply 4 = 0100. Other choices would be 5 = 0101, 6 = 0110, 7 = 0111, 20 = 10100, 21 = 10101, ...
Xoring with 4 will result in the list [3, 6, 9, 13], with 6 will get [1, 4, 11, 15], and with 21 will get [18, 23, 24, 28].
So for a list, we need to find the positions, that will change the inequality symbol if it points into the wrong direction. We find the position simply by taking the most significant bit of the xor of the pair. We combine all these position (with or) to result in a candidate number. The we check, if we haven't accidentally destroyed the already sorted pairs.
Ju.|G^2slHxMf>FT.:Q2Z   implicit: Q = input list
                .:Q2    all substrings of length 2
            f>FT        filter for pairs that are in descending order
          xM            apply xor to each such pair
 u                  Z   reduce this list, start value G = 0
                           iteration value is H
     ^2slH                 2 to the power of floor(logarithm base 2 of H)
                           this gives a mask representing the most significant bit
  .|G                      update G with the bitwise or of G and ^
J                       store the result in J

|tSIxRJQJ
    xRJQ      xor each element of the input list with J
  SI          check if the list is sorted
 t            subtract 1
|       J     this number or (if equal to zero) J
              implicit print

I'm exhorting at the existence of such a clean, simple solution.

It would be awesome if you could give an explanation of why this works for those of us who are more mathematically obtuse. I understand all the steps but don't quite see why the bitwise or of the MSB of every xor'ed descending pair is going to be the right value.

@Luke Added a long explanation. Hopefully it helps.

Wonderful explanation!

If you keep 2 binary values, the bits that have to change, and the bits that have to not change, then you have your final result with no more iterations

@edc65 Yeah, but that would require more bytes. And it is fast enough (even with the is_sorted function, which has nlogn complexity in Pyth).

Magic of esolangs. In javascript a numeric sort is no less then 18 bytes

What's the time complexity of this algorithm?

@Challenger5 The main algorithm is O(n), checking if the resulting list is sorted is O(n*log(n)). It can be done in O(n) too, but this would have required more bytes.

Ruby 2, 119
->a,*o{a.each_cons(2){|x,y|x==y||o[i=(x^y).bit_length-1]==1-(o[i]=x[i])&&(return-1)};(o.map(&:to_i).reverse*'').to_i 2}

Runs in 42 milliseconds on the large test cases.
Ungolfed:
def first_differing_bit(a,b)
  (a^b).bit_length - 1
end

def xort(ary)
  required_bits = []
  ary.each_cons(2) do |a,b|
    i = first_differing_bit(a,b)
    if i > -1
      bit = a[i]
      if required_bits[i] && required_bits[i] != bit
        return -1
      else
        required_bits[i] = bit
      end
    end
  end
  required_bits.map(&:to_i).reverse.join.to_i(2)
end

For once I wrote the ungolfed version first, then golfed it, since figuring out the right algorithm was a challenge in itself.
I actually tried to write something like this a few years ago to make a binary tree structure that would locally self-balance by letting each node redefine its comparison function dynamically. At first I thought I could just use xor, but as you say for random data there's unlikely to be a viable value.

Good solution, I like the array initialization and ruby's bit [] function. But try for example the list [4,4,4], this will give a SyntaxError as it tries to eval 0b. Luckily, as it often happened to me, there's another way to do the same thing in the same amount of bytes. This should work, I hope: ->a,*o{a.each_cons(2){|x,y|x==y||o[i=(x^y).bit_length-1]==1-(o[i]=x[i])&&(return-1)};(o.map(&:to_i).reverse*'').to_i 2}

Indeed it does, nice catch!

Julia, 174 144 77 75 71
[EDIT] Thanks to Alex A. for anonymizing & various shorthands.
[EDIT 2] Replaced my own implementation by the builtin issorted().
Runs in linear time and handles the big files without noticeable delay. Works just as well for negative numbers.
l->(r=0;s=issorted;for d=63:-1:0 s((l$r).>>d)||(r$=2^d)end;s(l$r)?r:[])

Another variant that calculates the result closest to a given key (the above returns the smallest).
(l,r)->(s=issorted;for d=63:-1:0 s((l$r).>>d)||(r$=2^d)end;s(l$r)?r:[])

usage:
julia> xort = l->(r=0;s=issorted;for d=63:-1:0 s((l$r).>>d)||(r$=2^d)end;s(l$r)?r:[])
(anonymous function)

julia> xort([4 7 6 1 0 3])
5

Example, step by step: [4 7 6 1 0 3] => 5
Start with:
     4  0b0100
     7  0b0111
     6  0b0110
     1  0b0001
     0  0b0000
     3  0b0011
result  0b0000

If the first n bits are sorted, do nothing.
        0b0
        0b0
        0b0
        0b0
        0b0
        0b0
result  0b0000
          ^
If the first n bits are not sorted, flip the nth bit.
        0b01            0b00
        0b01            0b00
        0b01            0b00
        0b00      =>    0b01
        0b00            0b01
        0b00            0b01
result  0b0000          0b0100
           ^               ^
        0b000
        0b001
        0b001
        0b010
        0b010
        0b011
result  0b0100
            ^
        0b0000          0b0001  1
        0b0011          0b0010  2
        0b0010          0b0011  3
        0b0101    =>    0b0100  4
        0b0100          0b0101  5
        0b0111          0b0110  6
result  0b0100          0b0101  5
             ^               ^
If the bit flip does not sort the truncated integers, xorting is
impossible. We continue anyway and check for success in the end.

71 bytes: l->(r=0;s=issorted;for d=63:-1:0 s((l$r).>>d)||(r$=2^d)end;s(l$r)?r:[])

JavaScript (ES6) 85 97 114 117
Edit Removed stupid,useless last AND
Edit2 Top bit search shortened
Edit3 Wow! I discovered that ES6 (almost) has a builtin to find the top bit (Math.clz32 counts the top 0 bits)
This is based on the solution of @Jakube (pls upvote that). I could never have found it by myself.
Here I go one step forward, iterating the list once and keeping a bit mask with the bits that have to be flipped, and another one with the bits that have to be kept.
If there is an overlap of the bit masks, then no solution is possible, else the solution is "bits to flip"
As binary operations in javascript work only on signed 32 bits integers, the return value is a signed 32 bit integer that can be negative or 0.
If there is no solution the return value is 'X'
l=>l.map(v=>(t=v^p&&1<<(31-Math.clz32(v^p)),v>p?k|=t:c|=t,p=v),p=l[c=k=0])&&c&k?"X":c

Test
The longer tests on jsfiddle

X=l=>l.map(v=>(t=v^p&&1<<(31-Math.clz32(v^p)),v>p?k|=t:c|=t,p=v),p=l[c=k=0])&&c&k?"X":c

console.log=x=>O.textContent+=x+'\n'
;[
[[4,7,6,1,0,3], 5],
[[4,7,1,6,0,3], 'X'],
[[0,1,3,4,6,7], 0],
[[4,2,3,1], 6],
[[2,3,0,0,7,7,4,5,11,11], 2],
[[2,3,0,0,7,7,5,4,11,11], 'X'],
[[1086101479,748947367,1767817317,656404978,1818793883,1143500039],'X'],
[[180522983,1885393660,751646477,367706848,331742205,724919510,850844696,2121330641,869882699,1831158987,542636180,1117249765,823387844,731663826,1762069894,240170102,1020696223,1212052937,2041219958,712044033,195249879,1871889904,1787674355,1849980586,1308879787,1743053674,1496763661,607071669,1987302942,178202560,1666170841,1035995406,75303032,1755269469,200581873,500680130,561748675,1749521426,1828237297,835004548,934883150,38711700,1978960635,209243689,1355970350,546308601,590319412,959613996,1956169400,140411967,112601925,88760619,1977727497,672943813,909069787,318174568,385280382,370710480,809689639,557034312,865578556,217468424,346250334,388513751,717158057,941441272,437016122,196344643,379529969,821549457,97008503,872313181,2105942402,603939495,143590999,1580192283,177939344,853074291,1288703007,1605552664,162070930,1325694479,850975127,681702163,1432762307,1994488829,780869518,4379756,602743458,1963508385,2115219284,1219523498,559301490,4191682,1918142271,169309431,346461371,1619467789,1521741606,1881525154],'X'],
[[37580156,64423492,87193676,91914964,93632157,96332899,154427982,176139560,184435039,228963836,230164674,279802291,301492375,309127664,345705721,370150824,380319820,403997410,410504675,416543032,418193132,424733526,428149607,435596038,477224208,515649925,519407995,525469350,614538124,624884850,642649261,653488151,679260270,685637235,690613185,739141066,825795124,832026691,832633584,833213619,852655299,913744258,917674993,921902522,925691996,931307936,954676047,972992595,997654606,1020009811,1027484648,1052748108,1071580605,1108881241,1113730139,1122392118,1154042251,1170901568,1180031842,1180186856,1206428383,1214066097,1242934611,1243983997,1244736049,1262979035,1312007069,1312030297,1356274316,1368442960,1377432523,1415342434,1471294243,1529353536,1537868913,1566069818,1610578189,1612277199,1613646498,1639183592,1668015280,1764022840,1784234921,1786654280,1835593744,1849372222,1875931624,1877593764,1899940939,2007896363,2023046907,2030492562,2032619034,2085680072,2085750388,2110824853,2123924948,2131327206,2134927760,2136423634],0],
[[1922985547,1934203179,1883318806,1910889055,1983590560,1965316186,2059139291,2075108931,2067514794,2117429526,2140519185,1659645051,1676816799,1611982084,1736461223,1810643297,1753583499,1767991311,1819386745,1355466982,1349603237,1360540003,1453750157,1461849199,1439893078,1432297529,1431882086,1427078318,1487887679,1484011617,1476718655,1509845392,1496496626,1583530675,1579588643,1609495371,1559139172,1554135669,1549766410,1566844751,1562161307,1561938937,1123551908,1086169529,1093103602,1202377124,1193780708,1148229310,1144649241,1257633250,1247607861,1241535002,1262624219,1288523504,1299222235,840314050,909401445,926048886,886867060,873099939,979662326,963003815,1012918112,1034467235,1026553732,568519178,650996158,647728822,616596108,617472393,614787483,604041145,633043809,678181561,698401105,776651230,325294125,271242551,291800692,389634988,346041163,344959554,345547011,342290228,354762650,442183586,467158857,412090528,532898841,534371187,32464799,21286066,109721665,127458375,192166356,146495963,142507512,167676030,236532616,262832772],1927544832],
[[1922985547,1934203179,1883318806,1910889055,1983590560,1965316186,2059139291,2075108931,2067514794,2117429526,2140519185,1659645051,1676816799,1611982084,1736461223,1810643297,1753583499,1767991311,1819386745,1355466982,1349603237,1360540003,1453750157,1461849199,1439893078,1432297529,1431882086,1427078318,1487887679,1484011617,1476718655,1509845392,1496496626,1583530675,1579588643,1609495371,1559139172,1554135669,1549766410,1566844751,1562161307,1561938937,1123551908,1086169529,1093103602,1202377124,1193780708,1148229310,1144649241,1257633250,1241535002,1247607861,1262624219,1288523504,1299222235,840314050,909401445,926048886,886867060,873099939,979662326,963003815,1012918112,1034467235,1026553732,568519178,650996158,647728822,616596108,617472393,614787483,604041145,633043809,678181561,698401105,776651230,325294125,271242551,291800692,389634988,346041163,344959554,345547011,342290228,354762650,442183586,467158857,412090528,532898841,534371187,32464799,21286066,109721665,127458375,192166356,146495963,142507512,167676030,236532616,262832772],'X']
].forEach(t=>{
  var i=t[0],k=t[1],r=X(i)
  console.log((k==r?'OK ':'Error (expected '+k+') ')+r+' for input '+i)
})
<pre id=O></pre>

ES6, 84 bytes
a=>(i=e=0,a.reduce((x,y)=>(z=1<<31-Math.clz32(x^y),x>y?i|=z:y>x?e|=z:z,y)),i&e?-1:i)

Edit: By the time it took me to write the answer the algorithm had already been independently posted by @Jakube; my algorithm is the same but this wasn't plagiarism honest! Also I notice another JavaScript answer has since been posted too. Sorry if I'm stepping on anyone's toes.
Edit: Saved 8 bytes thanks to edc65.

You're not stepping on anyone's toes at all. This is a good answer, nice work. :)

Nice, you beat @edc65! That almost never happens.

You have my vote. I think you too should use the clz32 function to beat me again.

If only 1<<31>>>32 was zero then I could save another 4 bytes.

C, 144 bytes
#include <strings.h>
#include <stdio.h>
m[2],l,i;main(v){while(scanf("%d",&v)==1)m[l<v]|=(i++&&v^l)<<~-fls(v^l),l=v;printf("%d",*m&m[1]?-1:*m);}

This is almost standard C99 (it misses a few int specifiers and has 1 argument for main). It also relies on 0<<-1 being 0 (which seems to be true when compiled with Clang at least — I haven't tested others)
I've taken Jakube's method and ported it to C. I think it does surprisingly well size-wise for C. It's also super-fast (0.061s to run all test files, including the massive 4). It takes input from STDIN and will print the matching value or -1 to STDOUT, so run it with one of:
echo "4 7 6 1 0 0 3" | ./xort
./xort < file.txt

Breakdown:
// Globals initialise to 0
m[2],                                    // Stores our bit masks
                                         // (m[0]=CHANGE, m[1]=MUST NOT CHANGE)
l,                                       // Last value
i;                                       // Current iteration
main(v){
    while(scanf("%d",&v)==1)             // Read each value in turn
        m[l<v]|=                         // If they are sorted, we mark a bit as
                                         // MUST NOT CHANGE (m[1]), otherwise we
                                         // mark as CHANGE (m[0])
                (i++&&v^l)               // If this is the first iteration,
                                         // or the value is unchanged, mark nothing
                          <<~-fls(v^l),  // Mark the highest bit which has changed
                                         // = (1<<(fls(v^l)-1)
        l=v;                             // Update last value
    printf("%d",
                *m&m[1]                  // Check if result is valid (if any bits
                                         // are both MUST NOT CHANGE and CHANGE,
                                         // it is not valid)
                       ?-1               // Print -1 on failure
                          :*m);          // Print value on success
}

Julia, 124 bytes
f(x,g=0)=issorted(([g|=2^Int(log2(h)÷1)for h=map(k->k[1]$k[2],filter(j->j[1]>=j[2],[x[i-1:i]for i=2:endof(x)]))];g)$x)?g:-1

This is a function that accepts an integer array and returns an integer. It uses Jakube's approach.
Ungolfed:
function f{T<:Integer}(x::Array{T,1}, g::T=0)
    # Get all pairs of elements in the input array
    pairs = [x[i-1:i] for i = 2:endof(x)]

    # Filter to pairs in descending order
    desc = filter(j -> j[1] ≥ j[2], pairs)

    # Map XOR over these pairs
    xord = map(k -> k[1] $ k[2], desc)

    # For each element of this array, update the
    # parameter g (which defaults to 0) as the
    # bitwise OR of itself and 2^floor(log2(element))
    for h in xord
        g |= 2^Int(log2(h) ÷ 1)
    end

    # If the array constructed as g XOR the input is
    # sorted, we've found our answer! Otherwise -1.
    return issorted(g $ x) ? g : -1
end

Out of curiosity, why is XOR $?

CJam, 37 bytes
q~_2ew{:>},{:^2mLi2\#}%0+:|_@f^_$=\W?

Test it here.
This uses the same algorithm as several of the other answers. It's essentially my reference implementation which I used to create the test cases. However, I did steal Jakube's trick of checking only the offending pairs and simply trying out the result with a sort. That breaks the pseudolinearity, but O(n log n) is still fast enough for the test cases. My original code also checked the pairs that are already in order, and built up a list of bits which must not be toggled in order to keep their relative order, and checked at the end that there are no overlaps between the two bit masks. This algorithm was originally suggested by Ben Jackson.

Python 2, 204 bytes
def f(a):
 m=n=0
 for i in range(32):
  b=2**(31-i);m|=b
  for n in[n,n|b]:
   if not q(a,m,n):break
  else:return-1
 return n
def q(a,m,n):
 if a:p=a[0]&m^n
 for t in a:
  t=t&m^n
  if t<p:return 1
  p=t

The input is passed as a list to function f.
This code figures out the value of N (named n in the program) one bit at a time, starting with the most significant bit. (the "for i" loop)
For each bit position, the "for n" loop first tries using 0 for that bit of n. If that doesn't work, it tries using 1. If neither of these works, then there is no solution. Note that the else clause is on the "for n" loop, not the if statement. In Python, a for statement can have an else clause, which is executed after the loop runs to completion, but is not executed if we break out of the loop.
The q function checks for problems with the list order given the list (a), a bit mask (m), and the value to be xored with each value in the list (n). It returns 1 if there is a problem with the ordering, or None if the order is ok. None is the default return value, so that saved me several characters.
This code handles an empty list or a list with 1 element correctly, returning 0. The "if a:" in function q is there only to avoid an IndexError exception when the list is empty. So 5 more bytes could be removed if handling empty lists isn't required.
On my computer, large test case #3 took 0.262 seconds. #2 took about the same. All the test cases together took 0.765 seconds.

Handling empty lists isn't required, I'll clarify that.

Python 2, 226 214 bytes
Simpleish algorithm, built it yesterday, golfed today.
o=input()
s=sorted
p=s(set(o),key=o.index)
n=q=0
while 1:
 a=1
 while 1-q and p[0]<p[1]:p=p[1:];q=len(p)==1
 if q:break
 while not p[0]^a<p[1]^a:a*=2
 n+=a;p=[i^a for i in p]
t=[a^n for a in o]
print[-1,n][s(t)==t]

Ungolfed:
def xor(a,b): return a^b

def rm_dupes(seq):
    seen = set()
    seen_add = seen.add
    return [x for x in seq if not (x in seen or seen_add(x))]

def rm_sorted(seq):
    while seq[0] < seq[1]:
        seq = seq[1:]
        if len(seq) == 1: return seq
    return seq

inp = input()
oi = inp

inp = rm_dupes(inp)
n=0
old_inp=0
while old_inp != inp:
    old_inp = inp
    inp = rm_sorted(inp)
    if len(inp)==1:break
    highest_set0 = len(bin(inp[0]))-3 # bin returns in form 0bxxx
    highest_set1 = len(bin(inp[1]))-3 # bin returns in form 0bxxx
    if highest_set1 == 0:
        try:
            t0 = max(int(bin(inp[0])[3:], 2), 1)
        except ValueError: toggle_amount = 1
        else: toggle_amount = t0^inp[0]
    else:
        fallen = False
        for i in xrange(max(highest_set0,highest_set1)+1):
            toggle_amount = 2**i
            if inp[0]^toggle_amount < inp[1]^toggle_amount:
                fallen = True
                break
        assert(fallen)
    n+=toggle_amount
    inp = [i^toggle_amount for i in inp]

out=map(xor, oi, [n]*len(oi))
if sorted(out)==out :print n
else:print -1

C, 312 bytes
#define R return
t,i,*b;f(int*a,int l,int k){int s=a[0]>>k&1,j=-1,i=1;if(k<0)R 0;for(;i<l;++i){t=a[i]>>k&1;if(s!=t)if(j<0)j=i,s=t;else R 1;}if(j<0)R f(a,l,k-1);else{if(s+b[k]==2)R 1;b[k]=s+1;R f(a,j,--k)||f(a+j,l-j,k);}}h(int*a,int l){int c[32]={0};b=c;if(f(a,l,30))R -1;t=0;for(i=0;i<32;++i)t|=(b[i]&1)<<i;R t;}

Defines a function h(int*a,int l) taking a pointer to an array and its length. Here is a test program behemoth.
Slightly ungolfed:
int t, i, *b;

int f(int * a, int l, int k) {
    int s = a[0] >> k & 1;
    int j = -1;
    int i = 1;
    if (k < 0) return 0;
    for (; i < l; ++i) {
        t = a[i] >> k & 1;
        if (s != t) {
            if (j < 0) {
                j = i;
                s = t;
            } else return 1;
        }
    }
    if (j < 0) {
        return f(a, l, k - 1);
    } else {
        if (s + b[k] == 2) return 1;
        b[k] = s + 1;
        return f(a, j, --k) || f(a + j, l - j, k);
    }
}

int h(int * a, int l) {
    int c[32] = {0};
    b = c;
    if (f(a, l, 30)) return -1;
    t = 0;
    for (i = 0; i < 32; ++i) {
        t |= (b[i] & 1) << i;
    }
    return t;
}

Mathematica, 99 97 Characters
Thanks to Martin Büttner for advices.
x@l_:=If[OrderedQ[l~BitXor~#],#,-1]&@Fold[#+#2Boole@!OrderedQ@⌊l~BitXor~#/#2⌋&,0,2^32/2^Range@32]

Explanation:
We will do multiple tries to modify N starting from zero, and do a test to validate the candidate N.
Step 1. We get these numbers (32-bit integers) "xor"ed by N(= 0 now) and divided by 2^31: ⌊l~BitXor~#/#2⌋. There are three cases:

ordered, e.g. {0, 0, 1, 1, 1, 1, 1, 1};
can be corrected, e.g. {1, 1, 1, 1, 0, 0, 0, 0};
else, e.g. {0, 0, 1, 0, 0, 1, 1, 1}.

We do nothing to N for the first case, or we add 2^31 to N to correct the order for the second case: #+#2Boole@!OrderedQ@.... While for the third case, it is impossible to xorting the list what ever we do, thus we just add 2^31 to N for simplicity (or anything!).
Step 2. We get these numbers "xor"ed by N and divided by 2^30. There are again three cases:

ordered, e.g. {0, 1, 2, 2, 2, 2, 3, 3};
can be corrected, e.g. {1, 1 , 0, 0, 3, 2, 2, 2};
else, e.g. {3, 3, 1, 3, 2, 0, 1, 0}.

We do nothing to N for the first case, or we add 2^30 to N to correct the order for the second case. Otherwise, we realize that xorting is impossible, thus we just add 2^30 to N for simplicity again.
Step 3 ~ 32. We recursively get these numbers "xor"ed by N and divided by 2^29, 2^28, ..., 2^0. And do similar things: Fold[...,0,2^32/2^Range[32]]
Step 33. Now we finally get a candidate N. If[OrderedQ[l~BitXor~#],#,-1]& is used to check if such N indeed xorting the list. If the list can be xorting by some N, it is not difficult to proof that we will always encounter the first or the second case.

Perl 6, 79 bytes
If there wasn't a time limit the shortest Perl 6 code would probably be
{first {[<=] $_ X+^@_},^2*.max} # 31 bytes

Instead I have to do something a bit more clever.
Since I took a while to come back to this, there was already an answer that describes a good algorithm, and the reasoning behind it.
{$/=0;for @_.rotor(2=>-1) ->(\a,\b){b>=a or$/+|=2**msb a+^b};$/if [<=] $/X+^@_} # 79

{
  # cheat by using a special variable
  # so there is no need to declare it
  $/=0;

  # takes the elements two at a time, backing up one
  for @_.rotor(2=>-1)
    # since that is a non-flat list, desugar each element into 2
    # terms
    ->(\a,\b){
      # if they are not sorted
      b>=a or
      # take the most significant bit of xoring the two values
      # and numeric or ｢+|｣ it into ｢$/｣
      $/+|=2**msb a+^b
    };

  # returns ｢$/｣ if the list is Xorted
  # otherwise returns Empty
  $/if [<=] $/X+^@_

  # ｢ $/ X[+^] @_ ｣
  # does numeric xor ｢+^｣ between ｢$/｣
  # and each element of the original list ｢@_｣
}

Usage:
# give it a lexical name for ease of use
my &code = {...}

say code [8,4,3,2,1];     # 15

say code [4,7,6,1,0,3]; # 5
say code [4,7,1,6,0,3]; # ()
say code [0,1,3,4,6,7]; # 0
say code [4,2,3,1];     # 6
say code [2,3,0,0,7,7,4,5,11,11]; # 2
say code [2,3,0,0,7,7,5,4,11,11]; # ()
say code [1086101479,748947367,1767817317,656404978,1818793883,1143500039]; # ()

# the example files
for 'testfiles'.IO.dir.sort».comb(/«\d+»/) {
  printf "%10s in %5.2f secs\n", code( @$_ ).gist, now - ENTER now;
}
#         () in  9.99 secs
#          0 in 11.70 secs
# 1096442624 in 13.54 secs
#         () in 11.44 secs

Mathematica 650 415 194 bytes
This challenge helped me understand quite a bit about Xor that I had never thought about.  It took a long time to whittle down the code, but was worth the effort.
BitXor works directly on base 10 numbers.  This greatly reduced the code from the earlier versions.
The logic is simple.  One works, not with pairs of numbers (as some submissions did) but rather with the complete set of numbers after being BitXored with the current "key".
Start with tentative solution, or "key" of zero, that is with all bits are zero.  When the original n numbers are BitXored with zero , they are returned, unaltered.  Correlate the ordering of the numbers with the range1, 2, ...n, which represent a perfectly ordered list.  The correlation, with a value between -1 and 1, reflects how well the numbers are ordered.
Then set the hi bit, obtain the new key, and BitXor the key with the current set of numbers.  If the correlation between the new sequence of numbers and the perfectly ordered list is an improvement, keep the bit set.  If not, leave the bit unset.
Proceed in this manner from the hi to the low bit.  If the best correlation is 1, then the key is the solution.  If not, it is -1.
There would be ways to make the code a bit more efficient, for example, by interrupting the process as soon as a solution is found, but this would require more coding and the current approach is very fast as it is.  (The final and longest test case takes 20 msec.)
c@i_:=Correlation[Ordering@i,Range[Length[i]]]//N;
t@{i_,k_,b_,w_}:=(v= c@BitXor[i,m=k+2^(b-1)];{i,If[v>w,m,k],b-1,v~Max~w})
g@i_:= (If[#4==1,#2,-1] &@@Nest[t,{i,0,b=1+Floor@Log[2,Max@i],x=c@i},b])

g[{4, 7, 6, 1, 0, 3}]

5

g[{4, 7, 1, 6, 0, 3}]

-1

g2@{0, 1, 3, 4, 6, 7}

0

g@{1922985547, 1934203179, 1883318806, 1910889055, 1983590560, 1965316186,2059139291, 2075108931, 2067514794, 2117429526, 2140519185, 1659645051, 1676816799, 1611982084, 1736461223, 1810643297, 1753583499, 1767991311, 1819386745, 1355466982, 1349603237, 1360540003, 1453750157, 1461849199, 1439893078, 1432297529, 1431882086, 1427078318, 1487887679, 1484011617, 1476718655, 1509845392, 1496496626, 1583530675, 1579588643, 1609495371, 1559139172, 1554135669, 1549766410, 1566844751, 1562161307,1561938937, 1123551908, 1086169529, 1093103602, 1202377124, 1193780708, 1148229310, 1144649241, 1257633250, 1247607861, 1241535002, 1262624219, 1288523504, 1299222235,840314050, 909401445, 926048886, 886867060, 873099939, 979662326,963003815, 1012918112, 1034467235, 1026553732, 568519178, 650996158,647728822, 616596108, 617472393, 614787483, 604041145, 633043809, 678181561, 698401105, 776651230, 325294125, 271242551, 291800692, 389634988, 346041163, 344959554, 345547011, 342290228, 354762650, 442183586, 467158857, 412090528, 532898841, 534371187, 32464799, 21286066, 109721665, 127458375, 192166356, 146495963, 142507512, 167676030, 236532616, 262832772}

1927544832

Add++, 125 119 bytes
D,g,@@,BxBBBDbU1€oB]BJ2$Bb1+
D,j,@,bUBSVcGbU£{g}B]BkAbUBSVcGbU£>B]BKBcB*¦Bo2/i
L!,B#a=
D,f,?!,{j}Vad{j}BF€Bx1]G$0=-1$Qp

Try it online!
I am actually really proud that Add++ is able to do this, and isn't the longest solution here
Declares a function f that takes each element as a separate argument (e.g. $f>4>2>3>1)
How it works
Buckle up folks, it's going to be a long ride
D,g,@@,		; Declare a function 'g'
		; Example arguments: 		[4 7]
	Bx	; Xor;			STACK = [3]
	BB	; To binary;		STACK = [11]
	BD	; Digits;		STACK = [[1 1]]
	bU	; Unpack;		STACK = [1 1]
	1€o	; Replace 0s with 1s;	STACK = [1 1]
	B]	; Wrap;			STACK = [[1 1]]
	BJ	; Concatenate;		STACK = ['11']
	2$Bb	; From binary;		STACK = [3]
	1+	; Increment;		STACK = [4]
		;			Return   4

D,j,@,		; Declare a function 'j'
		; Example argument:		[[4 7 6 1 0 3]]
	bU	; Unpack;		STACK = [4 7 6 1 0 3]
	BS	; Overlapping pairs;	STACK = [4 7 6 1 0 3 [[4 7] [4 6] [6 1] [1 0] [0 3]]]
	VcG	; Keep first element;	STACK = [[[4 7] [4 6] [6 1] [1 0] [0 3]]]
	bU	; Unpack;		STACK = [[4 7] [4 6] [6 1] [1 0] [0 3]]
	£{g}	; Apply 'g' over each;	STACK = [4 2 8 2 4]
	B]	; Wrap;			STACK = [[4 2 8 2 4]]
	Bk	; Global save;		STACK = []		; GLOBAL = [4 2 8 2 4]
	A	; Push arguments;	STACK = [[4 7 6 1 0 3]]
	bU	; Unpack;		STACK = [4 7 6 1 0 3]
	BSVcGbU	; Overlapping pairs;	STACK = [[4 7] [4 6] [6 1] [1 0] [0 3]]
	£>	; Greater than each;	STACK = [0 1 1 1 0]
	B]	; Wrap;			STACK = [[0 1 1 1 0]]
	BK	; Global get;		STACK = [[0 1 1 1 0] [4 2 8 2 4]]
	BcB*	; Products;		STACK = [[0 2 8 2 0]]
	¦Bo	; Reduce by logical OR;	STACK = [10]
	2/i	; Halve;		STACK = [5]
		;			Return   5

L!,		; Declare 'lambda 1'
		; Example argument:		[[1 2 3 4 5]]
	B#	; Sort;			STACK = [[1 2 3 4 5]]
	a=	; Equal to argument;	STACK = [1]
		; 			Return   1

D,f,?!,		; Declare a function 'f'
		; Example arguments:		[[4 7 6 1 0 3]]
	{j}	; Call 'j';		STACK = [5]
	V	; Save;			STACK = []		; REGISTER = 5
	ad	; Push arguments twice;	STACK = [[4 7 6 1 0 3] [4 7 6 1 0 3]]
	{j}	; Call 'j';		STACK = [[4 7 6 1 0 3] 5]
	BF	; Flatten;		STACK = [4 7 6 1 0 3 5]
	€Bx	; Xor each with 5;	STACK = [1 2 3 4 5 6]
	1]	; Call 'lambda 1';	STACK = [1]
	G$	; Retrieve REGISTER;	STACK = [5 1]
	0=	; If equal to 0:
	-1$Q	;   Return -1
	p	; Else, pop condition;	STACK = [5]
		;			Return   5

Stax, 29 bytes
¬√▬ⁿ{j╔■α√ï(íP♫_z(.▀ng▒JU↨@b┬

Run and debug online!
Uses @RainerP.'s solution (came up with the flipping bit part independently but uses the 32rr part)
Linear time complexity.
Uses the unpacked version to explain.
32rr{|2Y;{y/m:^!c{,{y|^m~}Mm,:^ud:b
32rr                                   Range [32,31..0]
    {                      m           Map each number `k` in the range with
     |2Y                                   `2^k`
        ;{y/m                              Map each number `l` in the input to `floor(l/2^k)`
             :^!                           The mapped array is not non-decreasing
                                           This is the binary digit `l` is mapped to
                c{       }M                If that's true, do
                  ,{y|^m~                  Flip the corresponding bit of every element in the input
                            ,:^        The final array is sorted
                               ud      Take inverse and discard, if the final array is not sorted this results in zero-division error
                                 :b    Convert mapped binary to integer

Japt, 11 bytes
(Eventually) Outputs undefined for falsey inputs.
@Ë^XÃäÎø1}f

Try it
@Ë^XÃäÎø1}f     :Implicit input of array U
@               :Function taking an integer X as argument
 Ë              :  Map U
  ^X            :    XOR X
    Ã           :  End map
     ä          :  Consecutive pairs
      Î         :  Signs of differences
       ø1       :  Contains 1?
         }      :End function
          f     :Get the first X>=0 that returns false


text:
Do the Chain Rule
We've had a lot of challenges on differentiation and integration, but none on just solving related rates problems. So in this challenge, you will get a bunch of derivatives (They will be numeric, not in terms of any variables) and have to find another derivative.
The input will come in a newline separated list of equations, in the form dx/dt = 4. There can be decimals and negatives.
The input will end with one differential, the one you will have to find. You can assume there will always be enough information to find it, butt there may also be excess information.
You may also have to consider the derivative of the inverse function, e.g. if you have dy/dx = 3, you also know that dx/dy = 1/3.
Your output will be in the form dy/dt = 6. All the whitespace, etc. has to be the same. Assume all variables are always one letter (They can be uppercase, and they can be d).
This is code-golf, so shortest code in bytes wins!
Test Cases
dy/dx = 4
dx/dt = 5
dy/dt

answer: dy/dt = 20

dy/dx = -3
dt/dx = 3
dy/dt

answer: dy/dt = -1

dA/dt = 4
dA/dC = 2
dC/dr = 6.28
dr/dt

answer: dr/dt = 0.3184713375796178

dx/dy = 7
dx/dt = 0
dy/dt

answer: dy/dt = 0

Is the output "answer: dx/dt = .318" or just "dx/dt = .318"?

@GamrCorps the latter.

Can we use built-in equation solvers?

I have a feeling answers will treat d_/d_ as a ratio and that makes me sad

@MartinBüttner yes, but not builtin differential equation solvers.

Will there ever be any zero derivatives?

@MartinBüttner yes.

@Maltysen that should be a test case then ;)

@Mar true, adding.

Can there be cycles ? if so, then in this example where ratios are represented by edges, is it valid? or dx/dz must be equal to dx/dy × dy/dz (thus, in any other example, any chain from dx to dz shall always give the same result)?

@Ampora why so sad? The difference quotient is a ratio, and so are rates in general. There are very few situations where you wouldn't want to treat that as a ratio.

Is it okay to take the input surrounded with quotes (for Python 2)?

I thought I understood the chain rule, but I don't understand the last test case. Can you explain how you get that answer?

@KSFT dx/dy = 7, so dy/dx = 1/7, and therefore dy/dt = (dy/dx)(dx/dt) = (1/7)(0) = 0.

How much precision is required? For example, is it acceptable for the second test case, if we print -0.999999999999999?

Python - 278 275
No one else has done this yet, so I thought I'd submit this, even though it isn't golfed very well yet.
a={}
e={}
k=input
i=k()
while"="in i:
 b,d=i.split(" =");b,c=b.split("/");d=float(d)
 if d:a[b]=a.get(b,[])+[[c,1/d]]
 a[c]=a.get(c,[])+[[b,d]];i=k()
i=i.split("/")
def f(x):
 for j in a.get(x,[]):
  if j[0] not in e:e[j[0]]=e[x]*j[1];f(j[0])
e[i[1]]=1
f(i[1])
print(e[i[0]])

Here it is partially ungolfed:
a={}
e={}
i=input()
while "=" in i:
 b,d=i.split(" =")
 b,c=b.split("/")
 d=float(d)
 if d:a[b]=a.get(b,[])+[[c,1/d]]
 a[c]=a.get(c,[])+[[b,d]]
 i=input()
i=i.split("/")
def f(x):
 for j in a.get(x,[]):
  if j[0] not in e:e[j[0]]=e[x]*j[1];f(j[0])
e[i[1]]=1
f(i[1])
print(e[i[0]])

Three bytes were saved by Thomas Kwa.


text:
Output the Partial Products
In long multiplication, after multiplying the numbers, you are left with the partial products, in this challenge you will output those partial products.
Because long multiplication is long, to compensate your code will need to be as short as possible.
Examples
34, 53
102, 1700

48, 38
384, 1440

361, 674
1444, 25270, 216600

0, 0
0

1, 8
8

Specifications

Input / Output may be in any reasonable format such as array, comma-separated string (or any other delimiter that's not a digit), list, function arguments, etc.
Partial products must be in increasing order.
If a partial product is 0, you can choose whether you want to output it or not.

This is code-golf so shortest code in bytes wins!

I'm assuming that the numbers can be strings, right?

That 0,0 test case is making it a lot harder.

What is the expected outcome for 12, 102? Most answers seem to return 24, 0, 1200.

@Dennis 24, 0, 1200 is fine. I'll specify in the post

Jelly, 10 bytes
DU×µLR’⁵*×

Try it online!
How it works
DU×µLR’⁵*×  Left argument: multiplier -- Right argument: multiplicant

D           Convert the multiplier to base 10 (array of digits).
 U          Reverse the array.
  ×         Multiply each digit by the multiplicant.
   µ        Begin a new, monadic chain. Argument: A(array of products)
    L       Get the length of A.
     R      Turn length l into [1, ..., l].
      ’     Decrement to yield [0, ..., l-1].
       ⁵*   Compute 10**i for each i in that range.
         ×  Hook; multiply the powers of ten by the corresponding elements of A.

I'm guessing the name of this language comes from the fact that it makes everyone feel jelly.

Pyth, 12 bytes
.e**Qsb^Tk_w

Test suite
Takes input newline separated, e.g.
361
674

Explanation:
.e**Qsb^Tk_w
                Implicit: Q = eval(input()),T = 10
           w    Input the second number as a string.
          _     Reverse it.
.e              Enumerated map, where b is the character and k is the index.
     sb         Convert the character to an int.
   *Q           Multiply by Q.
  *    ^Tk      Multiply by T ^ k. (10 ^ index)

JavaScript (ES7), 48 bytes
(a,b)=>[...b+""].reverse().map((d,i)=>10**i*a*d)

ES6 (56 bytes)
(a,b)=>[...b+""].reverse().map((d,i)=>a*d+"0".repeat(i))

Explanation
Returns an array of partial products as numbers.
(a,b)=>
  [...b+""]    // convert the multiplier to an array of digits
  .reverse()   // reverse the digits of the multiplier so the output is in the right order
  .map((d,i)=> // for each digit d of the multiplier
    10**i      // get the power of ten of the digit
      *a*d     // raise the product of the digit to it
  )

Test
Test uses Math.pow instead of ** to make it work in standard browsers.

var solution = (a,b)=>[...b+""].reverse().map((d,i)=>Math.pow(10,i)*a*d)
A = <input type="text" id="A" value="361" />

B = <input type="text" id="B" value="674" />

<button onclick="result.textContent=solution(+A.value,+B.value)">Go</button>

Lua, 72 68 Bytes
b=arg[2]:reverse()for i=1,#b do print(arg[1]*b:sub(i,i)*10^(i-1))end

APL, 21 bytes
{⍺×x×10*1-⍨⍳≢x←⊖⍎¨⍕⍵}

This is a dyadic function that accepts integers on the left and right and returns an array. To call it, assign it to a variable.
Explanation:
             x←⊖⍎¨⍕⍵} ⍝ Define x to be the reversed digits of the right input
     10*1-⍨⍳≢         ⍝ Generate all 10^(1-i) for i from 1 to the number of digits
{⍺×x×                 ⍝ Multiply the right input by the digits and the powers of 10

⍎¨⍕ is pretty clever.

Pyth, 26 bytes
DcGHKjHTFNJlK*G*@Kt-JN^TN

This defines a function c such that it accepts 2 arguments, and the function prints the partial products.
DcGHKjHTFNJlK*G*@Kt-JN^TN
DCGH                      Define function c(G, H)
    KjHT                  Set K to the list of digits converting H to base 10
        FNJlK             Set J to the length of K and loop with variable N
                          (Implicit: print)
             *G*@Kt-JN    Calculates the partial product
                      ^TN Raising it to the appropriate power of 10

05AB1E, 15 bytes
Code:
VDgUSXFTNmY**=\

Explanation:
VDgUSXFTNmY**=\

V                 # Assign the input to Y
 D                # Duplicate of input, because the stack is empty
  g               # Pushes the length of the last item
   U              # Assign the length to X
    S             # Split the last item
     X            # Pushes X (length of the last item)
      F           # Creates a for loop: for N in range(0, X)
       TNm        # Pushes 10 ^ N
          Y       # Pushes Y (first input)
           *      # Multiplies the last two items
            *     # Multiplies the last two items
             =    # Output the last item
              \   # Discard the last item

MATL, 18 bytes
ij48-tn:1-P10w^**P

The compiler (5.1.0) works in Matlab and in Octave.
Each number is input on a separate line.
Example
>> matl ij48-tn:1-P10w^**P
> 361
> 674
1444  25270 216600

Explanation
i           % input first number (say 361)
j           % input second number, interpreted as a string (say '674')
48-         % subtract '0' to obtain vector of figures (gives [6 7 4])
tn:1-P      % vector [n-1, ... 1, 0] where n is the number of figures (gives [2 1 0])
10w^        % 10 raised to that, element-wise (gives [100 10 1])
*           % multiply, element-wise (gives [600 70 4])
*           % multiply (gives 361*[600 70 4], or [216600 25270 1444])
P           % flip vector ([1444 25270 216600]). Implicitly display

Haskell, 60 57 54 bytes
g x=zipWith(\b->(x*10^b*).read.pure)[0..].reverse.show

5 bytes less (drop the .show) if I can take the second number as a string.
Usage example: g 361 674 -> [1444,25270,216600].
Multiply every digit of the reverse of y with x and scale with 10^i where i = 0,1,2,....
Edit: Thanks to @Mauris for 3 bytes!

You can even do (\b->(x*10^b*).read.pure).

@Mauris: Nice. Thanks a lot!

Julia, 50 49 bytes
f(a,b)=[a*d*10^~-i for(i,d)=enumerate(digits(b))]

This is a function that accepts two integers and returns an integer array.
The digits function returns an array of the input integer's digits in reverse order. We get the index, value pairs using enumerate and compute the partial products as the first input times the digits times 10 raised to the power of the digit's index - 1.
Saved a byte thanks to Dennis!

CJam, 19 17 bytes
q~W%eef{~~A@#**}p

Takes input with the first item being an integer and the second a string (e.g. 34 "53"). Suggestions are welcome, as I'm sure it can be shorter. Thanks to Dennis for saving two bytes.
Try it online.
Explanation
q~    e# Get input and evaluate it, x and "y"
W%    e# Reverse y so it will be properly sorted
ee    e# Enumerate through y with each character and its index
f{    e# For each digit in y...
  ~~  e# Convert the digit to an integer on the stack
  A@# e# Take 10 to the power of y's index
  **  e# Multiply all three together to get the final result
}
p     e# Print the array

~~A@#** saves a couple of bytes.

Python 2, 61
def p(a,b):
 j=0
 while b>0:
  print`b%10*a`+j*'0';b/=10;j+=1

Haskell, 37 bytes
a%0=[]
a%b=b`mod`10*a:(a*10)%div b 10

No stringifying, just arithmetic. Recursively prepends the smallest partial product to the rest, where the last digit of b is truncated and a multiplier of 10 is applied. The operator precedence works nicely.

Japt, 8 bytes
Takes input in reverse order with the first being a digit array and the second being an integer. If both inputs must be of the same type then we can take them both as strings and add ¬ to the beginning.
ÔË*V*ApE

Try it
¬ÔË*V*ApE     :Implicit input of array U & integer V (or strings U & V)
¬             :(Split U, if inputs are strings)
 Ô            :Reverse U
  Ë           :Map each element at 0-based index E
   *V*        :  Multiply by V multiplied by
      A       :  10
       pE     :  Raised to the power of E (1eE would also work in place of ApE)

, 11 chars / 23 bytes (non-competitive)
ᴙíⓢⓜî*$*Ⅹⁿ_

Try it here (Firefox only).
Found a bug while coding the solution to this problem...
Explanation
          // Implicit: î = input 1, í = input 2
ᴙíⓢ      // reverse í and split it into an array
ⓜî*$*Ⅹⁿ_ // multiply î by each individual digit in í and put in previous array
          // implicit output

Japt, 28 bytes
I=[]Vs w m@IpApY+1 /A*U*X};I

Explanation:
I=[]Vs w m@IpApY+1 /A*U*X};I
I=[]                         //that's simple, init an array I
    Vs                       //take the second input and convert to string
       w                     //reverse it and...
         m@              }   //...map through the chars; X is a char, Y is counter
           Ip............    //push the following value into I...
             ApY+1 /A*U*X    //10^(Y+1)/10*U*X, U is the first input
                           I //output the resulting array

Due to the bug in the interpreter, have to use ApY+1 /10 instead of ApY, because Ap0 (which is 10^0) gives 100. I guess it's for the reason to allow fast squaring with Ap, but 0 doesn't mean "no arguments". Plz fix, Eth.

Python 2, 42 bytes
f=lambda a,b:b*[0]and[b%10*a]+f(a*10,b/10)

No stringifying, just arithmetic. Recursively appends the smallest partial product to the rest, where the last digit of b is truncated and a multiplier of 10 is applied.

Husk, 10 bytes
z*:1İ⁰↔M*d

Try it online!