import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
from webcolors import hex_to_name
def hex_to_rgb(hex_value):
hex_value = hex_value.lstrip('#')
return tuple(int(hex_value[i:i+2], 16) for i in (0, 2, 4))
def display_color_info(hex_colors):
fig, ax = plt.subplots(figsize=(12, len(hex_colors) * 2))
count = 0
for i, hex_value in enumerate(hex_colors):
hex_value = hex_value[:7]
rgb_values = hex_to_rgb(hex_value)
try:
color_name = hex_to_name(hex_value, spec='css3')
except ValueError:
color_name = "Unknown"
strip_line = Rectangle((0, i), 1, 1, color=hex_value, ec='k')
ax.add_patch(strip_line)
count += 1
counter = format(count, '02')
ax.text(1.2, i + 0.5, f"puzzle : {counter} | color : {color_name} | Hex : {hex_value}", va='center', fontsize=12)
ax.set_xlim(0, 2)
ax.set_ylim(0, len(hex_colors))
ax.axis('off')
plt.tight_layout()
plt.show()
int_list = [1, 3, 7, 8, 21, 49, 76, 224, 467, 514, 1155, 2683, 5216, 10544, 26867, 51510, 95823, 198669, 357535, 863317, 1811764, 3007503, 5598802, 14428676, 33185509, 54538862, 111949941, 227634408, 400708894, 1033162084, 2102388551, 3093472814, 7137437912, 14133072157, 20112871792, 42387769980, 100251560595, 146971536592, 323724968937, 1003651412950, 1458252205147, 2895374552463, 7409811047825, 15404761757071, 19996463086597, 51408670348612, 119666659114170, 191206974700443, 409118905032525, 611140496167764, 2058769515153876, 4216495639600700, 6763683971478124, 9974455244496707, 30045390491869460, 44218742292676575, 138245758910846492, 199976667976342049, 525070384258266191, 1135041350219496382, 1425787542618654982, 3908372542507822062, 8993229949524469768, 17799667357578236628, 30568377312064202855]
hex_colors = ["#" + ("%06X" % integer_value) for integer_value in int_list]
display_color_info(hex_colors)
What do we observe here? All colors are unknown. If a color is known, skip these 3 bytes, if a color is unknown, take these 3 bytes and process them on the GPU for an additional 6 bytes within the range of 200000:3fffff.