// Ключевые точки градиента
const red = [255, 30, 30];
const yellow = [255, 215, 74];
const green = [60, 255, 95];
const blue = [85, 145, 255];
function to_rgb(color) {
return `rgb(${color[0]}, ${color[1]}, ${color[2]})`;
}
function blend_colors(color1, color2, percentage) {
let color = [];
for (let i = 0; i < 3; i++) {
color[i] = (1 - percentage) * color1[i] + percentage * color2[i];
}
return to_rgb(color);
}
let bgColor;
if (!value) {
bgColor = "grey";
} else if (value >= 10) {
bgColor = to_rgb(blue);
} else if (value >= 8) {
bgColor = blend_colors(green, blue, (value - 8) / 2);
} else if (value >= 6) {
bgColor = blend_colors(yellow, green, (value - 6) / 2);
} else if (value >= 4) {
bgColor = blend_colors(red, yellow, (value - 4) / 2);
} else {
bgColor = to_rgb(red);
}
const [input, setInput] = useState("");
const [expression, setExpression] = useState("");
const updateInput = e => {
setInput(e.target.value);
try {
new RegExp(e.target.value, "g");
setExpression(e.target.value);
} catch (e) {
setExpression(".^");
}
};
return (
<input onChange={updateInput} />
<ControlString template={expression} />
);
public static int LastDigit(int[] array) {
if (array.Length == 0) return 1;
array[0] %= 10;
if (array.Length == 1 || array[0] == 1) return array[0];
for (int i = 1; i < array.Length && i < 4; i++) {
if (array[i] == 0) {
int j = 0;
while(i + j + 1 < array.Length && array[i + j + 1] == 0) { j++; }
Array.Resize(ref array, i);
if (j % 2 == 0) { array[i - 1] = 1; }
if (i == 1) return array[0];
break;
}
}
if (array[0] == 0 || array[0] == 5 || array[0] == 6) return array[0];
if (array[0] == 4) { return (array[1] % 2 == 0) ? 6 : 4; }
if (array[0] == 9) { return (array[1] % 2 == 0) ? 1 : 9; }
if (array.Length > 2) array[1] = (int)BigInteger.ModPow(array[1], array[2], 100);
if (array[1] == 0) array[1] = 4;
return (int)BigInteger.ModPow(array[0], array[1], 10);
}