예제 #1
0
 /// <summary>
 /// Check if words are anagram
 /// </summary>
 /// <returns></returns>
 public bool AreAnagram()
 {
     if (IsValid)
     {
         // Sort first word
         // Sort second word
         // Apply sequence equal
         // return result
         return(FirstWord.ToArray().OrderBy(A => A).SequenceEqual(SecondWord.ToArray().OrderBy(B => B)));
     }
     else
     {
         return(false);
     }
 }
예제 #2
0
        static void Main(string[] args)
        {
            string FirstWord, SecondWord;
            bool   result;

            Console.WriteLine("Escriba la primera palabra");
            FirstWord = Console.ReadLine();
            Console.WriteLine("Escriba la segunda palabra");
            SecondWord = Console.ReadLine();

            FirstWord.ToLower();
            SecondWord.ToLower();

            char[] FirstWordArr  = FirstWord.ToCharArray();
            char[] SecondWordArr = SecondWord.ToCharArray();

            if (FirstWordArr.Length != FirstWordArr.Length)
            {
                result = false;
            }
            else
            {
                Array.Sort(FirstWordArr);
                Array.Sort(SecondWordArr);

                if (FirstWordArr == SecondWordArr)
                {
                    result = true;
                }
                else
                {
                    result = false;
                }
            }

            if (result)
            {
                Console.WriteLine("Son anagrama");
            }
            else
            {
                Console.WriteLine("No son anagramas");
            }
        }
예제 #3
0
        /// <summary>
        /// Describes branck instructions (BEQ and BGT).
        /// </summary>
        /// <param name="isBeq">If true describes BEQ, otherwise BGT.</param>
        protected void Branch(bool isBeq)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(isBeq ? "BEQ " : "BGT ");

            string v1 = Instruction[1] == 0 ? "#0" : FormatAddress(Instruction[1]);

            sb.Append(v1);
            sb.Append(", ");
            string v2 = Instruction[2] == 0 ? "#0" : FormatAddress(Instruction[2]);

            sb.Append(v2);
            sb.Append(", ");

            string branchAddress;

            WordCount = 1;
            if (Instruction[3] > 7)
            {
                if (Instruction[3] != 0x8)
                {
                    branchAddress = "?";
                }
                else
                {
                    WordCount     = 2;
                    branchAddress = SecondWord.ToString();
                }
            }
            else
            {
                branchAddress = FormatAddress(Instruction[3], true);
            }

            sb.Append(branchAddress);

            DisassembledInstruction = sb.ToString();
        }