From c13f8cfa41ee8cd4f8bd8819aade1962f5efce1b Mon Sep 17 00:00:00 2001 From: diwansimranbanu <72291969+diwansimranbanu@users.noreply.github.com> Date: Sat, 3 Oct 2020 11:01:33 +0530 Subject: [PATCH] added 804.py added 804.py --- 800-900q/804.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 800-900q/804.py diff --git a/800-900q/804.py b/800-900q/804.py new file mode 100644 index 0000000..974a51f --- /dev/null +++ b/800-900q/804.py @@ -0,0 +1,23 @@ +class Solution: + def uniqueMorseRepresentations(self, words: List[str]) -> int: + result = set() + def to_morse(s): + return ''.join(mapp.get(i) for i in s) + + mapp = {'a': '.-', 'b': '-...', 'c': '-.-.', + 'd': '-..', 'e': '.', 'f': '..-.', + 'g': '--.', 'h': '....', 'i': '..', + 'j': '.---', 'k': '-.-', 'l': '.-..', + 'm': '--', 'n': '-.', 'o': '---', + 'p': '.--.', 'q': '--.-', 'r': '.-.', + 's': '...', 't': '-', 'u': '..-', + 'v': '...-', 'w': '.--', 'x': '-..-', + 'y': '-.--', 'z': '--..', + } + + + for word in words: + result.add(to_morse(word)) + + return len(result) +