Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Making Anagrams
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; using System.Collections; namespace Rextester { public class Program { private void MyMethod(Dictionary<char,int> myDictionary) { } public static void Main(string[] args) { //Your code goes here string a = Console.ReadLine(); string b = Console.ReadLine(); char[] aO = a.Trim().Replace(" ","").ToLower().ToCharArray(); Array.Sort(aO); char[] bO = b.Trim().Replace(" ","").ToLower().ToCharArray(); Array.Sort(bO); ArrayList aOrignal = new ArrayList(); aOrignal.AddRange(aO); ArrayList bOrignal = new ArrayList(); bOrignal.AddRange(bO); Dictionary<char, int> aDic = new Dictionary<char, int>(); foreach(char item in aOrignal) { if (aDic.ContainsKey(item)) aDic[item]++; else aDic.Add(item, 1); } Dictionary<char, int> bDic = new Dictionary<char, int>(); foreach(char item in bOrignal) { if (bDic.ContainsKey(item)) bDic[item]++; else bDic.Add(item, 1); } ArrayList confirm = new ArrayList(); /* foreach (KeyValuePair<char, int> kvp in aDic.ToList()) { // Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value); if(kvp.Value == 1){ confirm.Add( kvp.Key); // aDic.Remove(kvp.Key); } else{ if(aOrignal.Contains(kvp.Key) && bOrignal.Contains(kvp.Key)){ if(kvp.Value % 2 == 0){ aDic.Remove(kvp.Key); } else{ aDic[kvp.Key] -=2; } } } // Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value); } Console.WriteLine(String.Join(" ",confirm.ToArray()));*/ foreach (KeyValuePair<char, int> kvp in aDic.ToList()) { if(aOrignal.Contains(kvp.Key) && bOrignal.Contains(kvp.Key)){ aDic[kvp.Key] -=1; bDic[kvp.Key] -=1; for(var i=1; i<kvp.Value;i++){ if(aDic.ContainsKey(kvp.Key) && bDic.ContainsKey(kvp.Key)){ if(aDic[kvp.Key] > 0 && bDic[kvp.Key] >0 ){ aDic[kvp.Key] -=1; bDic[kvp.Key] -=1; } } } } // Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value); } int count = 0; foreach (KeyValuePair<char, int> kvp in bDic) { count += kvp.Value; // Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value); } foreach (KeyValuePair<char, int> kvp in aDic) { count += kvp.Value; // Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value); } Console.WriteLine(count); //end } } }
a c c f g i l m m n r s v w x x y y y z b b d e e g h h i j j k l m m m o o p p q r r s t u v w w x
Show compiler warnings
[
-
]
Show input
fork mode
|
history
|
discussion