An RGB color code is consists of 7 characters in which the first character is ‘#’ and every other character represents a hexadecimal digit from 0 to f.
The first line contains an integer 'T' which denotes the number of test cases or queries to be run.
The first line of each test case contains a string ‘color’ representing an RGB color code.
For each test case, print a string that represents a perfect RGB color code and is most similar to the given RGB color code.
The output of each test case will be printed in a separate line.
You do not need to input or print anything, and it has already been taken care of. Just implement the given function.
1 <= T <= 5
length of color = 7
color[0] = ‘#’
Color[i] is a hexadecimal digit from 0 to f, for every i - 1 to 6.
Time Limit: 1sec
We know that the given string can be divided into three parts, and each part can be handled separately.
For example, for the string "#09f166", we will process "09", ''f1”, and ''66”separately. Our goal is to make the two characters of each part the same with the smallest distance from the original. In fact, there are not many choices for each path as there can be only 16 characters possible i.e [ ‘0’, ‘1’, ‘2’ …. ‘f’ ].