[Question]
  [
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](/questions/tagged/code-golf "show questions tagged '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](https://en.wikipedia.org/wiki/Involution_(mathematics))), the test
cases should work in both directions):
```
In/Out   Out/In
----------------
#ffffff  #000000
#abcdef  #543210
#badcab  #452354
#133742  #ecc8bd
#a1b2c3  #5e4d3c
#7f7f80  #80807f
```
  
[Answer]
## 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](https://pyth.herokuapp.com/?code=sXz.HM16&input=%23a1b2c3&debug=1). [Test suite.](https://pyth.herokuapp.com/?code=sXz.HM16&test_suite=1&test_suite_input=%23ffffff%0A%23000000%0A%0A%23abcdef%0A%23543210%0A%0A%23badcab%0A%23452354%0A%0A%23133742%0A%23ecc8bd%0A%0A%23a1b2c3%0A%235e4d3c%0A%0A%237f7f80%0A%2380807f&debug=1)
[Answer]
# 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.](http://retina.tryitonline.net/#code=VGB3YEctQTktMA&input=I0ZGRkZGRiAgIzAwMDAwMAojQUJDREVGICAjNTQzMjEwCiNCQURDQUIgICM0NTIzNTQKIzEzMzc0MiAgI0VDQzhCRAojQTFCMkMzICAjNUU0RDNDCiM3RjdGODAgICM4MDgwN0Y)
[Answer]
# [Julia 0.6](http://julialang.org/), ~~74~~ 49 bytes
```
h->"#"join([hex(15-parse(Int,i,16))for i=h[2:7]])
```
[Try it online!](https://tio.run/##XcvNisMgGIXhvVchdaOQDlGTGgYyzKow11C68Jd8EmxQC3P3GZPlvLvzwInvFfRtv8/7cv26kEt8QaKPxf9SPl43nYunP6l20PEbY@GVMczLQ3yq55Ptx6TQ4cgwJFy2FeoHzV67FZIvlDGEW9@6FJ8rvlNgeJ5x/KfxVEA@ObRlSHVNtOa3ZzsJZxiT/gwRbazzB4yDFLyB0c5q02AYhRwHRLiUahANvLWTce3CjbDyuPjBSYuICipMfYOpn3oV/gA "Julia 0.6 ‚Äì 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](https://codegolf.stackexchange.com/a/68309/20469), 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.
[Answer]
# Marbelous, 41 bytes
```
00@0
\\]]\/
-W/\@0
-W
~~
<A+700
+O//]]
+O
```
[Online Interpreter here.](https://codegolf.stackexchange.com/a/40808) 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`.
[Answer]
# 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
[Answer]
## JavaScript ES6, ~~63~~ ~~58~~ ~~52~~ 49 bytes
```
c=>c.replace(/\w/g,x=>(15-`0x${x}`).toString(16))
```
*Thanks to [nderscore](https://codegolf.stackexchange.com/users/20160/nderscore) for saving 11 bytes!*
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 4 bytes
```
k6·∏Çƒø
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCJrNuG4gsS/IiwiIiwiYTFiMmMzIl0=)
```
k6·∏Çƒø
k6   # Hex chars - "012356789abcdef"
  ·∏Ç  # Bifurcate - push its reverse without popping
   ƒø # Transliterate the input from the hex chars to the reverse hex chars
```
[Answer]
# 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!](http://conorobrien-foxx.github.io/Jolf/#code=cHEjLXdefjU2QyBMaTF-NTYw), [Test suite](http://conorobrien-foxx.github.io/Jolf/#code=cHEjLXdeODhDIExpMX41NjA&input=I2ZmZmZmZgoKI2FiY2RlZgoKI2JhZGNhYgoKIzEzMzc0MgoKI2ExYjJjMwoKIzdmN2Y4MA) (Use full run, which now works.)
[Answer]
# [Japt](http://ethproductions.github.io/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)
```
[Answer]
# 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'`.
[Answer]
# [MATL](https://github.com/lmendo/MATL/releases/tag/6.0.0), 21 bytes
```
35,5Y216,j6L)!16ZA-)h
```
This uses [release 6.0.0](https://github.com/lmendo/MATL/releases/tag/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**](http://matl.tryitonline.net/#code=MzUgNVkyMTYgajRMKSExNlpBLSlo&input=I0ZGQUEyMA). 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 '#'
```
[Answer]
# 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`.
[![enter image description here](https://i.stack.imgur.com/TcdFJ.png)](https://i.stack.imgur.com/TcdFJ.png)
[Answer]
# [Japt](https://github.com/ETHproductions/japt) v2.0a0, 9 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
r\w√ànG'nF
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&code=clx3yG5HJ25G&input=IiM3ZjdmODAi)
```
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
```
[Answer]
# Pyth, ~~20~~ 19 bytes
*[1 byte](https://codegolf.stackexchange.com/questions/68305/complementary-colors/68307?noredirect=1#comment165760_68307) thanks to [xnor](https://codegolf.stackexchange.com/users/20260/xnor).*
```
%"#%06x"-t^8 8itz16
```
[Try it online.](http://pyth.herokuapp.com/?code=%25%22%23%2506x%22-t%5E8+8itz16&input=%23badcab&debug=0) [Test suite.](http://pyth.herokuapp.com/?code=%25%22%23%2506x%22-t%5E8+8itz16&test_suite=1&test_suite_input=%23ffffff%0A%23abcdef%0A%23badcab%0A%23133742%0A%23a1b2c3%0A%237f7f80&debug=0)
### 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 `#`
[Answer]
# Java, ~~95~~ 90 bytes
```
String f(String v){return v.format("#%06x",0xFFFFFF^Integer.parseInt(v.substring(1),16));}
```
Bitwise XOR.
[Answer]
# 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!
[Answer]
# 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.
[Answer]
# 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.
[Answer]
# ùîºùïäùïÑùïöùïü 2, 18 chars / 34 bytes
```
√Øƒì/\w‚åø,‚Ü™(·∏è-`·∂ç‚¶É$}‚Äù‚ìß
```
`[Try it here (Firefox only).](http://molarmanful.github.io/ESMin/interpreter2.html?eval=false&input=%23ffffff&code=%C3%AF%C4%93%2F%5Cw%E2%8C%BF%2C%E2%86%AA%28%E1%B8%8F-%60%E1%B6%8D%E2%A6%83%24%7D%E2%80%9D%E2%93%A7)`
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.
[Answer]
## sed, 48 bytes
```
y/0123456789ABCDEFabcdef/fedcba9876543210543210/
```
Or 36 bytes if you only need to support one case.
[Answer]
## 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 :)
[Answer]
# [Befunge](https://esolangs.org/wiki/Befunge)-[98](https://esolangs.org/wiki/Funge-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!](https://tio.run/##S0pNK81LT9W1tPj/v06nzK6Mqy7NJk6hmMtOJ07BTtfKstxO3UCbK047XF0BCGLj/v9XTjRMMko2BgA "Befunge-98 (FBBI) ‚Äì Try It Online")
[40 byte version that terminates](https://tio.run/##S0pNK81LT9W1tPj/v06nzK6MSyHNJk6huM5BmctOJ07BTtfKstxO3UCbK047XF0BCGLj/v9XTjRMMko2BgA)
## 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.
[Answer]
# [C (clang)](http://clang.llvm.org/), ~~53~~ 49 bytes
```
p(*s){printf("#%06x",0xffffff-wcstol(s+1,0,16));}
```
[Try it online!](https://tio.run/##S9ZNzknMS///v0BDq1izuqAoM68kTUNJWdXArEJJx6AiDQx0y5OLS/JzNIq1DXUMdAzNNDWta//nJmbmaWhWcykoFGj4KClDVCppWheUlhRrKAEZMJnEpOSUVKwySYkpyYlJ2GQMjY3NTYywmmaYZJRsjE3GPM08zcIARab2PwA "C (clang) ‚Äì Try It Online")
-4 thanks to @jdt
[Answer]
# [Julia 1.0](http://julialang.org/), 46 bytes
```
h->'#'repr(~parse(UInt,h[2:7];base=16))[13:18]
```
[Try it online!](https://tio.run/##fcy9bsMgFIbh3VdxFIaAlEYG7BglIqOlXkCnKAN/VkAWtbArZYh66y6mnfuND@clfI1e0efay/Xxdt2jfXJTwt@TSrPDH@9xOTxu7NzdL1rNTtITITfKz1Tc1@EzAfYHCAR8hHka/XLEySk7@uhmTEgFeT32RMoArxdMyccF756wI1DeCowRe5DXcvjnPc5/Sgn@3yr8VmGrXLQrGsoAUF1WIaWNdRu0DWc0g1bWKJ2haRlvmwpRzruGZXDGCG1zQjUzfEtcY7mpUDd0g6gziFrU3fAD "Julia 1.0 ‚Äì Try It Online")
# [Julia 0.6](http://julialang.org/), 40 bytes
```
h->"#"hex(~parse(UInt,h[2:7],16))[11:16]
```
[Try it online!](https://tio.run/##fczNboQgFIbhvVdxIhtInEZAxUzCLE16AV1NZoH8RIihRm0yi0lv3SLtut/y4byEr9mr7hjkMV1uJSon@8Tfi1o3iz/e415Nd3YVj4p2hNwpvdLucbjPFbCvIBDwEbZl9vsbXq0ys492w4QUkDZgT6QM8HrBsvq44/IJJYH8lmGO2IO85cM/H3D6U0rw/1bhtwpnZaM5kMsDQHVegdSojT2hbTijCUZltBoTNC3jbVMgyrloWAKrdT@alNCRaX4mtjFcF0g44fo6QV/3tXA/ "Julia 0.6 ‚Äì 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
[Answer]
# [Nibbles](http://golfscript.com/nibbles/index.html), 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 '#')
```
[![enter image description here](https://i.stack.imgur.com/DfKV6.png)](https://i.stack.imgur.com/DfKV6.png)
[Answer]
# [Go](https://go.dev), 111 bytes
```
import(."strconv";."fmt")
func f(s string)string{n,_:=ParseInt(s[1:],16,64)
return Sprintf("#%06x",0xffffff-n)}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=LZBLasMwEIbX1SkGmYAFSvArtklJl4XuAl22JZFlyZg04yApJRBykm5CocfoprfobSo_ZjPwzfwz88_nV9Pdfo5C7kWj4CBaJO3h2Bm3oNaZFhtLv09Oz8u_buThUJAdftD7BdUHRxnRJ5SgQwujhI3pgny7Wm-EseoJXWhf4tUbj3OeZ4wY5U4G4fnoG50OaTCL8jPl0VkPMUd2ndb-DsP7w0IGFyKFVRZWa3hs1Xttw10wKgCCaAgSiErWqgfLLE1iDypRS1F5kC2TdJmRIE7TIks8UFKWVe0lcZXItJeorE4lCQpd6DLyoIzKqNA777EzsOXYrzYC_a_GSy7kbjN5mFmYP8DMviLlgNw_BBkjVzI5ud3G_A8)
[Answer]
# 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](https://codegolf.stackexchange.com/a/68308/29750) for more on transliteration.
[Try it online.](http://cjam.aditsu.net/#code=qA%2C'G%2C65%3E%2Bs_W%25er&input=%23A1B2C3)
### 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
```
[Answer]
# 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))
```
[Answer]
## 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.
[Answer]
## 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?
]