tanya_zheleva

5

Feb 18th, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Text;
  4. using System.Numerics;
  5.  
  6. namespace ExamPreparation
  7. {
  8.     public sealed class Preparation
  9.     {
  10.         public static void Main()
  11.         {
  12.             string[] input = Console.ReadLine().Split();
  13.             string firstToken = input[0];
  14.             string secondToken = input[1];
  15.  
  16.             bool areMagical = AreExchangeableWords(firstToken, secondToken);
  17.  
  18.             if (areMagical)
  19.             {
  20.                 Console.WriteLine("true");
  21.             }
  22.             else
  23.             {
  24.                 Console.WriteLine("false");
  25.             }
  26.         }
  27.  
  28.         private static bool AreExchangeableWords(string firstToken, string secondToken)
  29.         {
  30.             char[] uniqueFirstTokens = firstToken.Distinct().ToArray();
  31.             char[] uniqueSecondTokens = secondToken.Distinct().ToArray();
  32.  
  33.             if (uniqueFirstTokens.Length == uniqueSecondTokens.Length)
  34.             {
  35.                 return true;
  36.             }
  37.  
  38.             return false;
  39.         }
  40.     }
  41. }
Add Comment
Please, Sign In to add comment