Find the closest three-digit hex colour In CSS, colours can be specified by a "hex triplet" - a three byte (six digit) hexadecimal number where each byte represents the red, green, or blue components of the colour. For instance, #FF0000 is completely red, and is equivalent to rgb(255, 0, 0).

Colours can also be represented by the shorthand notation which uses three hexadecimal digits. The shorthand expands to the six digit form by duplicating each digit. For instance, #ABC becomes #AABBCC.

Since there are fewer digits in the hex shorthand, fewer colours can be represented.

The challenge

Write a program or function that takes a six digit hexadecimal colour code and outputs the closest three-digit colour code.

Here's an example:


  
  Input hex code: #28a086
  Red component
  
  
  0x28 = 40 (decimal)
  0x22 = 34
  0x33 = 51
  0x22 is closer, so the first digit of the shortened colour code is 2
  
  Green component
  
  
  0xa0 = 160
  0x99 = 153
  0xaa = 170
  0x99 is closer, so the second digit is 9
  
  Blue component
  
  
  0x86 = 134
  0x77 = 119
  0x88 = 136
  0x88 is closer, so the third digit is 8
  
  The shortened colour code is #298 (which expands to #229988)
  


Your program or function must accept as input a six digit hexadecimal colour code prepended with # and output a three digit colour code prepended with #.

Examples


#FF0000 → #F00
#00FF00 → #0F0
#D913C4 → #D1C
#C0DD39 → #BD3
#28A086 → #298
#C0CF6F → #BC7


Scoring

This is a code-golf challenge, so shortest answer in your language wins! Standard rules apply.
05AB1E, 13 bytes

ćs2ôH8+17÷hJ«


Try it online!

How?

ćs2ôH8+17÷hJ« | string, S   e.g. stack: "#B23F08"
ć             | decapitate              "B23F08", "#"
 s            | swap                    "#", "B23F08"
  2           | two                     "#", "B23F08", 2
   ô          | chuncks                 "#", ["B2", "3F", "08"]
    H         | from hexadecimal        "#", [178, 63, 8]
     8        | eight                   "#", [178, 63, 8], 8
      +       | add                     "#", [186, 71, 16]
       17     | seventeen               "#", [186, 71, 16], 17
         ÷    | integer divide          "#", [10, 4, 0]
          h   | to hexadecimal          "#", ["A", "4", "0"]
           J  | join                    "#", "A40"
            « | concatenate             "#A40"
              | print top of stack