Skip to main content
4 of 5
added 229 characters in body
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372

#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 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 '#'
Luis Mendo
  • 105.3k
  • 9
  • 135
  • 372