How would one create a deterministic Javascript HTML colour picker which given arguments of how many colours are desired returns an array of HTML hex colour codes, ie:
function createColours(numColours) {
return [/* colours array of size numColours */]
}
The colours themselves can be chosen / generated randomly, but the method must guarantee that colours chosen are always the same between calls and always in the same order in series.
For example, if the series of colours decided on by the function started with the following 8:
"#47092E", "#CC2A43", "#00C66B", "#BC1300", "#667E00", "#795800", "#FFD245", "#6EFFAD", etc, etc
The function would behave with the following consistent responses across separate method invocations on the client
["#47092E", "#CC2A43"] == createColours(2);
["#47092E", "#CC2A43", "#00C66B", "#BC1300", "#667E00"] == createColours(5);
["#47092E"] == createColours(1);
["#47092E", "#CC2A43", "#00C66B", "#BC1300", "#667E00", "#795800", "#FFD245", "#6EFFAD", #and 49 others#] == createColours(57);
Note: The colours are not defined as a variable in advance; the method might be asked for 345 colours, all of which it would be required to generate by whatever suitable means.
The problem to be solved is - first and foremost - how would you create a capability within the method to generate the n HEX colour values consistently the same each time also preserving the sequence