using
System;
using
System.Collections.Generic;
public
class
UniqueMorseCode
{
public
static
int
UniqueMorseRep(
string
[] words)
{
HashSet<
string
> uniqueMorseCodes =
new
HashSet<
string
>();
string
[] morseCodes =
new
string
[] {
".-"
,
"-..."
,
"-.-."
,
"-.."
,
"."
,
"..-."
,
"--."
,
"...."
,
".."
,
".---"
,
"-.-"
,
".-.."
,
"--"
,
"-."
,
"---"
,
".--."
,
"--.-"
,
".-."
,
"..."
,
"-"
,
"..-"
,
"...-"
,
".--"
,
"-..-"
,
"-.--"
,
"--.."
};
foreach
(
string
word
in
words)
{
System.Text.StringBuilder morseCode =
new
System.Text.StringBuilder();
foreach
(
char
c
in
word.ToCharArray())
{
morseCode.Append(morseCodes);
}
uniqueMorseCodes.Add(morseCode.ToString());
}
return
uniqueMorseCodes.Count;
}
public
static
void
Main(
string
[] args)
{
string
[] words = {
"gig"
,
"zeg"
,
"gin"
,
"msn"
};
Console.WriteLine(UniqueMorseRep(words));
}
}