Skip to content

Instantly share code, notes, and snippets.

@blacksheep557
Created August 12, 2021 05:18
Show Gist options
  • Select an option

  • Save blacksheep557/09e5f30258139a7a93771f92b9ba2885 to your computer and use it in GitHub Desktop.

Select an option

Save blacksheep557/09e5f30258139a7a93771f92b9ba2885 to your computer and use it in GitHub Desktop.
function getColors(code) {
const array = code.split('')
const [r,g,b] = [[array[1],array[2]],[array[3],array[4]],[array[5],array[6]]]
return {
red: parseInt(r.join(''), 16),
green: parseInt(g.join(''), 16),
blue: parseInt(b.join(''), 16),
}
}
console.log(getColors("#FF9933"));
function generateString(matrix, string) {
let iter = 0;
const len = matrix.length;
for (const char of string) {
const index = matrix[iter].indexOf(char);
if (index === -1) return false;
else {
matrix[iter].splice(index, 1);
}
iter++;
if (iter > len - 1) iter = 0;
}
return true;
}
console.log(generateString( [["a", "b", "a"],
["x", "y", "z"],
["b", "d", "r"]],"axbaydb"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment