Данный отчёт сгенерирован 10.02.2023 18:21:31 UTC.
HTML версия (этот сайт) сгенерирован 10.02.2023 18:21:38 UTC.
Коммит: [bfeb65b9] add automatic zip creation 10.02.2023 18:21:31
HTML версия (этот сайт) сгенерирован 10.02.2023 18:21:38 UTC.
Коммит: [bfeb65b9] add automatic zip creation 10.02.2023 18:21:31
Задача: Чорно-червоний
10.02.2023 18:21:31
Описание: Визначити функцію transform, яка отримує назву складеного кольору,
наприклад, "червоно-чорний" і повертає той самий колір, але в іншій формі,
а саме, "чорно-червоний". Ще приклад, transform("синьо-зелений") -> "зелено-синій".
10.02.2023 18:21:31
Решений: 65
10.02.2023 18:21:31
Чорно-червоний
10.02.2023 18:21:31
function transform(color) {
const colorTails = new Map([
['зелено', 'зелений'],
['червоно', 'червоний'],
['чорно', 'чорний'],
['біло', 'білий'],
['синьо', 'синій'],
['фіолетово', 'фіолетовий'],
['жовто', 'жовтий'],
['помаранчево', 'помаранчевий'],
['блакитно', 'блактиний'],
['сіро', 'сірий'],
['коричнево', 'коричневий'],
['рожево', 'рожевий'],
['зелений','зелено'],
['червоний','червоно'],
['чорний','чорно'],
['білий','біло'],
['синій','синьо'],
['фіолетовий','фіолетово'],
['жовтий','жовто'],
['помаранчевий','помаранчево'],
['блактиний', 'блакитно'],
['сірий','сіро'],
['коричневий','коричнево'],
['рожевий','рожево'],
]);
let array = color.split('-').reverse();
let color1 = array[0].toString();
array[0] = colorTails.get(color1);
let color2 = array[1].toString();
array[1] = colorTails.get(color2);
return array.toString().replace(',', '-');
}
function transform(color) {
let a = color.split('').slice(0, color.indexOf('-')), l1 = a.length;
let b = color.split('').slice(color.indexOf('-') + 1), l2 = b.length;
if(a[l1 - 2] == 'ь') {
a.splice(l1 - 2, 2);
a.push('ій');
} else {
a.splice(l1 - 1, 1);
a.push('ий');
}
if(b[l2 - 2] == 'і') {
b.splice(l2 - 2, 2);
b.push('ьо');
} else {
b.splice(l2 - 2, 2);
b.push('о');
}
return b.join('') + '-' + a.join('');
}
function transform(color){
let splittedColor = color.toString().split('-')
let splitted1Color = splittedColor[0].split('')
let splitted2Color = splittedColor[1].split('')
if (splitted1Color[splitted1Color.length-2] == 'ь'){
splitted1Color.splice(splitted1Color.length-2,1,'ій')
splitted1Color.pop()
}
else{
splitted1Color.pop()
splitted1Color.push('ий')
}
if (splitted2Color[splitted2Color.length-2] == 'і'){
splitted2Color.splice(splitted2Color.length-2,1,'ь')
splitted2Color.splice(splitted2Color.length-1,1,'о')
}
else{
splitted2Color.pop()
splitted2Color.pop()
splitted2Color.push('о')
}
return `${splitted2Color.join('')}-${splitted1Color.join('')}`
}
function transform(color){
let Color1 = color.toString().split('-')
let FirstColor = Color1[0].split('')
let SecondColor = Color1[1].split('')
if (FirstColor[FirstColor.length-2] == 'ь'){
FirstColor.splice(FirstColor.length-2,1,'ій')
FirstColor.pop()
}
else{
FirstColor.pop()
FirstColor.push('ий')
}
if (SecondColor[SecondColor.length-2] == 'і'){
SecondColor.splice(SecondColor.length-2,1,'ь')
SecondColor.splice(SecondColor.length-1,1,'о')
}
else{
SecondColor.pop()
SecondColor.pop()
SecondColor.push('о')
}
return `${SecondColor.join('')}-${FirstColor.join('')}`
}
function transform(color){
color = color.split('-').reverse()
if(color[0].indexOf('і',color[0].length-2)==-1){
color[0] = color[0].split('')
color[0].pop()
color[0].pop()
color[0].push('о')
color[0] = color[0].join('')
}
else{
color[0] = color[0].split('')
color[0].pop()
color[0].pop()
color[0].push('ь')
color[0].push('о')
color[0] = color[0].join('')
}
if(color[1].indexOf('ь',color[1].length-2)!=-1){
color[1] = color[1].split('')
color[1].pop()
color[1].pop()
color[1].push('і')
color[1].push('й')
color[1]=color[1].join('')
}
else{
color[1] = color[1].split('')
color[1].pop()
color[1].push('и')
color[1].push('й')
color[1] = color[1].join('')
}
return color.join('-')
}
function transform(s) {
let arr = s.split('-');
let c1 = arr[0]
let c2 = arr[1]
if (c1.includes('ьо')) arr[0] = c1.slice(0,-2) + 'ій';
else arr[0] = c1.slice(0,-1) + 'ий';
if (c2.includes('ій')) arr[1] = c2.slice(0,-2) + 'ьо';
else arr[1] = c2.slice(0,-2) + 'о';
return arr.reverse().join('-')
}
function transform(shade) {
let colors = shade.split('-');
let transformed = '';
let a = colors[0];
let b = colors[1];
let eA = a.substr(a.length - 2, 2);
let eB = b.substr(b.length - 2, 2);
transformed += b.substring(0, b.length - 2) + (eB === 'ий' ? 'о' : 'ьо');
transformed += '-' + a.substring(0, a.length - (eA === 'ьо' ? 2 : 1)) + (eA === 'ьо' ? 'ій' : 'ий');
return transformed;
}
function transform(color) {
dash = color.indexOf('-')
len = color.length
new_color = ''
if (color.slice(len-2) == 'ій')
new_color += color.slice(dash+1, len-2) + 'ьо-'
if (color.slice(len-2) == 'ий')
new_color += color.slice(dash+1, len-2) + 'о-'
if (color.slice(dash-2, dash) == 'ьо')
new_color += color.slice(0, dash-2) + 'ій'
else
new_color += color.slice(0, dash-1) + 'ий'
return new_color
}
function transform(color){
let splitted = color.split('-')
let [firstCol, secondCol] = splitted;
[secondCol, firstCol] = [firstCol.slice(0,-1) + "ий", secondCol.slice(0,-2) + "о"]
if(firstCol == 'сино') firstCol = 'синьо'
if(secondCol == 'синьий') secondCol = 'синій'
return firstCol + '-' + secondCol;
}
function transform(shade) {
let colors = shade.split('-');
let transf = '';
let a = colors[0];
let b = colors[1];
let eA = a.substr(a.length - 2, 2);
let eB = b.substr(b.length - 2, 2);
transf += b.substring(0, b.length - 2) + (eB == 'ий' ? 'о' : 'ьо');
transf += '-' + a.substring(0, a.length - (eA == 'ьо' ? 2 : 1)) + (eA == 'ьо' ? 'ій' : 'ий');
return transf;
}
function transform(str) {
str = str.split('-');
if (str[0].slice(str[0].length-2)=='ьо')
{
str[0]=str[0].replace('ьо', 'ій');
}
if (str[0].slice(str[0].length-2)=='но')
{
str[0]=str[0].replace('но', 'ний');
}
if (str[0].slice(str[0].length-2)=='то')
{
str[0]=str[0].replace('то', 'тий');
}
if (str[0].slice(str[0].length-2)=='во')
{
str[0]=str[0].replace('во', 'вий');
}
if (str[1].slice(str[1].length-2)=='ий')
{
str[1]=str[1].replace('ий', 'о');
}
if (str[1].slice(str[1].length-2)=='ій')
{
str[1]=str[1].replace('ій', 'ьо');
}
return str.reverse().join('-');
}
function transform(s) {
let result = "";
let divider_ind = s.indexOf('-');
let ending_1 = s.substring(divider_ind - 2, divider_ind);
let ending_2 = s.substring(s.length - 2, s.length);
let first_phrase = s.substring(0, divider_ind - 1);
let second_phrase = s.substring(divider_ind + 1, s.length - 2);
if (ending_1 == "ьо") f_ending_2 = "ій";
else f_ending_2 = "ий";
if (ending_2 == "ій") f_ending_1 = "ьо";
else f_ending_1 = "о";
if (first_phrase[first_phrase.length - 1] == "ь") first_phrase = s.substring(0, first_phrase.length - 1);
return result.concat(second_phrase, f_ending_1, "-", first_phrase, f_ending_2);
}
function transform(a) {
let ma = a.split('-');
s1 = ma[0]
s2 = ma[1]
if (ma[0][ma[0].length - 2] + ma[0][ma[0].length - 1] == "ьо") {
ma[0] = ma[0].slice(0, -2)
ma[0] += "ій"
}
else
if (ma[0][ma[0].length - 1] == "о") {
ma[0] = ma[0].slice(0, -1)
ma[0] += "ий"
}
if (ma[1][ma[1].length - 2] + ma[1][ma[1].length - 1] == "ій")
ma[1] = ma[1].slice(0, -2) + "ьо"
else ma[1] = ma[1].slice(0, -2) + "о"
result = ma[1] + "-" + ma[0]
return result
}
function transform(color) {
let a = color.split('-');
if((a[1].slice(-2))=="ій"){
a[1]= a[1].slice(0, -2)+"ьо"
}else{
a[1]= a[1].slice(0, -2)+"о"
}
if((a[0].slice(-2))=="ьо"){
a[0]= a[0].slice(0, -2)+"ій"
}else{
a[0]= a[0].slice(0, -1)+"ий"
}
return a[1]+'-'+a[0];
}
console.log(transform("зелено-синій") );
console.log(transform("синьо-зелений") );
function transform(s) {
let mas = s.split('-');
if (mas[0][mas[0].length-2]=='ь'){
mas[0]=mas[0].slice(0, mas[0].length-2)+'ій';
}
else mas[0]=mas[0].slice(0, mas[0].length-1)+'ий';
if (mas[1][mas[1].length-2]=='и'){
mas[1]=mas[1].slice(0, mas[1].length-2)+'о';
}
if (mas[1][mas[1].length-2]=='і'){
mas[1]=mas[1].slice(0, mas[1].length-2)+'ьо';
}
return (mas[1] + '-' + mas[0]);
}
function transform(color) {
let arr = color.split("-");
if(arr[0].slice(-2) == "ьо") {
arr[0] = arr[0].slice(0, -2) + "ій";
}
else {
arr[0] = arr[0].slice(0, -1) + "ий";
}
if(arr[1].slice(-2) == "ій") {
arr[1] = arr[1].slice(0, -2) + "ьо"
}
else {
arr[1] = arr[1].slice(0, -2) + "о"
}
return arr.reverse().join("-");
}
function transform(a) {
let ma = a.split('-');
s1 = ma[0]
s2 = ma[1]
if (ma[0][ma[0].length - 2] + ma[0][ma[0].length - 1] == "ьо") {
ma[0] = ma[0].slice(0, -2)
ma[0] += "ій"
}
else
if (ma[0][ma[0].length - 1] == "о") {
ma[0] = ma[0].slice(0, -1)
ma[0] += "ий"
}
if (ma[1][ma[1].length - 2] + ma[1][ma[1].length - 1] == "ій")
ma[1] = ma[1].slice(0, -2) + "ьо"
else ma[1] = ma[1].slice(0, -2) + "о"
result = ma[1] + "-" + ma[0]
return result
}
function transform(s) {
let start='', end='';
if (s.slice(0,s.indexOf('-')-2) == 'син') start = s.slice(0,s.indexOf('-')-2);
else start = s.slice(0,s.indexOf('-')-1);
end = s.slice(s.indexOf('-')+1,-2);
if (start != 'син') start += 'ий';
else start += 'ій';
if (end != 'син') end += 'о';
else end += 'ьо';
return end+"-"+start;
}
function transform(s) {
s=s.split('-');
s.reverse();
//first word
if(s[0].slice(-2, -1)=='і'){
s[0]=s[0].slice(0, -2);
s[0]+="ьо";
}
else{
s[0]=s[0].slice(0, -2);
s[0]+="о";
}
//second word
if(s[1][s[1].length-2]=="ь"){
s[1]=s[1].slice(0, -2);
s[1]+="і";
s[1]+="й";
}
else{
s[1]=s[1].slice(0, -1);
s[1]+="и";
s[1]+="й";
}
s=s.join('-');
return s;
}
function transform(color) {
let [w1, w2] = color.split('-');
if (w1.substring(w1.length-2) == 'ьо') {
w1 = w1.replace(/..$/,'ій');
}
else if (w1.substring(w1.length-1) == 'о'){
w1 = w1.replace(/.$/,'ий');
}
if (w2.substring(w2.length-2) == 'ий') {
w2 = w2.replace(/..$/,'о')
}
else if (w2.substring(w2.length-2) == 'ій') {
w2 = w2.replace(/..$/,'ьо')
}
return w2 + '-' + w1;
}
function transform(s) {
let half1 = s.split('').slice(0, s.indexOf('-'));
let half2 = s.split('').slice(s.indexOf('-') + 1);
if(half1[half1.length - 2] == 'ь'){
half1.splice(half1.length - 2, 2);
half1.push('ій');
}else{
half1.splice(half1.length - 1, 1);
half1.push('ий');
}
if(half2[half2.length - 2] == 'і'){
half2.splice(half2.length - 2, 2);
half2.push('ьо');
}else{
half2.splice(half2.length - 2, 2);
half2.push('о');
}
return half2.join('') + '-' + half1.join('');
}
function transform(s) {
arr = s.split("-")
zak1 = arr[0].slice(arr[0].length - 2, arr[0].length)
zak2 = arr[1].slice(arr[1].length - 2, arr[1].length)
arr[0]=arr[0].split("")
arr[1]=arr[1].split("")
if (zak1 == "ьо")
{
arr[0][arr[0].length-2]="і"
arr[0][arr[0].length-1]="й"
}
else if (zak1[1] == "о")
{
arr[0][arr[0].length-1]="и"
arr[0][arr[0].length]="й"
}
if (zak2 == "ий")
{
arr[1][arr[1].length-2]="о"
arr[1].pop()
}
else if (zak2 == "ій")
{
arr[1][arr[1].length-2]="ь"
arr[1][arr[1].length-1]="о"
}
let str = arr[1].join("")+"-"+arr[0].join("")
return str
}
function transform(shade) {
let colors = shade.split('-');
let transformed = '';
let a = colors[0];
let b = colors[1];
let eA = a.substr(a.length - 2, 2);
let eB = b.substr(b.length - 2, 2);
transformed += b.substring(0, b.length - 2) + (eB === 'ий' ? 'о' : 'ьо');
transformed += '-' + a.substring(0, a.length - (eA === 'ьо' ? 2 : 1)) + (eA === 'ьо' ? 'ій' : 'ий');
return transformed;
}
function transform (color) {
let string1 = color.split('-')[0]
let string2 = color.split('-')[1]
if (string1.slice(string1.length - 2) == 'ьо')
string1 = string1.slice(0, string1.length - 2) + 'ій'
else if (string1.slice(string1.length - 1) == 'о')
string1 = string1.slice(0, string1.length - 1) + 'ий'
if (string2.slice(string2.length - 2) == 'ій')
string2 = string2.slice(0, string2.length - 2) + 'ьо'
else if (string2.slice(string2.length - 2) == 'ий')
string2 = string2.slice(0, string2.length - 2) + 'о'
return string2 + '-' + string1
}
function transform(color){
let splitted = color.split('-')
let [firstCol, secondCol] = splitted;
[secondCol, firstCol] = [firstCol.slice(0,-1) + "ий", secondCol.slice(0,-2) + "о"]
if(firstCol == 'сино') firstCol = 'синьо'
if(secondCol == 'синьий') secondCol = 'синій'
return firstCol + '-' + secondCol;
}
function transform(str){
let arr = str.split("-");
if(arr[0].slice(-2) == "ьо")
arr[0] = arr[0].slice(0, -2) + "ій";
else
arr[0] = arr[0].slice(0, -1) + "ий";
if(arr[1].slice(-2) == "ій")
arr[1] = arr[1].slice(0, -2) + "ьо"
else
arr[1] = arr[1].slice(0, -2) + "о"
return arr.reverse().join("-")
}
function transform(color){
let colors = color.split('-');
let transformed = '';
let a = colors[0];
let b = colors[1];
let aA = a.substr(a.length - 2, 2);
let bB = b.substr(b.length - 2, 2);
transformed += b.substring(0, b.length - 2) + (bB === 'ий' ? 'о' : 'ьо');
transformed += '-' + a.substring(0, a.length - (aA === 'ьо' ? 2 : 1)) + (aA === 'ьо' ? 'ій' : 'ий');
return transformed;
}
function transform(shade) {
let colors = shade.split('-');
let transformed = '';
let a = colors[0];
let b = colors[1];
let eA = a.substr(a.length - 2, 2);
let eB = b.substr(b.length - 2, 2);
transformed += b.substring(0, b.length - 2) + (eB === 'ий' ? 'о' : 'ьо');
transformed += '-' + a.substring(0, a.length - (eA === 'ьо' ? 2 : 1)) + (eA === 'ьо' ? 'ій' : 'ий');
return transformed;
}
function transform(str){
let arr = str.split("-");
if(arr[0].slice(-2) == "ьо")
arr[0] = arr[0].slice(0, -2) + "ій";
else
arr[0] = arr[0].slice(0, -1) + "ий";
if(arr[1].slice(-2) == "ій")
arr[1] = arr[1].slice(0, -2) + "ьо"
else
arr[1] = arr[1].slice(0, -2) + "о"
return arr.reverse().join("-")
}
function transform(color) {
let arr = color.split('-');
let d=arr[0]
let k0 = '';
let r0 = d[d.length-2] + d[d.length-1];
for(let i = 0; i < d.length; i++){
if(r0 == 'ьо'){
if(i == d.length - 2){
k0+= 'ій';
break;
} else
k0+=d[i];
} else {
if(i == d.length - 1){
k0+= 'ий';
break;
} else
k0+=d[i];
}
}
let t=arr[1]
let k1 = '';
let r1 = t[t.length-2] + t[t.length-1];
for(let i = 0; i < t.length; i++){
if(r1 == 'ій') {
if(i == t.length - 2) {
k1+= 'ьо';
break
} else
k1+=t[i];
} else{
if(i == t.length - 2) {
k1+= 'о';
break
} else
k1+=t[i];
} }
return k1 + '-' + k0;
}
function transform(color) {
let arr = color.split('-');
if((arr[1].slice(-2))=="ій"){
arr[1]= arr[1].slice(0, -2)+"ьо"
}else{
arr[1]= arr[1].slice(0, -2)+"о"
}
if((arr[0].slice(-2))=="ьо"){
arr[0]= arr[0].slice(0, -2)+"ій"
}else{
arr[0]= arr[0].slice(0, -1)+"ий"
}
return arr[1]+'-'+arr[0];
}
function transform(color){
let splittedColor = color.toString().split('-')
let splittedFirstColor = splittedColor[0].split('')
let splittedSecondColor = splittedColor[1].split('')
if (splittedFirstColor[splittedFirstColor.length-2] == 'ь'){
splittedFirstColor.splice(splittedFirstColor.length-2,1,'ій')
splittedFirstColor.pop()
}
else{
splittedFirstColor.pop()
splittedFirstColor.push('ий')
}
if (splittedSecondColor[splittedSecondColor.length-2] == 'і'){
splittedSecondColor.splice(splittedSecondColor.length-2,1,'ь')
splittedSecondColor.splice(splittedSecondColor.length-1,1,'о')
}
else{
splittedSecondColor.pop()
splittedSecondColor.pop()
splittedSecondColor.push('о')
}
return `${splittedSecondColor.join('')}-${splittedFirstColor.join('')}`
}
function transform(color){
let half1=color.split('-')[0]
let half2=color.split('-')[1]
let root1=half1.includes('син')?half1.slice(0,half1.length-2):half1.slice(0,half1.length-1)
let root2=half2.slice(0,half2.length-2)
let s=`${root2}${root2=='син'?"ьо":"о"}-${root1}${root1=='син'?"ій":"ий"}`
return s
}
function transform(color){
let array = color.split("-").reverse();
if (array[0].slice(array[0].length - 2, array[0].length) == "ий"){
array[0] = array[0].slice(0, array[0].length - 2)
array[0] += "о";
}
else{
array[0] = array[0].slice(0, array[0].length - 2)
array[0] += "ьо";
}
if (array[1].slice(array[1].length - 2, array[1].length) == "ьо"){
array[1] = array[1].slice(0, array[1].length - 2)
array[1] += "ій";
}
else{
array[1] = array[1].slice(0, array[1].length - 1)
array[1] += "ий";
}
color = array.join("-");
return color;
}
function transform(color){
color =color.split("-");
const arr_of_colors_1 = ["червоно","синьо","біло","чорно","жовто","помаранчево",
"рожево","фіолетово","блакитно","сіро","зелено","коричнево","красно","сине",
"бело","чёрно","жёлто","оранжево","розово","фиолетово","голубо","серо",
"зелёно"]
const arr_of_colors_2 = ["червоний","синій","білий","чорний","жовтий","помаранчевий",
"рожевий","фіолетовий","блакитний","сірий","зелений","коричневий","красный","синий",
"белый","чёрный","жёлтый","оранжевый","розовый","фиолетовый","голубой","серый",
"зелёный"]
let index_1 = arr_of_colors_1.indexOf(color[0])
let index_2 = arr_of_colors_2.indexOf(color[1])
if(index_1!=-1){
color[0] = arr_of_colors_2[index_1]
}
if(index_2!=-1){
color[1]= arr_of_colors_1[index_2]
}
let semi_color = color[0];
color[0] = color[1]
color[1] = semi_color
console.log(color)
color =color.join("-")
return color
}
function transform(shade) {
let colors = shade.split('-');
let transformed = '';
let a = colors[0];
let b = colors[1];
let eA = a.substr(a.length - 2, 2);
let eB = b.substr(b.length - 2, 2);
transformed += b.substring(0, b.length - 2) + (eB === 'ий' ? 'о' : 'ьо');
transformed += '-' + a.substring(0, a.length - (eA === 'ьо' ? 2 : 1)) + (eA === 'ьо' ? 'ій' : 'ий');
return transformed;
}
function transform(color)
{
let Color1_2 = color.toString().split('-')
let FirstColor = Color1_2[0].split('')
let SecondColor = Color1_2[1].split('')
let result;
if (FirstColor[FirstColor.length-2] == 'ь')
{
FirstColor.splice(FirstColor.length-2,1,'ій')
FirstColor.pop()
}
else
{
FirstColor.pop()
FirstColor.push('ий')
}
if (SecondColor[SecondColor.length-2] == 'і')
{
SecondColor.splice(SecondColor.length-2,1,'ь')
SecondColor.splice(SecondColor.length-1,1,'о')
}
else
{
SecondColor.pop()
SecondColor.pop()
SecondColor.push('о')
}
result = `${SecondColor.join('')}-${FirstColor.join('')}`;
return result;
}
function transform(color)
{
let colors = color.split('-')
let c1 = colors[0]
let c2 = colors[1]
if(c1.endsWith('но'))
{
c1 = c1.replace('но', 'ний')
}
else if(c1.endsWith('ньо'))
{
c1 = c1.replace('ньо', 'ній')
}
else if(c1.endsWith('то'))
{
c1 = c1.replace('то', 'тий')
}
else
{
c1 = c1.replace('о', 'ий')
}
if(c2.endsWith('ний'))
{
c2 = c2.replace('ний', 'но')
}
else if(c2.endsWith('ній'))
{
c2 = c2.replace('ній', 'ньо')
}
else if(c2.endsWith('тий'))
{
c2 = c2.replace('тий', 'то')
}
else
{
c2 = c2.replace('ий', 'о')
}
return c2 + '-' + c1
}
function transform(shade) {
let colors = shade.split('-');
let transformed = '';
let a = colors[0];
let b = colors[1];
let eA = a.substr(a.length - 2, 2);
let eB = b.substr(b.length - 2, 2);
transformed += b.substring(0, b.length - 2) + (eB === 'ий' ? 'о' : 'ьо');
transformed += '-' + a.substring(0, a.length - (eA === 'ьо' ? 2 : 1)) + (eA === 'ьо' ? 'ій' : 'ий');
return transformed;
}
function transform(s) {
let mas = s.split('-');
mas.reverse()
let result = []
let word = mas[0].split('')
let re1;
if (word[word.length -2] == 'і'){
word.pop()
word.pop()
word.push('ьо')
}
else{
word.pop()
word.pop()
word.push('о')
}
re1 = word.join('')
let word1 = mas[1].split('')
let re2;
if(word1[word1.length - 2] == 'ь'){
word1.pop()
word1.pop()
word1.push('ій')
re2 = word1.join('')
}
else
{
word1.pop()
word1.push('ий')
re2 = word1.join('')
}
result.unshift(re2)
result.unshift(re1)
return result.join('-')
}
function transform(s) {
let mas = s.split('-');
mas.reverse()
let result = []
let word = mas[0].split('')
let re1;
if (word[word.length -2] == 'і'){
word.pop()
word.pop()
word.push('ьо')
}
else{
word.pop()
word.pop()
word.push('о')
}
re1 = word.join('')
let word1 = mas[1].split('')
let re2;
if(word1[word1.length - 2] == 'ь'){
word1.pop()
word1.pop()
word1.push('ій')
re2 = word1.join('')
}
else
{
word1.pop()
word1.push('ий')
re2 = word1.join('')
}
result.unshift(re2)
result.unshift(re1)
return result.join('-')
}
function transform(shade) {
let colors = shade.split('-');
let transformed = '';
let a = colors[0];
let b = colors[1];
let eA = a.substr(a.length - 2, 2);
let eB = b.substr(b.length - 2, 2);
transformed += b.substring(0, b.length - 2) + (eB === 'ий' ? 'о' : 'ьо');
transformed += '-' + a.substring(0, a.length - (eA === 'ьо' ? 2 : 1)) + (eA === 'ьо' ? 'ій' : 'ий');
return transformed;
}
function transform(s) {
let arrH = s.split('-');
let h1 = arrH[0].split('');
let h2 = arrH[1].split('');
let end1 = h1.slice(h1.length-2);
let end2 = h2.slice(h2.length-2);
if(end2[0] == 'ы'){
if(end1[1] == 'е'){
end2 = ['и','й']
end1[1] = 'о';
end1[0] = '';
}else {
end1[0] = '';
}
}else {
if(arrH[1] != 'синий'){
if(end2[0] == 'і'){
end1 = ['ь', 'о'];
end2 = ['и', 'й'];
}else if(end1[0] == 'ь'){
h1.pop();
end2 = ['і', 'й'];
end1[0] = '';
}else {
end1[0] = '';
}
}else {
end1 = ['', 'е'];
end2 = ['ы', 'й'];
}
}
h1 = h1.slice(0, h1.length-1);
h2 = h2.slice(0, h2.length-2);
return h2.join('')+end1.join('')+'-'+h1.join('')+ end2.join('');
}
function transform(shade) {
let colors = shade.split('-');
let transformed = '';
let a = colors[0];
let b = colors[1];
let eA = a.substr(a.length - 2, 2);
let eB = b.substr(b.length - 2, 2);
transformed += b.substring(0, b.length - 2) + (eB === 'ий' ? 'о' : 'ьо');
transformed += '-' + a.substring(0, a.length - (eA === 'ьо' ? 2 : 1)) + (eA === 'ьо' ? 'ій' : 'ий');
return transformed;
}
function transform(s) {
let arr = s.split('-')
let first = arr[0]
let first1 = first.split('')
let second = arr[arr.length-1]
let second1 = second.split('')
if (first1[first1.length-2] == 'ь'){
first1.splice(first1.length-2, 2, 'і', 'й')
}
if (first1[first1.length-1] == 'о'){
first1.splice(first1.length-1, 1, 'и', 'й')
}
if (second1[second1.length-2] == 'и'){
second1.splice(second1.length-2, 2, 'о')
}
if (second1[second1.length-2] == 'і'){
second1.splice(second1.length-2, 2, 'ь', 'о')
}
let string1 = second1.join('')
let string2 = first1.join('')
return string1 + '-' + string2
}
function transform(str) {
let a = str.split('-').reverse(),
f = a[0].split(''),
s = a[1].split(''),
ff;
if (f[f.length-2] == 'і')
ff = 'ьо';
else ff = 'о'
f.splice(f.length - 2, 2, ff)
a [0] = f.join('');
if (s[s.length-2] == 'ь')
s.splice(s.length - 2, 2, 'ій');
else s.splice(s.length - 1, 1, 'ий')
a [1] = s.join('');
return a.join('-');
}
function transform(color) {
let word1 = color.split('').slice(0, color.indexOf('-')), l1 = word1.length;
let word2 = color.split('').slice(color.indexOf('-') + 1), l2 = word2.length;
if(word1[l1 - 2] == 'ь') {
word1.splice(l1 - 2, 2);
word1.push('ій');
} else {
word1.splice(l1 - 1, 1);
word1.push('ий');
}
if(word2[l2 - 2] == 'і') {
word2.splice(l2 - 2, 2);
word2.push('ьо');
} else {
word2.splice(l2 - 2, 2);
word2.push('о');
}
return word2.join('') + '-' + word1.join('');
}
function transform(color){
endings = ["ий", "о"]
colors = color.split("-")
if(colors[0] == "синьо"){
return colors[1].slice(0, -2) + endings[1] + "-" + "синій"
}
if(colors[1] == "синій"){
return "синьо" + "-" +colors[0].slice(0, -1) + endings[0]
}
else{
return colors[1].slice(0, -2) + endings[1] + "-" + colors[0].slice(0, -1) + endings[0]
}
}
function transform(color){
let colors = color.split("-");
let color1 = colors[1];
let color2 = colors[0];
if(color1.endsWith("ній")) {
color1 = color1.replace("ній", "ньо");
} else
if(color1.endsWith("ний")) {
color1 = color1.replace("ний", "но");
}else
if(color1.endsWith("тий")) {
color1 = color1.replace("тий", "то");
}else{
color1 = color1.replace("ий", "о");
}
if(color2.endsWith("ньо")) {
color2 = color2.replace("ньо", "ній");
}else
if(color2.endsWith("но")) {
color2 = color2.replace("но", "ний");
}else
if(color2.endsWith("то")) {
color2 = color2.replace("то", "тий");
}else {
color2 = color2.replace("о", "ий");
}
return color1 + "-" + color2;
}
function transform(s) {
let words = s.split('-').reverse()
if (words[0] === "синій")
words[0] = words[0].slice(0, -2) + "ьо"
else words[0] = words[0].slice(0, -2) + "о"
if (words[1] === "синьо")
words[1] = words[1].slice(0, -2) + "ій"
else words[1] = words[1].slice(0, -1) + "ий"
return words.join('-')
}
function transform(color)
{
color=color.split('-').reverse()
if(color.indexOf('синій')!=-1)
{
color[0]=color[0].slice(0,-2).concat('ьо');
color[1]=color[1].slice(0,-1).concat('ий');
color=color.join('-');
return color}
if(color.indexOf('синьо')!=-1)
{
color[0]=color[0].slice(0,-2).concat('о');
color[1]=color[1].slice(0,-2).concat('ій');
color=color.join('-');
return color}
color[0]=color[0].slice(0,-2).concat('о');
color[1]=color[1].slice(0,-1).concat('ий');
color=color.join('-');
return color
}
function transform(color) {
let arr=color.split('-');
let a1=arr[0];
let a2=arr[1];
if (a1.slice(-2) == 'ьо') {
a1=a1.split('');
a1.splice(-2,2,'ій');
}
else {
a1=a1.split('');
a1.splice(-1,1,'ий');
}
if (a2.slice(-2) == 'ий') {
a2=a2.split('');
a2.splice(-2,2,'о');
}
else {
a2=a2.split('');
a2.splice(-2,2,'ьо');
}
let m=[];
arr=m.concat(a2,'-',a1);
return arr.join('');
}
function transform(s) {
const colorNames1 = ['червоно', 'рожево', 'помаранчево', 'жовто', 'зелено', 'блакитно', 'синьо', 'бузково', 'фіолетово', 'чорно', 'біло', 'сіро', 'коричнево',
'красно', 'оранжево', 'желто', 'зелёно', 'голубо', 'сине', 'фиолетово', 'бело', 'черно', 'чёрно'];
const colorNames2 = [
'червоний', 'рожевий', 'помаранчевий', 'жовтий', 'зелений', 'блакитний', 'синій', 'бузковий', 'фіолетовий', 'чорний', 'білий', 'сірий', 'коричневий',
'красный', "оранжевый", "желтый", "зелёный", "голубой" ,'синий', 'фиолетовый', 'белый', "черный", "чёрный"
];
let words = s.toLowerCase().split("-");
let color1idx = colorNames1.indexOf(words[0]);
let color2idx = colorNames2.indexOf(words[1]);
if (color1idx == -1 || color2idx == -1)
return 'неопознанный цвет';
return colorNames1[color2idx] + '-' + colorNames2[color1idx];
}
function transform(s) {
let first = s.split('').slice(0, s.indexOf('-'));
let second = s.split('').slice(s.indexOf('-') + 1);
if(first[first.length - 2] == 'ь')
{
first.splice(first.length - 2, 2);
first.push('ій');
}
else
{
first.splice(first.length - 1, 1);
first.push('ий');
}
if(second[second.length - 2] == 'і')
{
second.splice(second.length - 2, 2);
second.push('ьо');
}
else
{
second.splice(second.length - 2, 2);
second.push('о');
}
return second.join('') + '-' + first.join('');
}
function transform(a) {
let ma = a.split('-');
s1 = ma[0]
s2 = ma[1]
if (ma[0][ma[0].length - 2] + ma[0][ma[0].length - 1] == "ьо") {
ma[0] = ma[0].slice(0, -2)
ma[0] += "ій"
}
else
if (ma[0][ma[0].length - 1] == "о") {
ma[0] = ma[0].slice(0, -1)
ma[0] += "ий"
}
if (ma[1][ma[1].length - 2] + ma[1][ma[1].length - 1] == "ій")
ma[1] = ma[1].slice(0, -2) + "ьо"
else ma[1] = ma[1].slice(0, -2) + "о"
result = ma[1] + "-" + ma[0]
return result
}
function transform(s) {
let mas = s.split('-');
mas.reverse()
let result = []
let word = mas[0].split('')
let re1;
if (word[word.length -2] == 'і'){
word.pop()
word.pop()
word.push('ьо')
}
else{
word.pop()
word.pop()
word.push('о')
}
re1 = word.join('')
let word1 = mas[1].split('')
let re2;
if(word1[word1.length - 2] == 'ь'){
word1.pop()
word1.pop()
word1.push('ій')
re2 = word1.join('')
}
else
{
word1.pop()
word1.push('ий')
re2 = word1.join('')
}
result.unshift(re2)
result.unshift(re1)
return result.join('-')
}
function transform(color) {
let transArr = color.split('-');
let firstCol = transArr[0]; //синьо
let secondCol = transArr[1]; //зелений
let newFirstCol = '';
let newSecondCol = '';
let res = '';
let re1 = firstCol.split('').splice(firstCol.length-2, firstCol.length-1).join(''); //ьо
let re2 = secondCol.split('').splice(secondCol.length-2, secondCol.length-1).join(''); //ий
if (re1[0] == 'ь') {
newFirstCol = firstCol.replace(re1, 'ій');
} else if (re1[0] == 'н') {
newFirstCol = firstCol.replace(re1, 'ний');
} else if (re1[0] == 'т') {
newFirstCol = firstCol.replace(re1, 'тий');
}
if (re2[0] == 'и') {
newSecondCol = secondCol.replace(re2, 'о');
} else if (re2[0] == 'і') {
newSecondCol = secondCol.replace(re2, 'ьо');
}
res = newSecondCol + '-' + newFirstCol;
return res;
}
function transform(color){
arr = color.split('-').reverse();
if (arr[0].endsWith('ий')) arr[0] = arr[0].split('').slice(0, arr[0].length-2).concat(['о']).join('');
if (arr[0].endsWith('ій')) arr[0] = arr[0].split('').slice(0, arr[0].length-2).concat(['ь' ,'о']).join('');
if (arr[1].endsWith('ьо')) arr[1] = arr[1].split('').slice(0, arr[1].length-2).concat(['і' ,'й']).join('');
if (arr[1].endsWith('о')) arr[1] = arr[1].split('').slice(0, arr[1].length-1).concat(['и' ,'й']).join('');
return arr.join('-');
}
function transform(color){
let colora = color.split('-')
let check1 = false
let check2 = false
if(colora[0] == 'синьо'){
colora[0] = colora[0].split('')
colora[0].splice(colora[0].length-2,2)
colora[0] = colora[0].join('')
colora[0] += 'ій'
check1 = true
}else if(colora[1] == 'синій'){
colora[1] = colora[1].split('')
colora[1].splice(colora[1].length-2,2)
colora[1] = colora[1].join('')
colora[1] += 'ьо'
check2 = true
}
if(!check1){
colora[0] = colora[0].split('')
colora[0].splice(colora[0].length-1,1)
colora[0] = colora[0].join('')
colora[0] += 'ий'
}
if(!check2){
colora[1] = colora[1].split('')
colora[1].splice(colora[1].length-2,2)
colora[1] = colora[1].join('')
colora[1] += 'о'
}
return colora.reverse().join('-')
}
function transform(s) {
let mas = s.split('-');
mas.reverse()
let result = []
let word = mas[0].split('')
let re1;
if (word[word.length -2] == 'і'){
word.pop()
word.pop()
word.push('ьо')
}
else{
word.pop()
word.pop()
word.push('о')
}
re1 = word.join('')
let word1 = mas[1].split('')
let re2;
if(word1[word1.length - 2] == 'ь'){
word1.pop()
word1.pop()
word1.push('ій')
re2 = word1.join('')
}
else
{
word1.pop()
word1.push('ий')
re2 = word1.join('')
}
result.unshift(re2)
result.unshift(re1)
return result.join('-')
}
function transform(s)
{
let mas = s.split('-');
mas.reverse()
let result = []
let word = mas[0].split('')
let re1;
if (word[word.length -2] == 'і'){
word.pop()
word.pop()
word.push('ьо')
}
else{
word.pop()
word.pop()
word.push('о')
}
re1 = word.join('')
let word1 = mas[1].split('')
let re2;
if(word1[word1.length - 2] == 'ь'){
word1.pop()
word1.pop()
word1.push('ій')
re2 = word1.join('')
}
else
{
word1.pop()
word1.push('ий')
re2 = word1.join('')
}
result.unshift(re2)
result.unshift(re1)
return result.join('-')
}
function transform(color) {
let index = color.indexOf('-');
let first = color.slice(0, index);
first = first == 'синьо' ?
'синій' : first.slice(0, first.length - 1) + 'ий';
let second = color.slice(index + 1);
second = second == 'синій' ?
'синьо' : second.slice(0, second.length - 2) + 'о';
return second + '-' + first;
}
function transform(color)
{
let newcolor = "";
let end = ["ий","о"];
let elems = color.split("-");
if(elems[0] == "синьо")
{
newcolor = elems[1].slice(0,-2) + end[1] + "-" + "синій";
return newcolor;
}
if(elems[1] == "синій")
{
newcolor = "синьо" + "-" + elems[0].slice(0,-1) + end[0];
return newcolor;
}
else
{
newcolor = elems[1].slice(0,-2) + end[1] + "-" + elems[0].slice(0,-1) + end[0];
return newcolor;
}
}
function transform(a) {
let ma = a.split('-');
s1 = ma[0]
s2 = ma[1]
if (ma[0][ma[0].length - 2] + ma[0][ma[0].length - 1] == "ьо") {
ma[0] = ma[0].slice(0, -2)
ma[0] += "ій"
}
else
if (ma[0][ma[0].length - 1] == "о") {
ma[0] = ma[0].slice(0, -1)
ma[0] += "ий"
}
if (ma[1][ma[1].length - 2] + ma[1][ma[1].length - 1] == "ій")
ma[1] = ma[1].slice(0, -2) + "ьо"
else ma[1] = ma[1].slice(0, -2) + "о"
result = ma[1] + "-" + ma[0]
return result
}
function transform(color) {
let col = color.split('-');
let trs = '';
let a = col[0];
let b = col[1];
let c = a.substr(a.length - 2, 2);
let d = b.substr(b.length - 2, 2);
trs += b.substring(0, b.length - 2) + (d === 'ий' ? 'о' : 'ьо');
trs += '-' + a.substring(0, a.length - (c === 'ьо' ? 2 : 1)) + (c === 'ьо' ? 'ій' : 'ий');
return trs;
}
const colorTails = new Map([
['зелено', 'зелений'],
['червоно', 'червоний'],
['чорно', 'чорний'],
['біло', 'білий'],
['синьо', 'синій'],
['фіолетово', 'фіолетовий'],
['жовто', 'жовтий'],
['помаранчево', 'помаранчевий'],
['блакитно', 'блактиний'],
['сіро', 'сірий'],
['коричнево', 'коричневий'],
['рожево', 'рожевий'],
['зелений','зелено'],
['червоний','червоно'],
['чорний','чорно'],
['білий','біло'],
['синій','синьо'],
['фіолетовий','фіолетово'],
['жовтий','жовто'],
['помаранчевий','помаранчево'],
['блактиний', 'блакитно'],
['сірий','сіро'],
['коричневий','коричнево'],
['рожевий','рожево'],
]);
let array = color.split('-').reverse();
let color1 = array[0].toString();
array[0] = colorTails.get(color1);
let color2 = array[1].toString();
array[1] = colorTails.get(color2);
return array.toString().replace(',', '-');
}
let a = color.split('').slice(0, color.indexOf('-')), l1 = a.length;
let b = color.split('').slice(color.indexOf('-') + 1), l2 = b.length;
if(a[l1 - 2] == 'ь') {
a.splice(l1 - 2, 2);
a.push('ій');
} else {
a.splice(l1 - 1, 1);
a.push('ий');
}
if(b[l2 - 2] == 'і') {
b.splice(l2 - 2, 2);
b.push('ьо');
} else {
b.splice(l2 - 2, 2);
b.push('о');
}
return b.join('') + '-' + a.join('');
}
let splittedColor = color.toString().split('-')
let splitted1Color = splittedColor[0].split('')
let splitted2Color = splittedColor[1].split('')
if (splitted1Color[splitted1Color.length-2] == 'ь'){
splitted1Color.splice(splitted1Color.length-2,1,'ій')
splitted1Color.pop()
}
else{
splitted1Color.pop()
splitted1Color.push('ий')
}
if (splitted2Color[splitted2Color.length-2] == 'і'){
splitted2Color.splice(splitted2Color.length-2,1,'ь')
splitted2Color.splice(splitted2Color.length-1,1,'о')
}
else{
splitted2Color.pop()
splitted2Color.pop()
splitted2Color.push('о')
}
return `${splitted2Color.join('')}-${splitted1Color.join('')}`
}
let Color1 = color.toString().split('-')
let FirstColor = Color1[0].split('')
let SecondColor = Color1[1].split('')
if (FirstColor[FirstColor.length-2] == 'ь'){
FirstColor.splice(FirstColor.length-2,1,'ій')
FirstColor.pop()
}
else{
FirstColor.pop()
FirstColor.push('ий')
}
if (SecondColor[SecondColor.length-2] == 'і'){
SecondColor.splice(SecondColor.length-2,1,'ь')
SecondColor.splice(SecondColor.length-1,1,'о')
}
else{
SecondColor.pop()
SecondColor.pop()
SecondColor.push('о')
}
return `${SecondColor.join('')}-${FirstColor.join('')}`
}
color = color.split('-').reverse()
if(color[0].indexOf('і',color[0].length-2)==-1){
color[0] = color[0].split('')
color[0].pop()
color[0].pop()
color[0].push('о')
color[0] = color[0].join('')
}
else{
color[0] = color[0].split('')
color[0].pop()
color[0].pop()
color[0].push('ь')
color[0].push('о')
color[0] = color[0].join('')
}
if(color[1].indexOf('ь',color[1].length-2)!=-1){
color[1] = color[1].split('')
color[1].pop()
color[1].pop()
color[1].push('і')
color[1].push('й')
color[1]=color[1].join('')
}
else{
color[1] = color[1].split('')
color[1].pop()
color[1].push('и')
color[1].push('й')
color[1] = color[1].join('')
}
return color.join('-')
}
let arr = s.split('-');
let c1 = arr[0]
let c2 = arr[1]
if (c1.includes('ьо')) arr[0] = c1.slice(0,-2) + 'ій';
else arr[0] = c1.slice(0,-1) + 'ий';
if (c2.includes('ій')) arr[1] = c2.slice(0,-2) + 'ьо';
else arr[1] = c2.slice(0,-2) + 'о';
return arr.reverse().join('-')
}
let colors = shade.split('-');
let transformed = '';
let a = colors[0];
let b = colors[1];
let eA = a.substr(a.length - 2, 2);
let eB = b.substr(b.length - 2, 2);
transformed += b.substring(0, b.length - 2) + (eB === 'ий' ? 'о' : 'ьо');
transformed += '-' + a.substring(0, a.length - (eA === 'ьо' ? 2 : 1)) + (eA === 'ьо' ? 'ій' : 'ий');
return transformed;
}
dash = color.indexOf('-')
len = color.length
new_color = ''
if (color.slice(len-2) == 'ій')
new_color += color.slice(dash+1, len-2) + 'ьо-'
if (color.slice(len-2) == 'ий')
new_color += color.slice(dash+1, len-2) + 'о-'
if (color.slice(dash-2, dash) == 'ьо')
new_color += color.slice(0, dash-2) + 'ій'
else
new_color += color.slice(0, dash-1) + 'ий'
return new_color
}
let splitted = color.split('-')
let [firstCol, secondCol] = splitted;
[secondCol, firstCol] = [firstCol.slice(0,-1) + "ий", secondCol.slice(0,-2) + "о"]
if(firstCol == 'сино') firstCol = 'синьо'
if(secondCol == 'синьий') secondCol = 'синій'
return firstCol + '-' + secondCol;
}
let colors = shade.split('-');
let transf = '';
let a = colors[0];
let b = colors[1];
let eA = a.substr(a.length - 2, 2);
let eB = b.substr(b.length - 2, 2);
transf += b.substring(0, b.length - 2) + (eB == 'ий' ? 'о' : 'ьо');
transf += '-' + a.substring(0, a.length - (eA == 'ьо' ? 2 : 1)) + (eA == 'ьо' ? 'ій' : 'ий');
return transf;
}
str = str.split('-');
if (str[0].slice(str[0].length-2)=='ьо')
{
str[0]=str[0].replace('ьо', 'ій');
}
if (str[0].slice(str[0].length-2)=='но')
{
str[0]=str[0].replace('но', 'ний');
}
if (str[0].slice(str[0].length-2)=='то')
{
str[0]=str[0].replace('то', 'тий');
}
if (str[0].slice(str[0].length-2)=='во')
{
str[0]=str[0].replace('во', 'вий');
}
if (str[1].slice(str[1].length-2)=='ий')
{
str[1]=str[1].replace('ий', 'о');
}
if (str[1].slice(str[1].length-2)=='ій')
{
str[1]=str[1].replace('ій', 'ьо');
}
return str.reverse().join('-');
}
let result = "";
let divider_ind = s.indexOf('-');
let ending_1 = s.substring(divider_ind - 2, divider_ind);
let ending_2 = s.substring(s.length - 2, s.length);
let first_phrase = s.substring(0, divider_ind - 1);
let second_phrase = s.substring(divider_ind + 1, s.length - 2);
if (ending_1 == "ьо") f_ending_2 = "ій";
else f_ending_2 = "ий";
if (ending_2 == "ій") f_ending_1 = "ьо";
else f_ending_1 = "о";
if (first_phrase[first_phrase.length - 1] == "ь") first_phrase = s.substring(0, first_phrase.length - 1);
return result.concat(second_phrase, f_ending_1, "-", first_phrase, f_ending_2);
}
let ma = a.split('-');
s1 = ma[0]
s2 = ma[1]
if (ma[0][ma[0].length - 2] + ma[0][ma[0].length - 1] == "ьо") {
ma[0] = ma[0].slice(0, -2)
ma[0] += "ій"
}
else
if (ma[0][ma[0].length - 1] == "о") {
ma[0] = ma[0].slice(0, -1)
ma[0] += "ий"
}
if (ma[1][ma[1].length - 2] + ma[1][ma[1].length - 1] == "ій")
ma[1] = ma[1].slice(0, -2) + "ьо"
else ma[1] = ma[1].slice(0, -2) + "о"
result = ma[1] + "-" + ma[0]
return result
}
let a = color.split('-');
if((a[1].slice(-2))=="ій"){
a[1]= a[1].slice(0, -2)+"ьо"
}else{
a[1]= a[1].slice(0, -2)+"о"
}
if((a[0].slice(-2))=="ьо"){
a[0]= a[0].slice(0, -2)+"ій"
}else{
a[0]= a[0].slice(0, -1)+"ий"
}
return a[1]+'-'+a[0];
}
console.log(transform("зелено-синій") );
console.log(transform("синьо-зелений") );
let mas = s.split('-');
if (mas[0][mas[0].length-2]=='ь'){
mas[0]=mas[0].slice(0, mas[0].length-2)+'ій';
}
else mas[0]=mas[0].slice(0, mas[0].length-1)+'ий';
if (mas[1][mas[1].length-2]=='и'){
mas[1]=mas[1].slice(0, mas[1].length-2)+'о';
}
if (mas[1][mas[1].length-2]=='і'){
mas[1]=mas[1].slice(0, mas[1].length-2)+'ьо';
}
return (mas[1] + '-' + mas[0]);
}
let arr = color.split("-");
if(arr[0].slice(-2) == "ьо") {
arr[0] = arr[0].slice(0, -2) + "ій";
}
else {
arr[0] = arr[0].slice(0, -1) + "ий";
}
if(arr[1].slice(-2) == "ій") {
arr[1] = arr[1].slice(0, -2) + "ьо"
}
else {
arr[1] = arr[1].slice(0, -2) + "о"
}
return arr.reverse().join("-");
}
let ma = a.split('-');
s1 = ma[0]
s2 = ma[1]
if (ma[0][ma[0].length - 2] + ma[0][ma[0].length - 1] == "ьо") {
ma[0] = ma[0].slice(0, -2)
ma[0] += "ій"
}
else
if (ma[0][ma[0].length - 1] == "о") {
ma[0] = ma[0].slice(0, -1)
ma[0] += "ий"
}
if (ma[1][ma[1].length - 2] + ma[1][ma[1].length - 1] == "ій")
ma[1] = ma[1].slice(0, -2) + "ьо"
else ma[1] = ma[1].slice(0, -2) + "о"
result = ma[1] + "-" + ma[0]
return result
}
let start='', end='';
if (s.slice(0,s.indexOf('-')-2) == 'син') start = s.slice(0,s.indexOf('-')-2);
else start = s.slice(0,s.indexOf('-')-1);
end = s.slice(s.indexOf('-')+1,-2);
if (start != 'син') start += 'ий';
else start += 'ій';
if (end != 'син') end += 'о';
else end += 'ьо';
return end+"-"+start;
}
s=s.split('-');
s.reverse();
//first word
if(s[0].slice(-2, -1)=='і'){
s[0]=s[0].slice(0, -2);
s[0]+="ьо";
}
else{
s[0]=s[0].slice(0, -2);
s[0]+="о";
}
//second word
if(s[1][s[1].length-2]=="ь"){
s[1]=s[1].slice(0, -2);
s[1]+="і";
s[1]+="й";
}
else{
s[1]=s[1].slice(0, -1);
s[1]+="и";
s[1]+="й";
}
s=s.join('-');
return s;
}
let [w1, w2] = color.split('-');
if (w1.substring(w1.length-2) == 'ьо') {
w1 = w1.replace(/..$/,'ій');
}
else if (w1.substring(w1.length-1) == 'о'){
w1 = w1.replace(/.$/,'ий');
}
if (w2.substring(w2.length-2) == 'ий') {
w2 = w2.replace(/..$/,'о')
}
else if (w2.substring(w2.length-2) == 'ій') {
w2 = w2.replace(/..$/,'ьо')
}
return w2 + '-' + w1;
}
let half1 = s.split('').slice(0, s.indexOf('-'));
let half2 = s.split('').slice(s.indexOf('-') + 1);
if(half1[half1.length - 2] == 'ь'){
half1.splice(half1.length - 2, 2);
half1.push('ій');
}else{
half1.splice(half1.length - 1, 1);
half1.push('ий');
}
if(half2[half2.length - 2] == 'і'){
half2.splice(half2.length - 2, 2);
half2.push('ьо');
}else{
half2.splice(half2.length - 2, 2);
half2.push('о');
}
return half2.join('') + '-' + half1.join('');
}
arr = s.split("-")
zak1 = arr[0].slice(arr[0].length - 2, arr[0].length)
zak2 = arr[1].slice(arr[1].length - 2, arr[1].length)
arr[0]=arr[0].split("")
arr[1]=arr[1].split("")
if (zak1 == "ьо")
{
arr[0][arr[0].length-2]="і"
arr[0][arr[0].length-1]="й"
}
else if (zak1[1] == "о")
{
arr[0][arr[0].length-1]="и"
arr[0][arr[0].length]="й"
}
if (zak2 == "ий")
{
arr[1][arr[1].length-2]="о"
arr[1].pop()
}
else if (zak2 == "ій")
{
arr[1][arr[1].length-2]="ь"
arr[1][arr[1].length-1]="о"
}
let str = arr[1].join("")+"-"+arr[0].join("")
return str
}
let colors = shade.split('-');
let transformed = '';
let a = colors[0];
let b = colors[1];
let eA = a.substr(a.length - 2, 2);
let eB = b.substr(b.length - 2, 2);
transformed += b.substring(0, b.length - 2) + (eB === 'ий' ? 'о' : 'ьо');
transformed += '-' + a.substring(0, a.length - (eA === 'ьо' ? 2 : 1)) + (eA === 'ьо' ? 'ій' : 'ий');
return transformed;
}
let string1 = color.split('-')[0]
let string2 = color.split('-')[1]
if (string1.slice(string1.length - 2) == 'ьо')
string1 = string1.slice(0, string1.length - 2) + 'ій'
else if (string1.slice(string1.length - 1) == 'о')
string1 = string1.slice(0, string1.length - 1) + 'ий'
if (string2.slice(string2.length - 2) == 'ій')
string2 = string2.slice(0, string2.length - 2) + 'ьо'
else if (string2.slice(string2.length - 2) == 'ий')
string2 = string2.slice(0, string2.length - 2) + 'о'
return string2 + '-' + string1
}
let splitted = color.split('-')
let [firstCol, secondCol] = splitted;
[secondCol, firstCol] = [firstCol.slice(0,-1) + "ий", secondCol.slice(0,-2) + "о"]
if(firstCol == 'сино') firstCol = 'синьо'
if(secondCol == 'синьий') secondCol = 'синій'
return firstCol + '-' + secondCol;
}
let arr = str.split("-");
if(arr[0].slice(-2) == "ьо")
arr[0] = arr[0].slice(0, -2) + "ій";
else
arr[0] = arr[0].slice(0, -1) + "ий";
if(arr[1].slice(-2) == "ій")
arr[1] = arr[1].slice(0, -2) + "ьо"
else
arr[1] = arr[1].slice(0, -2) + "о"
return arr.reverse().join("-")
}
let colors = color.split('-');
let transformed = '';
let a = colors[0];
let b = colors[1];
let aA = a.substr(a.length - 2, 2);
let bB = b.substr(b.length - 2, 2);
transformed += b.substring(0, b.length - 2) + (bB === 'ий' ? 'о' : 'ьо');
transformed += '-' + a.substring(0, a.length - (aA === 'ьо' ? 2 : 1)) + (aA === 'ьо' ? 'ій' : 'ий');
return transformed;
}
let colors = shade.split('-');
let transformed = '';
let a = colors[0];
let b = colors[1];
let eA = a.substr(a.length - 2, 2);
let eB = b.substr(b.length - 2, 2);
transformed += b.substring(0, b.length - 2) + (eB === 'ий' ? 'о' : 'ьо');
transformed += '-' + a.substring(0, a.length - (eA === 'ьо' ? 2 : 1)) + (eA === 'ьо' ? 'ій' : 'ий');
return transformed;
}
let arr = str.split("-");
if(arr[0].slice(-2) == "ьо")
arr[0] = arr[0].slice(0, -2) + "ій";
else
arr[0] = arr[0].slice(0, -1) + "ий";
if(arr[1].slice(-2) == "ій")
arr[1] = arr[1].slice(0, -2) + "ьо"
else
arr[1] = arr[1].slice(0, -2) + "о"
return arr.reverse().join("-")
}
let arr = color.split('-');
let d=arr[0]
let k0 = '';
let r0 = d[d.length-2] + d[d.length-1];
for(let i = 0; i < d.length; i++){
if(r0 == 'ьо'){
if(i == d.length - 2){
k0+= 'ій';
break;
} else
k0+=d[i];
} else {
if(i == d.length - 1){
k0+= 'ий';
break;
} else
k0+=d[i];
}
}
let t=arr[1]
let k1 = '';
let r1 = t[t.length-2] + t[t.length-1];
for(let i = 0; i < t.length; i++){
if(r1 == 'ій') {
if(i == t.length - 2) {
k1+= 'ьо';
break
} else
k1+=t[i];
} else{
if(i == t.length - 2) {
k1+= 'о';
break
} else
k1+=t[i];
} }
return k1 + '-' + k0;
}
let arr = color.split('-');
if((arr[1].slice(-2))=="ій"){
arr[1]= arr[1].slice(0, -2)+"ьо"
}else{
arr[1]= arr[1].slice(0, -2)+"о"
}
if((arr[0].slice(-2))=="ьо"){
arr[0]= arr[0].slice(0, -2)+"ій"
}else{
arr[0]= arr[0].slice(0, -1)+"ий"
}
return arr[1]+'-'+arr[0];
}
let splittedColor = color.toString().split('-')
let splittedFirstColor = splittedColor[0].split('')
let splittedSecondColor = splittedColor[1].split('')
if (splittedFirstColor[splittedFirstColor.length-2] == 'ь'){
splittedFirstColor.splice(splittedFirstColor.length-2,1,'ій')
splittedFirstColor.pop()
}
else{
splittedFirstColor.pop()
splittedFirstColor.push('ий')
}
if (splittedSecondColor[splittedSecondColor.length-2] == 'і'){
splittedSecondColor.splice(splittedSecondColor.length-2,1,'ь')
splittedSecondColor.splice(splittedSecondColor.length-1,1,'о')
}
else{
splittedSecondColor.pop()
splittedSecondColor.pop()
splittedSecondColor.push('о')
}
return `${splittedSecondColor.join('')}-${splittedFirstColor.join('')}`
}
let half1=color.split('-')[0]
let half2=color.split('-')[1]
let root1=half1.includes('син')?half1.slice(0,half1.length-2):half1.slice(0,half1.length-1)
let root2=half2.slice(0,half2.length-2)
let s=`${root2}${root2=='син'?"ьо":"о"}-${root1}${root1=='син'?"ій":"ий"}`
return s
}
let array = color.split("-").reverse();
if (array[0].slice(array[0].length - 2, array[0].length) == "ий"){
array[0] = array[0].slice(0, array[0].length - 2)
array[0] += "о";
}
else{
array[0] = array[0].slice(0, array[0].length - 2)
array[0] += "ьо";
}
if (array[1].slice(array[1].length - 2, array[1].length) == "ьо"){
array[1] = array[1].slice(0, array[1].length - 2)
array[1] += "ій";
}
else{
array[1] = array[1].slice(0, array[1].length - 1)
array[1] += "ий";
}
color = array.join("-");
return color;
}
color =color.split("-");
const arr_of_colors_1 = ["червоно","синьо","біло","чорно","жовто","помаранчево",
"рожево","фіолетово","блакитно","сіро","зелено","коричнево","красно","сине",
"бело","чёрно","жёлто","оранжево","розово","фиолетово","голубо","серо",
"зелёно"]
const arr_of_colors_2 = ["червоний","синій","білий","чорний","жовтий","помаранчевий",
"рожевий","фіолетовий","блакитний","сірий","зелений","коричневий","красный","синий",
"белый","чёрный","жёлтый","оранжевый","розовый","фиолетовый","голубой","серый",
"зелёный"]
let index_1 = arr_of_colors_1.indexOf(color[0])
let index_2 = arr_of_colors_2.indexOf(color[1])
if(index_1!=-1){
color[0] = arr_of_colors_2[index_1]
}
if(index_2!=-1){
color[1]= arr_of_colors_1[index_2]
}
let semi_color = color[0];
color[0] = color[1]
color[1] = semi_color
console.log(color)
color =color.join("-")
return color
}
let colors = shade.split('-');
let transformed = '';
let a = colors[0];
let b = colors[1];
let eA = a.substr(a.length - 2, 2);
let eB = b.substr(b.length - 2, 2);
transformed += b.substring(0, b.length - 2) + (eB === 'ий' ? 'о' : 'ьо');
transformed += '-' + a.substring(0, a.length - (eA === 'ьо' ? 2 : 1)) + (eA === 'ьо' ? 'ій' : 'ий');
return transformed;
}
{
let Color1_2 = color.toString().split('-')
let FirstColor = Color1_2[0].split('')
let SecondColor = Color1_2[1].split('')
let result;
if (FirstColor[FirstColor.length-2] == 'ь')
{
FirstColor.splice(FirstColor.length-2,1,'ій')
FirstColor.pop()
}
else
{
FirstColor.pop()
FirstColor.push('ий')
}
if (SecondColor[SecondColor.length-2] == 'і')
{
SecondColor.splice(SecondColor.length-2,1,'ь')
SecondColor.splice(SecondColor.length-1,1,'о')
}
else
{
SecondColor.pop()
SecondColor.pop()
SecondColor.push('о')
}
result = `${SecondColor.join('')}-${FirstColor.join('')}`;
return result;
}
{
let colors = color.split('-')
let c1 = colors[0]
let c2 = colors[1]
if(c1.endsWith('но'))
{
c1 = c1.replace('но', 'ний')
}
else if(c1.endsWith('ньо'))
{
c1 = c1.replace('ньо', 'ній')
}
else if(c1.endsWith('то'))
{
c1 = c1.replace('то', 'тий')
}
else
{
c1 = c1.replace('о', 'ий')
}
if(c2.endsWith('ний'))
{
c2 = c2.replace('ний', 'но')
}
else if(c2.endsWith('ній'))
{
c2 = c2.replace('ній', 'ньо')
}
else if(c2.endsWith('тий'))
{
c2 = c2.replace('тий', 'то')
}
else
{
c2 = c2.replace('ий', 'о')
}
return c2 + '-' + c1
}
let colors = shade.split('-');
let transformed = '';
let a = colors[0];
let b = colors[1];
let eA = a.substr(a.length - 2, 2);
let eB = b.substr(b.length - 2, 2);
transformed += b.substring(0, b.length - 2) + (eB === 'ий' ? 'о' : 'ьо');
transformed += '-' + a.substring(0, a.length - (eA === 'ьо' ? 2 : 1)) + (eA === 'ьо' ? 'ій' : 'ий');
return transformed;
}
let mas = s.split('-');
mas.reverse()
let result = []
let word = mas[0].split('')
let re1;
if (word[word.length -2] == 'і'){
word.pop()
word.pop()
word.push('ьо')
}
else{
word.pop()
word.pop()
word.push('о')
}
re1 = word.join('')
let word1 = mas[1].split('')
let re2;
if(word1[word1.length - 2] == 'ь'){
word1.pop()
word1.pop()
word1.push('ій')
re2 = word1.join('')
}
else
{
word1.pop()
word1.push('ий')
re2 = word1.join('')
}
result.unshift(re2)
result.unshift(re1)
return result.join('-')
}
let mas = s.split('-');
mas.reverse()
let result = []
let word = mas[0].split('')
let re1;
if (word[word.length -2] == 'і'){
word.pop()
word.pop()
word.push('ьо')
}
else{
word.pop()
word.pop()
word.push('о')
}
re1 = word.join('')
let word1 = mas[1].split('')
let re2;
if(word1[word1.length - 2] == 'ь'){
word1.pop()
word1.pop()
word1.push('ій')
re2 = word1.join('')
}
else
{
word1.pop()
word1.push('ий')
re2 = word1.join('')
}
result.unshift(re2)
result.unshift(re1)
return result.join('-')
}
let colors = shade.split('-');
let transformed = '';
let a = colors[0];
let b = colors[1];
let eA = a.substr(a.length - 2, 2);
let eB = b.substr(b.length - 2, 2);
transformed += b.substring(0, b.length - 2) + (eB === 'ий' ? 'о' : 'ьо');
transformed += '-' + a.substring(0, a.length - (eA === 'ьо' ? 2 : 1)) + (eA === 'ьо' ? 'ій' : 'ий');
return transformed;
}
let arrH = s.split('-');
let h1 = arrH[0].split('');
let h2 = arrH[1].split('');
let end1 = h1.slice(h1.length-2);
let end2 = h2.slice(h2.length-2);
if(end2[0] == 'ы'){
if(end1[1] == 'е'){
end2 = ['и','й']
end1[1] = 'о';
end1[0] = '';
}else {
end1[0] = '';
}
}else {
if(arrH[1] != 'синий'){
if(end2[0] == 'і'){
end1 = ['ь', 'о'];
end2 = ['и', 'й'];
}else if(end1[0] == 'ь'){
h1.pop();
end2 = ['і', 'й'];
end1[0] = '';
}else {
end1[0] = '';
}
}else {
end1 = ['', 'е'];
end2 = ['ы', 'й'];
}
}
h1 = h1.slice(0, h1.length-1);
h2 = h2.slice(0, h2.length-2);
return h2.join('')+end1.join('')+'-'+h1.join('')+ end2.join('');
}
let colors = shade.split('-');
let transformed = '';
let a = colors[0];
let b = colors[1];
let eA = a.substr(a.length - 2, 2);
let eB = b.substr(b.length - 2, 2);
transformed += b.substring(0, b.length - 2) + (eB === 'ий' ? 'о' : 'ьо');
transformed += '-' + a.substring(0, a.length - (eA === 'ьо' ? 2 : 1)) + (eA === 'ьо' ? 'ій' : 'ий');
return transformed;
}
let arr = s.split('-')
let first = arr[0]
let first1 = first.split('')
let second = arr[arr.length-1]
let second1 = second.split('')
if (first1[first1.length-2] == 'ь'){
first1.splice(first1.length-2, 2, 'і', 'й')
}
if (first1[first1.length-1] == 'о'){
first1.splice(first1.length-1, 1, 'и', 'й')
}
if (second1[second1.length-2] == 'и'){
second1.splice(second1.length-2, 2, 'о')
}
if (second1[second1.length-2] == 'і'){
second1.splice(second1.length-2, 2, 'ь', 'о')
}
let string1 = second1.join('')
let string2 = first1.join('')
return string1 + '-' + string2
}
let a = str.split('-').reverse(),
f = a[0].split(''),
s = a[1].split(''),
ff;
if (f[f.length-2] == 'і')
ff = 'ьо';
else ff = 'о'
f.splice(f.length - 2, 2, ff)
a [0] = f.join('');
if (s[s.length-2] == 'ь')
s.splice(s.length - 2, 2, 'ій');
else s.splice(s.length - 1, 1, 'ий')
a [1] = s.join('');
return a.join('-');
}
let word1 = color.split('').slice(0, color.indexOf('-')), l1 = word1.length;
let word2 = color.split('').slice(color.indexOf('-') + 1), l2 = word2.length;
if(word1[l1 - 2] == 'ь') {
word1.splice(l1 - 2, 2);
word1.push('ій');
} else {
word1.splice(l1 - 1, 1);
word1.push('ий');
}
if(word2[l2 - 2] == 'і') {
word2.splice(l2 - 2, 2);
word2.push('ьо');
} else {
word2.splice(l2 - 2, 2);
word2.push('о');
}
return word2.join('') + '-' + word1.join('');
}
endings = ["ий", "о"]
colors = color.split("-")
if(colors[0] == "синьо"){
return colors[1].slice(0, -2) + endings[1] + "-" + "синій"
}
if(colors[1] == "синій"){
return "синьо" + "-" +colors[0].slice(0, -1) + endings[0]
}
else{
return colors[1].slice(0, -2) + endings[1] + "-" + colors[0].slice(0, -1) + endings[0]
}
}
let colors = color.split("-");
let color1 = colors[1];
let color2 = colors[0];
if(color1.endsWith("ній")) {
color1 = color1.replace("ній", "ньо");
} else
if(color1.endsWith("ний")) {
color1 = color1.replace("ний", "но");
}else
if(color1.endsWith("тий")) {
color1 = color1.replace("тий", "то");
}else{
color1 = color1.replace("ий", "о");
}
if(color2.endsWith("ньо")) {
color2 = color2.replace("ньо", "ній");
}else
if(color2.endsWith("но")) {
color2 = color2.replace("но", "ний");
}else
if(color2.endsWith("то")) {
color2 = color2.replace("то", "тий");
}else {
color2 = color2.replace("о", "ий");
}
return color1 + "-" + color2;
}
let words = s.split('-').reverse()
if (words[0] === "синій")
words[0] = words[0].slice(0, -2) + "ьо"
else words[0] = words[0].slice(0, -2) + "о"
if (words[1] === "синьо")
words[1] = words[1].slice(0, -2) + "ій"
else words[1] = words[1].slice(0, -1) + "ий"
return words.join('-')
}
{
color=color.split('-').reverse()
if(color.indexOf('синій')!=-1)
{
color[0]=color[0].slice(0,-2).concat('ьо');
color[1]=color[1].slice(0,-1).concat('ий');
color=color.join('-');
return color}
if(color.indexOf('синьо')!=-1)
{
color[0]=color[0].slice(0,-2).concat('о');
color[1]=color[1].slice(0,-2).concat('ій');
color=color.join('-');
return color}
color[0]=color[0].slice(0,-2).concat('о');
color[1]=color[1].slice(0,-1).concat('ий');
color=color.join('-');
return color
}
let arr=color.split('-');
let a1=arr[0];
let a2=arr[1];
if (a1.slice(-2) == 'ьо') {
a1=a1.split('');
a1.splice(-2,2,'ій');
}
else {
a1=a1.split('');
a1.splice(-1,1,'ий');
}
if (a2.slice(-2) == 'ий') {
a2=a2.split('');
a2.splice(-2,2,'о');
}
else {
a2=a2.split('');
a2.splice(-2,2,'ьо');
}
let m=[];
arr=m.concat(a2,'-',a1);
return arr.join('');
}
const colorNames1 = ['червоно', 'рожево', 'помаранчево', 'жовто', 'зелено', 'блакитно', 'синьо', 'бузково', 'фіолетово', 'чорно', 'біло', 'сіро', 'коричнево',
'красно', 'оранжево', 'желто', 'зелёно', 'голубо', 'сине', 'фиолетово', 'бело', 'черно', 'чёрно'];
const colorNames2 = [
'червоний', 'рожевий', 'помаранчевий', 'жовтий', 'зелений', 'блакитний', 'синій', 'бузковий', 'фіолетовий', 'чорний', 'білий', 'сірий', 'коричневий',
'красный', "оранжевый", "желтый", "зелёный", "голубой" ,'синий', 'фиолетовый', 'белый', "черный", "чёрный"
];
let words = s.toLowerCase().split("-");
let color1idx = colorNames1.indexOf(words[0]);
let color2idx = colorNames2.indexOf(words[1]);
if (color1idx == -1 || color2idx == -1)
return 'неопознанный цвет';
return colorNames1[color2idx] + '-' + colorNames2[color1idx];
}
let first = s.split('').slice(0, s.indexOf('-'));
let second = s.split('').slice(s.indexOf('-') + 1);
if(first[first.length - 2] == 'ь')
{
first.splice(first.length - 2, 2);
first.push('ій');
}
else
{
first.splice(first.length - 1, 1);
first.push('ий');
}
if(second[second.length - 2] == 'і')
{
second.splice(second.length - 2, 2);
second.push('ьо');
}
else
{
second.splice(second.length - 2, 2);
second.push('о');
}
return second.join('') + '-' + first.join('');
}
let ma = a.split('-');
s1 = ma[0]
s2 = ma[1]
if (ma[0][ma[0].length - 2] + ma[0][ma[0].length - 1] == "ьо") {
ma[0] = ma[0].slice(0, -2)
ma[0] += "ій"
}
else
if (ma[0][ma[0].length - 1] == "о") {
ma[0] = ma[0].slice(0, -1)
ma[0] += "ий"
}
if (ma[1][ma[1].length - 2] + ma[1][ma[1].length - 1] == "ій")
ma[1] = ma[1].slice(0, -2) + "ьо"
else ma[1] = ma[1].slice(0, -2) + "о"
result = ma[1] + "-" + ma[0]
return result
}
let mas = s.split('-');
mas.reverse()
let result = []
let word = mas[0].split('')
let re1;
if (word[word.length -2] == 'і'){
word.pop()
word.pop()
word.push('ьо')
}
else{
word.pop()
word.pop()
word.push('о')
}
re1 = word.join('')
let word1 = mas[1].split('')
let re2;
if(word1[word1.length - 2] == 'ь'){
word1.pop()
word1.pop()
word1.push('ій')
re2 = word1.join('')
}
else
{
word1.pop()
word1.push('ий')
re2 = word1.join('')
}
result.unshift(re2)
result.unshift(re1)
return result.join('-')
}
let transArr = color.split('-');
let firstCol = transArr[0]; //синьо
let secondCol = transArr[1]; //зелений
let newFirstCol = '';
let newSecondCol = '';
let res = '';
let re1 = firstCol.split('').splice(firstCol.length-2, firstCol.length-1).join(''); //ьо
let re2 = secondCol.split('').splice(secondCol.length-2, secondCol.length-1).join(''); //ий
if (re1[0] == 'ь') {
newFirstCol = firstCol.replace(re1, 'ій');
} else if (re1[0] == 'н') {
newFirstCol = firstCol.replace(re1, 'ний');
} else if (re1[0] == 'т') {
newFirstCol = firstCol.replace(re1, 'тий');
}
if (re2[0] == 'и') {
newSecondCol = secondCol.replace(re2, 'о');
} else if (re2[0] == 'і') {
newSecondCol = secondCol.replace(re2, 'ьо');
}
res = newSecondCol + '-' + newFirstCol;
return res;
}
arr = color.split('-').reverse();
if (arr[0].endsWith('ий')) arr[0] = arr[0].split('').slice(0, arr[0].length-2).concat(['о']).join('');
if (arr[0].endsWith('ій')) arr[0] = arr[0].split('').slice(0, arr[0].length-2).concat(['ь' ,'о']).join('');
if (arr[1].endsWith('ьо')) arr[1] = arr[1].split('').slice(0, arr[1].length-2).concat(['і' ,'й']).join('');
if (arr[1].endsWith('о')) arr[1] = arr[1].split('').slice(0, arr[1].length-1).concat(['и' ,'й']).join('');
return arr.join('-');
}
let colora = color.split('-')
let check1 = false
let check2 = false
if(colora[0] == 'синьо'){
colora[0] = colora[0].split('')
colora[0].splice(colora[0].length-2,2)
colora[0] = colora[0].join('')
colora[0] += 'ій'
check1 = true
}else if(colora[1] == 'синій'){
colora[1] = colora[1].split('')
colora[1].splice(colora[1].length-2,2)
colora[1] = colora[1].join('')
colora[1] += 'ьо'
check2 = true
}
if(!check1){
colora[0] = colora[0].split('')
colora[0].splice(colora[0].length-1,1)
colora[0] = colora[0].join('')
colora[0] += 'ий'
}
if(!check2){
colora[1] = colora[1].split('')
colora[1].splice(colora[1].length-2,2)
colora[1] = colora[1].join('')
colora[1] += 'о'
}
return colora.reverse().join('-')
}
let mas = s.split('-');
mas.reverse()
let result = []
let word = mas[0].split('')
let re1;
if (word[word.length -2] == 'і'){
word.pop()
word.pop()
word.push('ьо')
}
else{
word.pop()
word.pop()
word.push('о')
}
re1 = word.join('')
let word1 = mas[1].split('')
let re2;
if(word1[word1.length - 2] == 'ь'){
word1.pop()
word1.pop()
word1.push('ій')
re2 = word1.join('')
}
else
{
word1.pop()
word1.push('ий')
re2 = word1.join('')
}
result.unshift(re2)
result.unshift(re1)
return result.join('-')
}
{
let mas = s.split('-');
mas.reverse()
let result = []
let word = mas[0].split('')
let re1;
if (word[word.length -2] == 'і'){
word.pop()
word.pop()
word.push('ьо')
}
else{
word.pop()
word.pop()
word.push('о')
}
re1 = word.join('')
let word1 = mas[1].split('')
let re2;
if(word1[word1.length - 2] == 'ь'){
word1.pop()
word1.pop()
word1.push('ій')
re2 = word1.join('')
}
else
{
word1.pop()
word1.push('ий')
re2 = word1.join('')
}
result.unshift(re2)
result.unshift(re1)
return result.join('-')
}
let index = color.indexOf('-');
let first = color.slice(0, index);
first = first == 'синьо' ?
'синій' : first.slice(0, first.length - 1) + 'ий';
let second = color.slice(index + 1);
second = second == 'синій' ?
'синьо' : second.slice(0, second.length - 2) + 'о';
return second + '-' + first;
}
{
let newcolor = "";
let end = ["ий","о"];
let elems = color.split("-");
if(elems[0] == "синьо")
{
newcolor = elems[1].slice(0,-2) + end[1] + "-" + "синій";
return newcolor;
}
if(elems[1] == "синій")
{
newcolor = "синьо" + "-" + elems[0].slice(0,-1) + end[0];
return newcolor;
}
else
{
newcolor = elems[1].slice(0,-2) + end[1] + "-" + elems[0].slice(0,-1) + end[0];
return newcolor;
}
}
let ma = a.split('-');
s1 = ma[0]
s2 = ma[1]
if (ma[0][ma[0].length - 2] + ma[0][ma[0].length - 1] == "ьо") {
ma[0] = ma[0].slice(0, -2)
ma[0] += "ій"
}
else
if (ma[0][ma[0].length - 1] == "о") {
ma[0] = ma[0].slice(0, -1)
ma[0] += "ий"
}
if (ma[1][ma[1].length - 2] + ma[1][ma[1].length - 1] == "ій")
ma[1] = ma[1].slice(0, -2) + "ьо"
else ma[1] = ma[1].slice(0, -2) + "о"
result = ma[1] + "-" + ma[0]
return result
}
let col = color.split('-');
let trs = '';
let a = col[0];
let b = col[1];
let c = a.substr(a.length - 2, 2);
let d = b.substr(b.length - 2, 2);
trs += b.substring(0, b.length - 2) + (d === 'ий' ? 'о' : 'ьо');
trs += '-' + a.substring(0, a.length - (c === 'ьо' ? 2 : 1)) + (c === 'ьо' ? 'ій' : 'ий');
return trs;
}