Skip to main content
deleted 254 characters in body
Source Link
Gilad
  • 5.3k
  • 5
  • 37
  • 63
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    public class ReverseString
    {
        public ReverseString()
        {
            string str = "Gilad";
            string res = Reverse(str);
          
            List<string> wordsList = new List<string>();
            wordsList.Add("batel");            
            wordsList.Add("Gilad");
            wordsList.Add("daliG");
            wordsList.Add("enon");
            wordsList.Add("none");
            wordsList.Add("letab");
            var pairs = PairAnagramWords(wordsList);
        }

        public string Reverse(string str)
        {
            StringBuilder s = new StringBuilder();
            for (int i = str.Length - 1; i >= 0; i--)
            { 
                s.Append(str[i]);
            }
            return s.ToString();
        }

        Dictionary<string, string> PairAnagramWords(List<string> wordsList)
        {
            wordsList.Sort();
            Dictionary<string, string> res = new Dictionary<string, string>();
            foreach (var item in wordsList)
            {
                if (res.ContainsValue(item))
                {
                    continue;
                }
                
                foreach (var item2 in wordsList)
                {
                    if (item == item2 || item.Length != item2.Length)
                    {
                        continue;
                    }
                    var reversed = Reverse(item2);
                    int i;
                    for (i = 0; i < item.Length; i++)
                    {
                        if (item[i] != reversed[i])
                        {
                            break;
                        }
                    }
                    if (i == item.Length)
                    {
                        res.Add(item, item2);
                    }
                }
            }
            return res;
        }
    }
}

}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    public class ReverseString
    {
        public ReverseString()
        {
            string str = "Gilad";
            string res = Reverse(str);
          
            List<string> wordsList = new List<string>();
            wordsList.Add("batel");            
            wordsList.Add("Gilad");
            wordsList.Add("daliG");
            wordsList.Add("enon");
            wordsList.Add("none");
            wordsList.Add("letab");
            var pairs = PairAnagramWords(wordsList);
        }

        public string Reverse(string str)
        {
            StringBuilder s = new StringBuilder();
            for (int i = str.Length - 1; i >= 0; i--)
            { 
                s.Append(str[i]);
            }
            return s.ToString();
        }

        Dictionary<string, string> PairAnagramWords(List<string> wordsList)
        {
            wordsList.Sort();
            Dictionary<string, string> res = new Dictionary<string, string>();
            foreach (var item in wordsList)
            {
                if (res.ContainsValue(item))
                {
                    continue;
                }
                
                foreach (var item2 in wordsList)
                {
                    if (item == item2 || item.Length != item2.Length)
                    {
                        continue;
                    }
                    var reversed = Reverse(item2);
                    int i;
                    for (i = 0; i < item.Length; i++)
                    {
                        if (item[i] != reversed[i])
                        {
                            break;
                        }
                    }
                    if (i == item.Length)
                    {
                        res.Add(item, item2);
                    }
                }
            }
            return res;
        }
    }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
public class ReverseString
{
    public ReverseString()
    {
        string str = "Gilad";
        string res = Reverse(str);
      
        List<string> wordsList = new List<string>();
        wordsList.Add("batel");            
        wordsList.Add("Gilad");
        wordsList.Add("daliG");
        wordsList.Add("enon");
        wordsList.Add("none");
        wordsList.Add("letab");
        var pairs = PairAnagramWords(wordsList);
    }

    public string Reverse(string str)
    {
        StringBuilder s = new StringBuilder();
        for (int i = str.Length - 1; i >= 0; i--)
        { 
            s.Append(str[i]);
        }
        return s.ToString();
    }

    Dictionary<string, string> PairAnagramWords(List<string> wordsList)
    {
        wordsList.Sort();
        Dictionary<string, string> res = new Dictionary<string, string>();
        foreach (var item in wordsList)
        {
            if (res.ContainsValue(item))
            {
                continue;
            }
            
            foreach (var item2 in wordsList)
            {
                if (item == item2 || item.Length != item2.Length)
                {
                    continue;
                }
                var reversed = Reverse(item2);
                int i;
                for (i = 0; i < item.Length; i++)
                {
                    if (item[i] != reversed[i])
                    {
                        break;
                    }
                }
                if (i == item.Length)
                {
                    res.Add(item, item2);
                }
            }
        }
        return res;
    }
}

}

Rollback to Revision 5
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237

String reverse, and pairing reversed words and pairing anagrams

using System;

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace ConsoleApplication2 { public class ReverseString { public ReverseString() { string str = "Gilad"; string res = Reverse(str);

        List<string> wordsList = new List<string>();
       using wordsListSystem.Add("batel");            
        wordsListCollections.Add("Gilad");Generic;
       using wordsListSystem.Add("daliG");Linq;
       using wordsListSystem.Add("enon");Text;
       using wordsListSystem.Add("none");
        wordsListThreading.Add("letab");Tasks;

namespace ConsoleApplication2
{
    public class ReverseString
 Dictionary<string,string> pairs = PairPolnidromWords(wordsList);
{
        List<string> anagarms = newpublic List<string>ReverseString();
        anagarms.Add("Gilad");{
        anagarms.Add("dilaG");
     string str = anagarms.Add("bat");"Gilad";
        anagarms.Add("but");
       string pairsres = PairAnagramsReverse(anagarmsstr);
    }

    public string Reverse(string str)
    {
        StringBuilderList<string> swordsList = new StringBuilderList<string>();
        for (int i = strwordsList.Length - 1; iAdd("batel"); >= 0; i--)
        { 
            swordsList.AppendAdd(str[i]"Gilad");
        }
        return swordsList.ToStringAdd("daliG");
    }

    Dictionary<string, string> PairPolnidromWords(List<string> wordsList)
    {
        wordsList.SortAdd("enon");
        Dictionary<string, string> res = new Dictionary<string, string>wordsList.Add("none");
        foreach (var item in wordsList)
        {
            if (res.ContainsValueAdd(item)"letab")
            {;
             var pairs = continue;PairAnagramWords(wordsList);
            }
            
           public foreachstring Reverse(var item2 instring wordsListstr)
            {
             StringBuilder s = ifnew StringBuilder(item == item2 || item.Length != item2.Length);
                {
          for (int i = str.Length - 1; i >= 0; continue;i--)
               { }
                var reversed = Reverses.Append(item2str[i]);
                int i;}
                for (i = 0; i <return items.Length; i++ToString();
                {}
            
        Dictionary<string, ifstring> PairAnagramWords(item[i] !=List<string> reversed[i]wordsList)
        {
            {wordsList.Sort();
                  Dictionary<string, string> res = new Dictionary<string, break;string>();
                foreach (var item in }wordsList)
                }{
                if (i == itemres.LengthContainsValue(item))
                {
                    res.Add(item, item2);continue;
                }
            }
        }
        return res;
    }

   foreach Dictionary<string,(var string>item2 PairAnagrams(List<string>in wordsList)
    {
        Dictionary<string, string> dictionary = new Dictionary<string, string>();{
        foreach(var item in wordsList)
        {
      if (item == item2 || item.Length if!= (dictionaryitem2.ContainsValue(item)Length)
            {
        {
        continue;
            }
    continue;
        foreach(var item2 in wordsList)
         }
   {
                if(item.Length !=var item2.Lengthreversed ||= item.EqualsReverse(item2));
                {
                   int continue;i;
                }

             for (i = var0; sortedWord1i =< item.ToArray(Length; i++);
                Array.Sort(sortedWord1);
       {
         var sortedWord2 = item2.ToArray();
             if (item[i] != Array.Sort<char>(sortedWord2reversed[i]);
                int i;
        {
        for (i = 0; i < sortedWord2.Length; i++)
                {break;
                    if (sortedWord2[i] != sortedWord1[i]) }
                    {}
                     if (i == break;item.Length)
                    }{
                }
                ifres.Add(i ==item, sortedWord1.Lengthitem2)
                {;
                    dictionary.Add(item, item2);}
                }
            }
        }
    return res;
   return dictionary;
    }
    }
}

}

String reverse, pairing reversed words and pairing anagrams

using System;

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace ConsoleApplication2 { public class ReverseString { public ReverseString() { string str = "Gilad"; string res = Reverse(str);

        List<string> wordsList = new List<string>();
        wordsList.Add("batel");            
        wordsList.Add("Gilad");
        wordsList.Add("daliG");
        wordsList.Add("enon");
        wordsList.Add("none");
        wordsList.Add("letab");
        Dictionary<string,string> pairs = PairPolnidromWords(wordsList);

        List<string> anagarms = new List<string>();
        anagarms.Add("Gilad");
        anagarms.Add("dilaG");
        anagarms.Add("bat");
        anagarms.Add("but");
        pairs = PairAnagrams(anagarms);
    }

    public string Reverse(string str)
    {
        StringBuilder s = new StringBuilder();
        for (int i = str.Length - 1; i >= 0; i--)
        { 
            s.Append(str[i]);
        }
        return s.ToString();
    }

    Dictionary<string, string> PairPolnidromWords(List<string> wordsList)
    {
        wordsList.Sort();
        Dictionary<string, string> res = new Dictionary<string, string>();
        foreach (var item in wordsList)
        {
            if (res.ContainsValue(item))
            {
                continue;
            }
            
            foreach (var item2 in wordsList)
            {
                if (item == item2 || item.Length != item2.Length)
                {
                    continue;
                }
                var reversed = Reverse(item2);
                int i;
                for (i = 0; i < item.Length; i++)
                {
                    if (item[i] != reversed[i])
                    {
                        break;
                    }
                }
                if (i == item.Length)
                {
                    res.Add(item, item2);
                }
            }
        }
        return res;
    }

    Dictionary<string, string> PairAnagrams(List<string> wordsList)
    {
        Dictionary<string, string> dictionary = new Dictionary<string, string>();
        foreach(var item in wordsList)
        {
            if (dictionary.ContainsValue(item))
            {
                continue;
            }
            foreach(var item2 in wordsList)
            {
                if(item.Length != item2.Length || item.Equals(item2))
                {
                    continue;
                }

                var sortedWord1 = item.ToArray();
                Array.Sort(sortedWord1);
                var sortedWord2 = item2.ToArray();
                Array.Sort<char>(sortedWord2);
                int i;
                for (i = 0; i < sortedWord2.Length; i++)
                {
                    if (sortedWord2[i] != sortedWord1[i])
                    {
                        break;
                    }
                }
                if(i == sortedWord1.Length)
                {
                    dictionary.Add(item, item2);
                }
            }
        }
        return dictionary;
    }
    
}

}

String reverse and pairing reversed words

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    public class ReverseString
    {
        public ReverseString()
        {
            string str = "Gilad";
            string res = Reverse(str);
          
            List<string> wordsList = new List<string>();
            wordsList.Add("batel");            
            wordsList.Add("Gilad");
            wordsList.Add("daliG");
            wordsList.Add("enon");
            wordsList.Add("none");
            wordsList.Add("letab");
            var pairs = PairAnagramWords(wordsList);
        }

        public string Reverse(string str)
        {
            StringBuilder s = new StringBuilder();
            for (int i = str.Length - 1; i >= 0; i--)
            { 
                s.Append(str[i]);
            }
            return s.ToString();
        }
 
        Dictionary<string, string> PairAnagramWords(List<string> wordsList)
        {
            wordsList.Sort();
            Dictionary<string, string> res = new Dictionary<string, string>();
            foreach (var item in wordsList)
            {
                if (res.ContainsValue(item))
                {
                    continue;
                }
                
                foreach (var item2 in wordsList)
                {
                    if (item == item2 || item.Length != item2.Length)
                    {
                        continue;
                    }
                    var reversed = Reverse(item2);
                    int i;
                    for (i = 0; i < item.Length; i++)
                    {
                        if (item[i] != reversed[i])
                        {
                            break;
                        }
                    }
                    if (i == item.Length)
                    {
                        res.Add(item, item2);
                    }
                }
            }
            return res;
        }
    }
}
added 1321 characters in body; edited title
Source Link
Gilad
  • 5.3k
  • 5
  • 37
  • 63

String reverse and, pairing reversed words and pairing anagrams

using System;
using

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace ConsoleApplication2 { public class ReverseString { public ReverseString() { string str = "Gilad"; string res = Reverse(str);

 System.Collections.Generic;       List<string> wordsList = new List<string>();
using System       wordsList.Linq;Add("batel");            
using System       wordsList.Text;Add("Gilad");
using System.Threading       wordsList.Tasks;
Add("daliG");
namespace ConsoleApplication2       wordsList.Add("enon");
{        wordsList.Add("none");
    public class ReverseString  wordsList.Add("letab");
    {    Dictionary<string,string> pairs = PairPolnidromWords(wordsList);

        publicList<string> ReverseStringanagarms = new List<string>();
        {anagarms.Add("Gilad");
        anagarms.Add("dilaG");
    string str = "Gilad"; anagarms.Add("bat");
        anagarms.Add("but");
     string res  pairs = ReversePairAnagrams(stranagarms);
    }

    public string Reverse(string str)
    {
        List<string>StringBuilder wordsLists = new List<string>StringBuilder();
        for (int i = wordsListstr.Add("batel");Length - 1; i >= 0; i--)
        { 
            wordsLists.AddAppend("Gilad"str[i]);
        }
    wordsList    return s.AddToString("daliG");
    }

    Dictionary<string, string> PairPolnidromWords(List<string> wordsList)
    {
        wordsList.AddSort("enon");
        Dictionary<string, string> res = wordsList.Addnew Dictionary<string, string>("none");
        foreach (var item in wordsList.Add("letab");
        {
     var pairs = PairAnagramWords    if (wordsListres.ContainsValue(item);)
        }
    {
        public string Reverse(string str)     continue;
        {    }
            StringBuilder 
 s = new StringBuilder        foreach (var item2 in wordsList);
            for{
                if (intitem i== =item2 str|| item.Length -!= 1;item2.Length)
 i >= 0; i--)
            { 
                s.Append(str[i]);    continue;
                }
            return s.ToString   var reversed = Reverse(item2);
        }
        int i;
        Dictionary<string, string> PairAnagramWords      for (List<string>i wordsList= 0; i < item.Length; i++)
                {
            wordsList.Sort        if (item[i] != reversed[i]);
            Dictionary<string, string> res = new Dictionary<string, string>();  {
            foreach (var item in wordsList)        break;
            {        }
                }
                if (res.ContainsValue(i == item).Length)
                {
                    continue;res.Add(item, item2);
                }
            }
        }
        return res;
    }

   foreach (varDictionary<string, item2string> inPairAnagrams(List<string> wordsList)
    {
        Dictionary<string, string> dictionary = {new Dictionary<string, string>();
        foreach(var item in wordsList)
        {
 if (item == item2 || item.Length != item2    if (dictionary.LengthContainsValue(item))
            {
        {
        continue;
            }
    continue;
        foreach(var item2 in wordsList)
         }
   {
                if(item.Length var!= reverseditem2.Length =|| Reverseitem.Equals(item2);)
                {
    int i;               continue;
                }

    for (i = 0; i <       var sortedWord1 = item.Length; i++ToArray();
                Array.Sort(sortedWord1);
    {
            var sortedWord2 = item2.ToArray();
         if (item[i] != reversed[i]    Array.Sort<char>(sortedWord2);
                int i;
       {
         for (i = 0; i < sortedWord2.Length; i++)
            break;
    {
                    }if (sortedWord2[i] != sortedWord1[i])
                    }{
                    if (i == item.Length) break;
                    {}
                }
        res.Add        if(item,i item2== sortedWord1.Length);
                {
    }                dictionary.Add(item, item2);
                }
            }
        }
    return res;
   return dictionary;
    }
    }
}

}

String reverse and pairing reversed words

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication2
{
    public class ReverseString
    {
        public ReverseString()
        {
            string str = "Gilad";
            string res = Reverse(str);
          
            List<string> wordsList = new List<string>();
            wordsList.Add("batel");            
            wordsList.Add("Gilad");
            wordsList.Add("daliG");
            wordsList.Add("enon");
            wordsList.Add("none");
            wordsList.Add("letab");
            var pairs = PairAnagramWords(wordsList);
        }

        public string Reverse(string str)
        {
            StringBuilder s = new StringBuilder();
            for (int i = str.Length - 1; i >= 0; i--)
            { 
                s.Append(str[i]);
            }
            return s.ToString();
        }

        Dictionary<string, string> PairAnagramWords(List<string> wordsList)
        {
            wordsList.Sort();
            Dictionary<string, string> res = new Dictionary<string, string>();
            foreach (var item in wordsList)
            {
                if (res.ContainsValue(item))
                {
                    continue;
                }
                
                foreach (var item2 in wordsList)
                {
                    if (item == item2 || item.Length != item2.Length)
                    {
                        continue;
                    }
                    var reversed = Reverse(item2);
                    int i;
                    for (i = 0; i < item.Length; i++)
                    {
                        if (item[i] != reversed[i])
                        {
                            break;
                        }
                    }
                    if (i == item.Length)
                    {
                        res.Add(item, item2);
                    }
                }
            }
            return res;
        }
    }
}

String reverse, pairing reversed words and pairing anagrams

using System;

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace ConsoleApplication2 { public class ReverseString { public ReverseString() { string str = "Gilad"; string res = Reverse(str);

        List<string> wordsList = new List<string>();
        wordsList.Add("batel");            
        wordsList.Add("Gilad");
        wordsList.Add("daliG");
        wordsList.Add("enon");
        wordsList.Add("none");
        wordsList.Add("letab");
        Dictionary<string,string> pairs = PairPolnidromWords(wordsList);

        List<string> anagarms = new List<string>();
        anagarms.Add("Gilad");
        anagarms.Add("dilaG");
        anagarms.Add("bat");
        anagarms.Add("but");
        pairs = PairAnagrams(anagarms);
    }

    public string Reverse(string str)
    {
        StringBuilder s = new StringBuilder();
        for (int i = str.Length - 1; i >= 0; i--)
        { 
            s.Append(str[i]);
        }
        return s.ToString();
    }

    Dictionary<string, string> PairPolnidromWords(List<string> wordsList)
    {
        wordsList.Sort();
        Dictionary<string, string> res = new Dictionary<string, string>();
        foreach (var item in wordsList)
        {
            if (res.ContainsValue(item))
            {
                continue;
            }
             
            foreach (var item2 in wordsList)
            {
                if (item == item2 || item.Length != item2.Length)
                {
                    continue;
                }
                var reversed = Reverse(item2);
                int i;
                for (i = 0; i < item.Length; i++)
                {
                    if (item[i] != reversed[i])
                    {
                        break;
                    }
                }
                if (i == item.Length)
                {
                    res.Add(item, item2);
                }
            }
        }
        return res;
    }

    Dictionary<string, string> PairAnagrams(List<string> wordsList)
    {
        Dictionary<string, string> dictionary = new Dictionary<string, string>();
        foreach(var item in wordsList)
        {
            if (dictionary.ContainsValue(item))
            {
                continue;
            }
            foreach(var item2 in wordsList)
            {
                if(item.Length != item2.Length || item.Equals(item2))
                {
                    continue;
                }

                var sortedWord1 = item.ToArray();
                Array.Sort(sortedWord1);
                var sortedWord2 = item2.ToArray();
                Array.Sort<char>(sortedWord2);
                int i;
                for (i = 0; i < sortedWord2.Length; i++)
                {
                    if (sortedWord2[i] != sortedWord1[i])
                    {
                        break;
                    }
                }
                if(i == sortedWord1.Length)
                {
                    dictionary.Add(item, item2);
                }
            }
        }
        return dictionary;
    }
    
}

}

edited title
Link
Gilad
  • 5.3k
  • 5
  • 37
  • 63
Loading
angrams -> anagrams
Source Link
rolfl
  • 97.5k
  • 17
  • 218
  • 418
Loading
added 35 characters in body
Source Link
Gilad
  • 5.3k
  • 5
  • 37
  • 63
Loading
added 12 characters in body; edited title
Source Link
Jamal
  • 34.9k
  • 13
  • 133
  • 237
Loading
Source Link
Gilad
  • 5.3k
  • 5
  • 37
  • 63
Loading