using System;
using System.Collections.Generic;
class UniqueHexColors
{
// Convert an integer (0–255) to a two-digit HEX string.
static string ToHex(int value)
{
return value.ToString("X2").ToLower();
}
// Generate N unique random HEX colors.
static string[] GenerateRandomUniqueHexColors(int count)
{
var seen = new HashSet<string>();
var colors = new string[count];
var rnd = new Random();
int generated = 0;
while (generated < count)
{
int r = rnd.Next(256);
int g = rnd.Next(256);
int b = rnd.Next(256);
string hex = "#" + ToHex(r) + ToHex(g) + ToHex(b);
if (seen.Add(hex)) {
colors[generated] = hex;
generated++;
}
}
return colors;
}
static void Main()
{
int n = 12;
var colors = GenerateRandomUniqueHexColors(n);
Console.WriteLine("Generated HEX colors:");
foreach (var c in colors)
{
Console.WriteLine(c);
}
}
}
/*
run:
Generated HEX colors:
#794077
#991cad
#2d48ef
#73fc9e
#22f7ec
#804d11
#fed5d0
#0f611e
#75bb83
#49641b
#fa6527
#ed1cd0
*/