Данный отчёт сгенерирован 04.04.2023 06:21:13 UTC.
HTML версия (этот сайт) сгенерирован 04.04.2023 06:21:31 UTC.
Коммит: [bfeb65b9] add automatic zip creation
04.04.2023 06:21:13
Задача: Слова у Рифму 04.04.2023 06:21:13
Описание: Оголосити метод Rhyme, який отримує два слова, наприклад, «комар» та «кошмар». Якщо введені слова римуються, метод повертає true, якщо не римуються, false. Вважатимемо, що слова римуються, якщо в них збігаються три останні літери, або всі літери, якщо якесь слово коротше трьох літер. 04.04.2023 06:21:13
Решений: 48 04.04.2023 06:21:13
Слова у Рифму 04.04.2023 06:21:13
 static bool Rhyme(string w1, string w2){
            if (w1.Length < 3 || w2.Length < 3){
                int minLen = Math.Min(w1.Length, w2.Length);
                if(w1.Substring(w1.Length - minLen, minLen) == w2.Substring(w2.Length - minLen, minLen)){
                    return true;
                }
                else{
                    return false;
                }
            }
            else{
                if(w1.Substring(w1.Length - 3, 3) == w2.Substring(w2.Length - 3, 3)){
                    return true;
                }
                else{
                    return false;
                }
            }
        }
 static bool Rhyme(string w1, string w2)
    {
        int minLength = Math.Min(w1.Length, w2.Length);
        int compareLength = Math.Min(3, minLength);

        for (int i = 1; i <= compareLength; i++)
        {
            if (w1[w1.Length - i] != w2[w2.Length - i])
            {
                return false;
            }
        }
        return true;
    }
 static bool Rhyme(string w1, string w2)
{
     if( (w1.Length>=3&&w2.Length>=3&&w1.Substring(w1.Length-3,3)==w2.Substring(w1.Length-3,3)) ||(w1.Length< 3&&w1.Length< w2.Length&&w2.EndsWith(w1)) ||(w2.Length< 3&&w2.Length< w1.Length&&w1.EndsWith(w1))){return true;}
    else{return false;}
}
 static bool Rhyme(string w1, string w2){
    if (w1.Length > 2 && w2.Length > 2){
        w1=w1.Substring(w1.Length-3,3);
        w2=w2.Substring(w2.Length-3,3);
        return w1 == w2;
    }
    else{
        if (w1.Length < 3) {
            return w1 == w2.Substring(w2.Length-w1.Length,w1.Length);
        }
        else {
            return w2 == w1.Substring(w1.Length-w2.Length,w2.Length);
        }
    }
}
 static bool Rhyme(string w1, string w2)
{
    int schet = 0;
    for (int i = 1; i <= w1.Length && i <= w2.Length && i <= 3; i++)
    {
        if (w1[^i] == w2[^i]) schet++;
        if(schet==3 || schet==w1.Length || schet==w2.Length) { 
            return true;
        }
    }
    return false;
}
 static bool Rhyme(string w1, string w2) {
    if (string.IsNullOrEmpty(w1) == true || string.IsNullOrEmpty(w2) == true)
        return false;
    int l = Math.Min(Math.Min(w1.Length, w2.Length), 3);
    return string.Equals(w1.Substring(w1.Length - l), w2.Substring(w2.Length - l), StringComparison.OrdinalIgnoreCase);
}
 static bool Rhyme(string w1, string w2){
bool res = false;
if(w1.Length > 3 && w2.Length > 3){
   for(int i = 1;i <= 3;i++){
       for(int j = 1;j <= 3;j++){
       if(w1[w1.Length - i] == w2[w2.Length - j]){
           res = true;
           
           continue;
       }
       else{
           break;
       }
       }
   }
   }
   if(w1.Length < 3 || w2.Length < 3){
    if(w2.Length ==1|| w1.Length == 1){
        for(int i = 1;i < 2;i++){
            if(w1[w1.Length-i]==w2[w2.Length-i]){
                res = true;
            }
        }
    }
    else{
    for(int i  = 1; i < 3;i++){
       for(int j = 1;j < 3;j++){
         if(w1[w1.Length - i] == w2[w2.Length - j]){
           res = true;
           
           continue;
       }
       else{
           break;
       }   
    }
    }
}
}
   return res;
}
 static bool Rhyme(string w1, string w2)
{
    int w1LastElement = w1.Length - 1;
    int w2LastElement = w2.Length - 1;
    int result = 0;
    while (w1LastElement >= 0 && w2LastElement >=0)
    {
        if (w1[w1LastElement] == w2[w2LastElement])
        {
            result++;
        }
        w1LastElement--;
        w2LastElement--;
    }
    if (result >= 3 || result == w1.Length || result == w2.Length)
    {
        return true;
    }
    else
    {
        return false;
    }
}
 static bool Rhyme(string w1, string w2){
    if (w1.Length < 3 && w1 == w2.Substring(w2.Length - w1.Length) || w2.Length < 3 && w2 == w1.Substring(w1.Length - w2.Length) || w1.Substring(w1.Length - 3) == w2.Substring(w2.Length - 3))
            {
                return true;
            }
            else
            {
                return false;
            }
}
 static bool Rhyme(string w1, string w2){
if(w1.Length < 3 && w1.Length <= w2.Length) return w1 == w2.Substring(w2.Length-w1.Length);
if(w2.Length < 3 && w1.Length >= w2.Length) return w2 == w1.Substring(w1.Length-w2.Length);
return w2.Substring(w2.Length-3) == w1.Substring(w1.Length-3);
}
 static bool Rhyme(string w1, string w2)
{
    if( (w1.Length>=3&&w2.Length>=3&&w1.Substring(w1.Length-3,3)==w2.Substring(w1.Length-3,3)) || (w1.Length< 3&&w1.Length< w2.Length&&w2.EndsWith(w1)) || (w2.Length< 3&&w2.Length< w1.Length&&w1.EndsWith(w1))){return true;}
    else{return false;}
}
 static bool Rhyme(string w1, string w2)
{   
    int l = w1.Length > w2.Length ? (w2.Length > 3 ? 3 : w2.Length) : (w1.Length > 3 ? 3 : w1.Length);
    return w1.Substring(w1.Length - l) == w2.Substring(w2.Length - l);
}
 static bool Rhyme(string w1, string w2){
    if(w1.Length< 3) return w1 == w2.Substring(w2.Length-w1.Length, w1.Length);
    if(w2.Length< 3) return w2 == w1.Substring(w1.Length-w2.Length, w2.Length);
    return w1.Substring(w1.Length-3, 3) == w2.Substring(w2.Length-3, 3);
}
 static bool Rhyme(string w1, string w2)
{
    if (w1.Length < 3)            
        return w2.Substring(w2.Length - w1.Length) == w1;
             
    if (w2.Length < 3)            
        return w1.Substring(w1.Length - w2.Length) == w2;

    return w1.Substring(w1.Length - 3) == w2.Substring(w2.Length - 3);
}
 static bool Rhyme(string w1, string w2){
    if(w1.Length>2&&w2.Length>2){
        return w1.Substring(w1.Length-3)==w2.Substring(w2.Length-3);
    }
    if(w1.Length< 3&&w1.Length< w2.Length){
        return w1==w2.Substring(w2.Length-w1.Length);
    }
    return w2==w1.Substring(w1.Length-w2.Length);
}
 static bool Rhyme(string w1, string w2)
        {
            string last3one= last(w1);
            string last3two= last(w2);
            if ((last3one.Length != 3 || last3two.Length != 3) || (last3one.Length != 3 && last3two.Length != 3))
            {
                string over;
                string less;
                if (last3one.Length > last3two.Length) {
                    over = last3one;
                    less = last3two;
                } else {
                    over = last3two;
                    less = last3one;
                }
                while(over.Length > less.Length)
                {
                    over= over.Substring(1);
                }
                int t= String.Compare(over, less);
                if (t == 0) return true;
                else return false;
            }
            int r =String.Compare(last3one, last3two);
            if(r==0)
            {
                return true;
            }
            else
            {
                return false;
            }
            static string last(string word)
            {
                string last3;
                if (word.Length > 3)
                {
                   last3 = word.Substring(word.Length - 3);
                //} if else (word.Length == 3){
                 //   last3 = word.Substring(word.Length - );
                }
                else 
                {
                    last3 = word;
                }
                return last3;
            }
           




        }
 static bool Rhyme(string w1, string w2)
{
    if (w1.Length >= 3 && w2.Length >= 3)
    {
        string EndingOfStr1 = w1.Substring(w1.Length - 3, 3);
        string EndingOfStr2 = w2.Substring(w2.Length - 3, 3);
        return EndingOfStr1 == EndingOfStr2;
    }
    else if (w1.Length < 3 || w2.Length < 3)
    {
        if (w1.Length < 3 && w2.Length < 3)
            return w1 == w2;
        else if (w1.Length >= 3 && w2.Length < 3)
        {
            string EndingOfStr1 = w1.Substring(w1.Length - w2.Length, w2.Length);
            return EndingOfStr1 == w2;
        }
        else if (w1.Length < 3 && w2.Length >= 3)
        {
            string EndingOfStr2 = w2.Substring(w2.Length - w1.Length, w1.Length);
            return w1 == EndingOfStr2;
        }
    }
    return false;
}
 static bool Rhyme(string w1, string w2)
{
    if(w1.Length < 3 || w2.Length < 3)
    {
        return true;
    }
    if(w1.Substring(w1.Length-3) == w2.Substring(w2.Length-3))
    {
        return true;
    }
    else
    {
        return false;
    }
}
static bool Rhyme(string w1, string w2) {
    int l = w1.Length > w2.Length ? w2.Length : w1.Length;
    l = l > 3 ? 3 : l;
    for(int i = 1; i <= l; i++) {
        if(w1[w1.Length-i] != w2[w2.Length-i]) return false;
    }
    return true;
}
 static bool Rhyme(string w1, string w2) 
{
    int min = Math.Min(w1.Length, w2.Length);
    int compare = Math.Min(3, min);
    return w1.Substring(w1.Length - compare) == w2.Substring(w2.Length - compare);
}
 static bool Rhyme(string w1, string w2)
{
    if(w1.Length < 3 || w2.Length < 3) return true;
    int c1 = w1.Length - 1, c2 = w2.Length - 1, count = 0;
    while(count < 3)
    {
        if(w1[c1] != w2[c2])
        {
            return false;
        }
        c1--;
        c2--;
        count++;
    }
    return true;
}
 static bool Rhyme(string w1, string w2)
{
    bool k = true;

    if (w1.Length >= 3 && w2.Length >= 3)
    {
        for (int i = w1.Length - 3; i < w1.Length;)
        {
            for (int j = w2.Length - 3; j < w2.Length; j++)
            {
                if (w1[i] != w2[j])
                {
                    k = false;
                }
                i++;
            }
        }
    }
    else if (w1.Length == 2 || w2.Length == 2)
    {
        if (w1[w1.Length - 1] != w2[w2.Length - 1] || w1[w1.Length - 2] != w2[w2.Length - 2])
        {
            k = false;
        }
    }
    else if (w1.Length == 1 || w2.Length == 1)
    {
        if (w1[w1.Length - 1] != w2[w2.Length - 1])
        {
            k = false;
        }
    }
    return k;
}
 static bool Rhyme(string w1, string w2)
{
  if (w1.Length < 4 || w2.Length < 4)
  {
      int index = 1;
      string end1 = "";
      string end2 = "";
      if (w1.Length > w2.Length)
        {
            while (index <= w2.Length)
            {
                end1 += w1[w1.Length - index];
                end2 += w2[w2.Length - index];
                index++;
            }
        }
        else
        {
            while (index <= w1.Length)
            {
            end1 += w1[w1.Length - index];
            end2 += w2[w2.Length - index];
            index++;
            }
        }
        return end1 == end2;
    }
    else
    {
        return w1[^3] + w1[^2] + w1[^3] == w2[^3] + w2[^2] + w2[^3];
    }
}
 static bool Rhyme(string w1, string w2)
    {
        if (w1.Length < 3)
        {
            return w1.Equals(w2.Substring(w2.Length - w1.Length));
        }
        else if (w2.Length < 3)
        {
            return w2.Equals(w1.Substring(w1.Length - w2.Length));
        }
        else
        {
            return w1.Substring(w1.Length - 3).Equals(w2.Substring(w2.Length - 3)); 
        }
    }
 static bool Rhyme(string w1, string w2)
{
    if(w1.Length < 3 || w2.Length < 3)
    {
        for(int i = 0; i < (w1.Length < 3 ? w1.Length : w2.Length); i++)
        {
            if(w1[w1.Length - 1 - i] != w2[w2.Length - 1 - i])
            {
                return false;
            }
        }
        return true;
    }
    else
    {
        for(int i = 0; i < 3; i++)
        {
            if(w1[w1.Length - 1 - i] != w2[w2.Length - 1 - i])
            {
                return false;
            }
        }
        return true;
    }
}
 static bool Rhyme(string w1, string w2) 
{
    if (w1.Length < 3 || w2.Length < 3) return true;
    
    else if (w1 == w2) return true;
    
    string sub1 = w1.Substring(w1.Length-3);
    string sub2 = w2.Substring(w2.Length-3);
    
    if (sub1 == sub2) return true;
    
    else return false;
}
 static bool Rhyme(string w1, string w2)
{
    bool result = false;
    if (w1.Length <= 3 || w2.Length <= 3)
    {
        if (w1.EndsWith(w2) || w2.EndsWith(w1))
        {
            result = true;
        }
    }
    else 
    {
        if (w1.Substring(w1.Length - 3, 3) == w2.Substring(w2.Length - 3, 3))
        {
            result = true;
        }
    }
    return result;
}
 static bool Rhyme(string w1, string w2)
{
            int lengt = Math.Min(w1.Length, w2.Length);
            if (w1.Length <= 3 || w2.Length <= 3)
            {
                for (int i = 1; i <= lengt; i++)
                {
                    if (w1[w1.Length - i] != w2[w2.Length - i])
                    {
                        return false;
                    }
                }
                return true;
            }
            return w1.Substring(w1.Length - 3,3) == (w2.Substring(w2.Length - 3,3));
        }
 static bool Rhyme(string w1, string w2)
{
    w1 = new String(w1.Reverse().ToArray());
    w2 = new String(w2.Reverse().ToArray());
    int counter = 0;
    for(int i = 0; i < (w1.Length > w2.Length ? w2.Length : w2.Length); i++)
    {
        if(w1[i] != w2[i])  break;
            counter++;
    }
    if(counter >= 3 || counter == w1.Length || counter == w2.Length) return true;
    return false;
}
 static bool Rhyme(string w1, string w2) {
    if (w1.Length < 3) {
        return w2.Substring(w2.Length - w1.Length) == w1;
    }
    
    if (w2.Length < 3) {
        return w1.Substring(w1.Length - w2.Length) == w2;
    }
    
    return w1.Substring(w1.Length - 3) == w2.Substring(w2.Length - 3);
}
 static bool Rhyme(string w1, string w2)
{

    if (w1.Length >= 3 && w2.Length >= 3)
    {

        if (w1.Substring(w1.Length - 3) == w2.Substring(w2.Length - 3))
        {
            return true;
        }

    }
    else
    {
        if (w1.LastIndexOf(w2) == w1.Length - w2.Length || w2.LastIndexOf(w1) == w2.Length - w1.Length)
        {
            return true;
        }
    }

    return false;
}
 static bool Rhyme(string w1, string w2)
{
    if (w1.Length < 3 || w2.Length < 3)
    {
        return true;
    }
    
    string end1 = w1.Substring(w1.Length - 3);
    string end2 = w2.Substring(w2.Length - 3);
    
    return end1 == end2;
}
 static bool Rhyme(string w1, string w2){
    int minLength = Math.Min(w1.Length, w2.Length);
    int matchLength = Math.Min(3, minLength);

    for (int i = 1; i <= matchLength; i++)
    {
        if (w1[w1.Length - i] != w2[w2.Length - i])
            return false;
    }

    return true;
}
 static bool Rhyme(string w1, string w2)
{
    if (string.Compare(w2, w1, true) == 0)
    {
        return true;
    }
    else if( w1.Length< 3 || w2.Length < 3){
        return true;
    }
    else if(w1.Substring(w1.Length-3) == w2.Substring(w2.Length-3))
    {
    return true;
    }
    else
    {
        return false; 
    }
}
 static bool Rhyme(string w1, string w2)
{
            int lengt = Math.Min(w1.Length, w2.Length);
            if (w1.Length <= 3 || w2.Length <= 3)
            {
                for (int i = 1; i <= lengt; i++)
                {
                    if (w1[w1.Length - i] != w2[w2.Length - i])
                    {
                        return false;
                    }
                }
                return true;
            }
            return w1.Substring(w1.Length - 3,3) == (w2.Substring(w2.Length - 3,3));
        }
 static bool Rhyme(string w1, string w2)
{
    bool t = true;
    if (w1.Length < 3)
    {
        for (int i = 0; i < w1.Length; i++)
        {
            if (w1[i] != w2[w2.Length - w1.Length + i])
                t = false;
        }
    }
    if (w2.Length < 3)
    {
        for (int i = 0; i < w2.Length; i++)
        {
            if (w2[i] != w1[w1.Length - w2.Length + i])
                t = false;
        }
    }
    if(w1.Length > 2 && w2.Length > 2)
    for (int i = 3; i >= 1; i--)
    {
        if (w1[w1.Length - i] != w2[w2.Length - i])
            t = false;
    }
    return t;
}
 public static bool Rhyme(string word1, string word2)
{
    int length = Math.Min(3, Math.Min(word1.Length, word2.Length));
    string suffix1 = word1.Substring(word1.Length - length);
    string suffix2 = word2.Substring(word2.Length - length);
    return suffix1 == suffix2;
}
 static bool Rhyme(string w1, string w2)
{
    if(w1.Length < 3 || w2.Length < 3)
    {
        for(int i = 0; i < (w1.Length < 3 ? w1.Length : w2.Length); i++)
        {
            if(w1[w1.Length - 1 - i] != w2[w2.Length - 1 - i])
            {
                return false;
            }
        }
        return true;
    }
    else
    {
        for(int i = 0; i < 3; i++)
        {
            if(w1[w1.Length - 1 - i] != w2[w2.Length - 1 - i])
            {
                return false;
            }
        }
        return true;
    }
}
 static bool Rhyme(string w1, string w2){
    if(w1.Length < 3)
    {
        if (w2.IndexOf(w1)>0) { return true; }
    }else if(w2.Length < 3)
    {
        if (w1.IndexOf(w2) > 0) { return true; }
    }else if(w1.Substring(w1.Length-3) == w2.Substring(w2.Length - 3))
    {
        return true;
    }
    return false;
}
 static bool Rhyme(string w1, string w2)
{
    bool r = true;
    if (w1.Length < 3)
    {
        w2 = w2.Substring(w2.Length - w1.Length, w1.Length);
        if (w1 != w2)
            r = false;
    }
    else if(w2.Length < 3)
    {
        w1 = w1.Substring(w1.Length - w2.Length, w2.Length);
        if (w1 != w2)
            r = false;
    }
    else for (int i = 1; i < 4; i++)
    {
        if (w1[w1.Length - i] != w2[w2.Length - i])
            r = false;
    }
    return r;
}
 static bool Rhyme(string w1, string w2)
{
    if(w1.Length < 3 || w2.Length < 3)
    {
        for(int i = 0; i < (w1.Length < 3 ? w1.Length : w2.Length); i++)
        {
            if(w1[w1.Length - 1 - i] != w2[w2.Length - 1 - i])
            {
                return false;
            }
        }
        return true;
    }
    else
    {
        for(int i = 0; i < 3; i++)
        {
            if(w1[w1.Length - 1 - i] != w2[w2.Length - 1 - i])
            {
                return false;
            }
        }
        return true;
    }
}
 static bool Rhyme(string w1, string w2) {
    if (string.Compare(w2, w1, true) == 0)
        return true;
    else if (w1.Length < 3 || w2.Length < 3) 
        return true;
    else if (w1.Substring(w1.Length - 3) == w2.Substring (w2.Length - 3)) 
        return true;
    return false;
}
 static bool Rhyme(string w1, string w2)
{
    int a = 3;
    if (w1.Length < a) a = w1.Length;
    if (w2.Length < a) a = w2.Length;
    return w1.Substring(w1.Length - a) == w2.Substring(w2.Length - a);
}
 static bool Rhyme(string w1, string w2){
if(w1.Length < 3 && w1.Length <= w2.Length) return w1 == w2.Substring(w2.Length-w1.Length);
if(w2.Length < 3 && w1.Length >= w2.Length) return w2 == w1.Substring(w1.Length-w2.Length);
return w2.Substring(w2.Length-3) == w1.Substring(w1.Length-3);
}
 static bool Rhyme(string w1, string w2)
{
    if(w1.Length < 3){
        w2 = w2.Substring(w2.Length-w1.Length);
        return (w2==w1);
    } 
    else if(w2.Length < 3){
        w1 = w1.Substring(w1.Length-w2.Length);
        return (w2==w1);
    }
    else{
    w1 = w1.Substring(w1.Length-3);
    w2 = w2.Substring(w2.Length-3);
    return (w2==w1);
    }
    
}
 static bool Rhyme(string word1, string word2)
{
    if (word1.Length < 3 || word2.Length < 3) 
    {
        return true;
    }

    string suffix1 = word1.Substring(word1.Length - 3); 
    string suffix2 = word2.Substring(word2.Length - 3); 

    return suffix1 == suffix2;
}
 static bool Rhyme(string w1, string w2)
{
    if (w1 == w2)
{
return true;
}
    if (w1.Length < 3) 
        {
return true;
}
if (w2.Length < 3) 
        {
return true;
}
if (w1.Substring(w1.Length - 3) == w2.Substring(w2.Length - 3))
{
return true;
}
else 
{
return false;
}
}
 static bool Rhyme(string w1, string w2)
        {
            bool result = false;
            if ((w1.Length > 3 && w2.Length > 3)&&(w1[w1.Length-1] == w2[w2.Length - 1] && w1[w1.Length - 2] == w2[w2.Length - 2] && w1[w1.Length - 3] == w2[w2.Length - 3]))
            {
                result = true;
            }
            else if ((w1.Length == 2 || w2.Length == 2) && (w1[w1.Length - 1] == w2[w2.Length - 1] && w1[w1.Length - 2] == w2[w2.Length - 2]))
            {
                result = true;
            }
            else if ((w1.Length == 1 || w2.Length == 1) && (w1[w1.Length - 1] == w2[w2.Length - 1]))
            {
                result = true;
            }
            return result;
        }