Is this string a palindrome (in Morse Code)?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite












Challenge



Inspired by this video



As you may know, a palindrome is a word that is spelled the same forward as it is backward. The word "PULP" is not a palindrome, but when translated into Morse Code (with the spacing between letters removed), "PULP" becomes ".--...-.-...--." which is a palindrome. Your task is to write a program or function which takes a string and returns whether that word is a palindrome in International Morse Code.



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: --..


Rules



Input



Input can be taken in any reasonable format. The input string will contain only letters in any case you prefer. The string will not contain spaces, numbers, or punctuation.



Output



Your program should output 1 of 2 constant distinct results based on whether the input is a palindrome, e.g. True/False, 1/0, HOTDOG/NOTHOTDOG



Scoring



This is code-golf so shortest answer in bytes wins. Standard loopholes are forbidden.



Test Cases



Input => Output



"PULP" => True
"RESEARCHER" => True
"HOTDOGS" => True
"" => True
"A" => False
"RACECAR" => False
"PROGRAMMING"=> False
"PUZZLES" => False









share|improve this question























  • related
    – Luis felipe De jesus Munoz
    2 hours ago










  • Only my vote is a hammer, I'd VTC this as a dupe of the challenge Luis linked; the bulk of most solutions is going to be converting the input to Morse code.
    – Shaggy
    2 hours ago














up vote
4
down vote

favorite












Challenge



Inspired by this video



As you may know, a palindrome is a word that is spelled the same forward as it is backward. The word "PULP" is not a palindrome, but when translated into Morse Code (with the spacing between letters removed), "PULP" becomes ".--...-.-...--." which is a palindrome. Your task is to write a program or function which takes a string and returns whether that word is a palindrome in International Morse Code.



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: --..


Rules



Input



Input can be taken in any reasonable format. The input string will contain only letters in any case you prefer. The string will not contain spaces, numbers, or punctuation.



Output



Your program should output 1 of 2 constant distinct results based on whether the input is a palindrome, e.g. True/False, 1/0, HOTDOG/NOTHOTDOG



Scoring



This is code-golf so shortest answer in bytes wins. Standard loopholes are forbidden.



Test Cases



Input => Output



"PULP" => True
"RESEARCHER" => True
"HOTDOGS" => True
"" => True
"A" => False
"RACECAR" => False
"PROGRAMMING"=> False
"PUZZLES" => False









share|improve this question























  • related
    – Luis felipe De jesus Munoz
    2 hours ago










  • Only my vote is a hammer, I'd VTC this as a dupe of the challenge Luis linked; the bulk of most solutions is going to be converting the input to Morse code.
    – Shaggy
    2 hours ago












up vote
4
down vote

favorite









up vote
4
down vote

favorite











Challenge



Inspired by this video



As you may know, a palindrome is a word that is spelled the same forward as it is backward. The word "PULP" is not a palindrome, but when translated into Morse Code (with the spacing between letters removed), "PULP" becomes ".--...-.-...--." which is a palindrome. Your task is to write a program or function which takes a string and returns whether that word is a palindrome in International Morse Code.



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: --..


Rules



Input



Input can be taken in any reasonable format. The input string will contain only letters in any case you prefer. The string will not contain spaces, numbers, or punctuation.



Output



Your program should output 1 of 2 constant distinct results based on whether the input is a palindrome, e.g. True/False, 1/0, HOTDOG/NOTHOTDOG



Scoring



This is code-golf so shortest answer in bytes wins. Standard loopholes are forbidden.



Test Cases



Input => Output



"PULP" => True
"RESEARCHER" => True
"HOTDOGS" => True
"" => True
"A" => False
"RACECAR" => False
"PROGRAMMING"=> False
"PUZZLES" => False









share|improve this question















Challenge



Inspired by this video



As you may know, a palindrome is a word that is spelled the same forward as it is backward. The word "PULP" is not a palindrome, but when translated into Morse Code (with the spacing between letters removed), "PULP" becomes ".--...-.-...--." which is a palindrome. Your task is to write a program or function which takes a string and returns whether that word is a palindrome in International Morse Code.



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: --..


Rules



Input



Input can be taken in any reasonable format. The input string will contain only letters in any case you prefer. The string will not contain spaces, numbers, or punctuation.



Output



Your program should output 1 of 2 constant distinct results based on whether the input is a palindrome, e.g. True/False, 1/0, HOTDOG/NOTHOTDOG



Scoring



This is code-golf so shortest answer in bytes wins. Standard loopholes are forbidden.



Test Cases



Input => Output



"PULP" => True
"RESEARCHER" => True
"HOTDOGS" => True
"" => True
"A" => False
"RACECAR" => False
"PROGRAMMING"=> False
"PUZZLES" => False






code-golf decision-problem






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 1 hour ago

























asked 2 hours ago









Cowabunghole

643315




643315











  • related
    – Luis felipe De jesus Munoz
    2 hours ago










  • Only my vote is a hammer, I'd VTC this as a dupe of the challenge Luis linked; the bulk of most solutions is going to be converting the input to Morse code.
    – Shaggy
    2 hours ago
















  • related
    – Luis felipe De jesus Munoz
    2 hours ago










  • Only my vote is a hammer, I'd VTC this as a dupe of the challenge Luis linked; the bulk of most solutions is going to be converting the input to Morse code.
    – Shaggy
    2 hours ago















related
– Luis felipe De jesus Munoz
2 hours ago




related
– Luis felipe De jesus Munoz
2 hours ago












Only my vote is a hammer, I'd VTC this as a dupe of the challenge Luis linked; the bulk of most solutions is going to be converting the input to Morse code.
– Shaggy
2 hours ago




Only my vote is a hammer, I'd VTC this as a dupe of the challenge Luis linked; the bulk of most solutions is going to be converting the input to Morse code.
– Shaggy
2 hours ago










3 Answers
3






active

oldest

votes

















up vote
1
down vote














MBASIC, 325 bytes



First attempt, before the big guns get here :-)



1 DATA .-,-...,-.-.,-..,.,..-.,--.,....,..,.---,-.-,.-..,--,-.,---,.--.,--.-,.-.,...,-,..-,...-,.--,-..-,-.--,--..
2 DIM C$(26):FOR I=1 TO 26:READ C$(I):NEXT:INPUT T$:FOR I=1 TO LEN(T$):N=ASC(MID$(T$,I,1))-64:S$=S$+C$(N):NEXT:L=LEN(S$):FOR I=1 TO L:IF MID$(S$,I,1)<>MID$(S$,(L+1)-I,1) THEN 4
3 NEXT:PRINT"True":END
4 PRINT"False


Output



? PULP
True

? RESEARCHER
True

? HOTDOGS
True

?
True

? A
False

? RACECAR
False

? PROGRAMMING
False

? PUZZLES
False





share|improve this answer



























    up vote
    1
    down vote














    Jelly, 35 bytes



    ØẠḣ29“Œ}ⱮEcƑⱮʋeẏ⁻ỌḂ’œ?iⱮ⁸d⁴BnⱮ/€FŒḂ


    Takes input in uppercase only; output is 1 for true, 0 for false.



    Try it online! Or see the test-suite.



    How?



    ØẠḣ29“...’œ?iⱮ⁸d⁴BnⱮ/€FŒḂ - Link: list of characters (in [A-Z] only), S
    ØẠ - alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
    ḣ29 - head to index 29 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabc'
    “...’ - base 250 literal = 1222276956185766767980461920692
    œ? - permutation at index = 'EAIWRUSJPaLbFVHcTNMDKGOBXCYZQ'
    ⁸ - chain's left argument = S e.g. 'FOOL'
    â±® - map with:
    i - first index of (char in 'EAI...') [13,23,23,11]
    ⁴ - literal 16 16
    d - divmod [[0,13],[1,7],[1,7],[0,11]]
    B - to binary (vectorises) [[[0],[1,1,0,1]],[[1],[1,1,1]],[[1],[1,1,1]],[[0],[1,0,1,1]]]
    € - for each:
    / - reduce by:
    â±® - map with:
    n - not equal [[1,1,0,1],[0,0,0],[0,0,0],[1,0,1,1]]
    F - flatten [1,1,0,1,0,0,0,0,0,0,1,0,1,1]
    ŒḂ - is palindromic? 1





    share|improve this answer



























      up vote
      0
      down vote













      Pyth, 35 33 bytes



      The code contains unprintable characters, so here's a hexdump.



      00000000: 5f49 7358 7a47 632e 2207 0901 3f08 82ee _IsXzGc."...?...
      00000010: bd3f c256 9d54 c381 7dac 6590 37d3 c8f5 .?.V.T..}.e.7...
      00000020: 52 R


      Try it online. Test suite.



      Explanation



      Starting from ." the end of the code generates the Morse alphabet, with dots as x08 and dashes as x07, and separated by tabs.



      c splits the string by the tabs.



      XzG translates (X) the input (z) from the alphabet (G) to this "Morse alphabet".



      s sums (joins) the Morse symbols together. For empty inputs, returns 0, but this is not a problem.



      _I checks if the result does not change (I) when reversed (_). For empty input, checks if 0 does not change when negated.






      share|improve this answer






















        Your Answer




        StackExchange.ifUsing("editor", function ()
        return StackExchange.using("mathjaxEditing", function ()
        StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
        StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
        );
        );
        , "mathjax-editing");

        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "200"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        convertImagesToLinks: false,
        noModals: false,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













         

        draft saved


        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f174319%2fis-this-string-a-palindrome-in-morse-code%23new-answer', 'question_page');

        );

        Post as a guest






























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        1
        down vote














        MBASIC, 325 bytes



        First attempt, before the big guns get here :-)



        1 DATA .-,-...,-.-.,-..,.,..-.,--.,....,..,.---,-.-,.-..,--,-.,---,.--.,--.-,.-.,...,-,..-,...-,.--,-..-,-.--,--..
        2 DIM C$(26):FOR I=1 TO 26:READ C$(I):NEXT:INPUT T$:FOR I=1 TO LEN(T$):N=ASC(MID$(T$,I,1))-64:S$=S$+C$(N):NEXT:L=LEN(S$):FOR I=1 TO L:IF MID$(S$,I,1)<>MID$(S$,(L+1)-I,1) THEN 4
        3 NEXT:PRINT"True":END
        4 PRINT"False


        Output



        ? PULP
        True

        ? RESEARCHER
        True

        ? HOTDOGS
        True

        ?
        True

        ? A
        False

        ? RACECAR
        False

        ? PROGRAMMING
        False

        ? PUZZLES
        False





        share|improve this answer
























          up vote
          1
          down vote














          MBASIC, 325 bytes



          First attempt, before the big guns get here :-)



          1 DATA .-,-...,-.-.,-..,.,..-.,--.,....,..,.---,-.-,.-..,--,-.,---,.--.,--.-,.-.,...,-,..-,...-,.--,-..-,-.--,--..
          2 DIM C$(26):FOR I=1 TO 26:READ C$(I):NEXT:INPUT T$:FOR I=1 TO LEN(T$):N=ASC(MID$(T$,I,1))-64:S$=S$+C$(N):NEXT:L=LEN(S$):FOR I=1 TO L:IF MID$(S$,I,1)<>MID$(S$,(L+1)-I,1) THEN 4
          3 NEXT:PRINT"True":END
          4 PRINT"False


          Output



          ? PULP
          True

          ? RESEARCHER
          True

          ? HOTDOGS
          True

          ?
          True

          ? A
          False

          ? RACECAR
          False

          ? PROGRAMMING
          False

          ? PUZZLES
          False





          share|improve this answer






















            up vote
            1
            down vote










            up vote
            1
            down vote










            MBASIC, 325 bytes



            First attempt, before the big guns get here :-)



            1 DATA .-,-...,-.-.,-..,.,..-.,--.,....,..,.---,-.-,.-..,--,-.,---,.--.,--.-,.-.,...,-,..-,...-,.--,-..-,-.--,--..
            2 DIM C$(26):FOR I=1 TO 26:READ C$(I):NEXT:INPUT T$:FOR I=1 TO LEN(T$):N=ASC(MID$(T$,I,1))-64:S$=S$+C$(N):NEXT:L=LEN(S$):FOR I=1 TO L:IF MID$(S$,I,1)<>MID$(S$,(L+1)-I,1) THEN 4
            3 NEXT:PRINT"True":END
            4 PRINT"False


            Output



            ? PULP
            True

            ? RESEARCHER
            True

            ? HOTDOGS
            True

            ?
            True

            ? A
            False

            ? RACECAR
            False

            ? PROGRAMMING
            False

            ? PUZZLES
            False





            share|improve this answer













            MBASIC, 325 bytes



            First attempt, before the big guns get here :-)



            1 DATA .-,-...,-.-.,-..,.,..-.,--.,....,..,.---,-.-,.-..,--,-.,---,.--.,--.-,.-.,...,-,..-,...-,.--,-..-,-.--,--..
            2 DIM C$(26):FOR I=1 TO 26:READ C$(I):NEXT:INPUT T$:FOR I=1 TO LEN(T$):N=ASC(MID$(T$,I,1))-64:S$=S$+C$(N):NEXT:L=LEN(S$):FOR I=1 TO L:IF MID$(S$,I,1)<>MID$(S$,(L+1)-I,1) THEN 4
            3 NEXT:PRINT"True":END
            4 PRINT"False


            Output



            ? PULP
            True

            ? RESEARCHER
            True

            ? HOTDOGS
            True

            ?
            True

            ? A
            False

            ? RACECAR
            False

            ? PROGRAMMING
            False

            ? PUZZLES
            False






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 1 hour ago









            wooshinyobject

            915




            915




















                up vote
                1
                down vote














                Jelly, 35 bytes



                ØẠḣ29“Œ}ⱮEcƑⱮʋeẏ⁻ỌḂ’œ?iⱮ⁸d⁴BnⱮ/€FŒḂ


                Takes input in uppercase only; output is 1 for true, 0 for false.



                Try it online! Or see the test-suite.



                How?



                ØẠḣ29“...’œ?iⱮ⁸d⁴BnⱮ/€FŒḂ - Link: list of characters (in [A-Z] only), S
                ØẠ - alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
                ḣ29 - head to index 29 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabc'
                “...’ - base 250 literal = 1222276956185766767980461920692
                œ? - permutation at index = 'EAIWRUSJPaLbFVHcTNMDKGOBXCYZQ'
                ⁸ - chain's left argument = S e.g. 'FOOL'
                â±® - map with:
                i - first index of (char in 'EAI...') [13,23,23,11]
                ⁴ - literal 16 16
                d - divmod [[0,13],[1,7],[1,7],[0,11]]
                B - to binary (vectorises) [[[0],[1,1,0,1]],[[1],[1,1,1]],[[1],[1,1,1]],[[0],[1,0,1,1]]]
                € - for each:
                / - reduce by:
                â±® - map with:
                n - not equal [[1,1,0,1],[0,0,0],[0,0,0],[1,0,1,1]]
                F - flatten [1,1,0,1,0,0,0,0,0,0,1,0,1,1]
                ŒḂ - is palindromic? 1





                share|improve this answer
























                  up vote
                  1
                  down vote














                  Jelly, 35 bytes



                  ØẠḣ29“Œ}ⱮEcƑⱮʋeẏ⁻ỌḂ’œ?iⱮ⁸d⁴BnⱮ/€FŒḂ


                  Takes input in uppercase only; output is 1 for true, 0 for false.



                  Try it online! Or see the test-suite.



                  How?



                  ØẠḣ29“...’œ?iⱮ⁸d⁴BnⱮ/€FŒḂ - Link: list of characters (in [A-Z] only), S
                  ØẠ - alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
                  ḣ29 - head to index 29 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabc'
                  “...’ - base 250 literal = 1222276956185766767980461920692
                  œ? - permutation at index = 'EAIWRUSJPaLbFVHcTNMDKGOBXCYZQ'
                  ⁸ - chain's left argument = S e.g. 'FOOL'
                  â±® - map with:
                  i - first index of (char in 'EAI...') [13,23,23,11]
                  ⁴ - literal 16 16
                  d - divmod [[0,13],[1,7],[1,7],[0,11]]
                  B - to binary (vectorises) [[[0],[1,1,0,1]],[[1],[1,1,1]],[[1],[1,1,1]],[[0],[1,0,1,1]]]
                  € - for each:
                  / - reduce by:
                  â±® - map with:
                  n - not equal [[1,1,0,1],[0,0,0],[0,0,0],[1,0,1,1]]
                  F - flatten [1,1,0,1,0,0,0,0,0,0,1,0,1,1]
                  ŒḂ - is palindromic? 1





                  share|improve this answer






















                    up vote
                    1
                    down vote










                    up vote
                    1
                    down vote










                    Jelly, 35 bytes



                    ØẠḣ29“Œ}ⱮEcƑⱮʋeẏ⁻ỌḂ’œ?iⱮ⁸d⁴BnⱮ/€FŒḂ


                    Takes input in uppercase only; output is 1 for true, 0 for false.



                    Try it online! Or see the test-suite.



                    How?



                    ØẠḣ29“...’œ?iⱮ⁸d⁴BnⱮ/€FŒḂ - Link: list of characters (in [A-Z] only), S
                    ØẠ - alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
                    ḣ29 - head to index 29 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabc'
                    “...’ - base 250 literal = 1222276956185766767980461920692
                    œ? - permutation at index = 'EAIWRUSJPaLbFVHcTNMDKGOBXCYZQ'
                    ⁸ - chain's left argument = S e.g. 'FOOL'
                    â±® - map with:
                    i - first index of (char in 'EAI...') [13,23,23,11]
                    ⁴ - literal 16 16
                    d - divmod [[0,13],[1,7],[1,7],[0,11]]
                    B - to binary (vectorises) [[[0],[1,1,0,1]],[[1],[1,1,1]],[[1],[1,1,1]],[[0],[1,0,1,1]]]
                    € - for each:
                    / - reduce by:
                    â±® - map with:
                    n - not equal [[1,1,0,1],[0,0,0],[0,0,0],[1,0,1,1]]
                    F - flatten [1,1,0,1,0,0,0,0,0,0,1,0,1,1]
                    ŒḂ - is palindromic? 1





                    share|improve this answer













                    Jelly, 35 bytes



                    ØẠḣ29“Œ}ⱮEcƑⱮʋeẏ⁻ỌḂ’œ?iⱮ⁸d⁴BnⱮ/€FŒḂ


                    Takes input in uppercase only; output is 1 for true, 0 for false.



                    Try it online! Or see the test-suite.



                    How?



                    ØẠḣ29“...’œ?iⱮ⁸d⁴BnⱮ/€FŒḂ - Link: list of characters (in [A-Z] only), S
                    ØẠ - alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
                    ḣ29 - head to index 29 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabc'
                    “...’ - base 250 literal = 1222276956185766767980461920692
                    œ? - permutation at index = 'EAIWRUSJPaLbFVHcTNMDKGOBXCYZQ'
                    ⁸ - chain's left argument = S e.g. 'FOOL'
                    â±® - map with:
                    i - first index of (char in 'EAI...') [13,23,23,11]
                    ⁴ - literal 16 16
                    d - divmod [[0,13],[1,7],[1,7],[0,11]]
                    B - to binary (vectorises) [[[0],[1,1,0,1]],[[1],[1,1,1]],[[1],[1,1,1]],[[0],[1,0,1,1]]]
                    € - for each:
                    / - reduce by:
                    â±® - map with:
                    n - not equal [[1,1,0,1],[0,0,0],[0,0,0],[1,0,1,1]]
                    F - flatten [1,1,0,1,0,0,0,0,0,0,1,0,1,1]
                    ŒḂ - is palindromic? 1






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 16 mins ago









                    Jonathan Allan

                    49.2k534161




                    49.2k534161




















                        up vote
                        0
                        down vote













                        Pyth, 35 33 bytes



                        The code contains unprintable characters, so here's a hexdump.



                        00000000: 5f49 7358 7a47 632e 2207 0901 3f08 82ee _IsXzGc."...?...
                        00000010: bd3f c256 9d54 c381 7dac 6590 37d3 c8f5 .?.V.T..}.e.7...
                        00000020: 52 R


                        Try it online. Test suite.



                        Explanation



                        Starting from ." the end of the code generates the Morse alphabet, with dots as x08 and dashes as x07, and separated by tabs.



                        c splits the string by the tabs.



                        XzG translates (X) the input (z) from the alphabet (G) to this "Morse alphabet".



                        s sums (joins) the Morse symbols together. For empty inputs, returns 0, but this is not a problem.



                        _I checks if the result does not change (I) when reversed (_). For empty input, checks if 0 does not change when negated.






                        share|improve this answer


























                          up vote
                          0
                          down vote













                          Pyth, 35 33 bytes



                          The code contains unprintable characters, so here's a hexdump.



                          00000000: 5f49 7358 7a47 632e 2207 0901 3f08 82ee _IsXzGc."...?...
                          00000010: bd3f c256 9d54 c381 7dac 6590 37d3 c8f5 .?.V.T..}.e.7...
                          00000020: 52 R


                          Try it online. Test suite.



                          Explanation



                          Starting from ." the end of the code generates the Morse alphabet, with dots as x08 and dashes as x07, and separated by tabs.



                          c splits the string by the tabs.



                          XzG translates (X) the input (z) from the alphabet (G) to this "Morse alphabet".



                          s sums (joins) the Morse symbols together. For empty inputs, returns 0, but this is not a problem.



                          _I checks if the result does not change (I) when reversed (_). For empty input, checks if 0 does not change when negated.






                          share|improve this answer
























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            Pyth, 35 33 bytes



                            The code contains unprintable characters, so here's a hexdump.



                            00000000: 5f49 7358 7a47 632e 2207 0901 3f08 82ee _IsXzGc."...?...
                            00000010: bd3f c256 9d54 c381 7dac 6590 37d3 c8f5 .?.V.T..}.e.7...
                            00000020: 52 R


                            Try it online. Test suite.



                            Explanation



                            Starting from ." the end of the code generates the Morse alphabet, with dots as x08 and dashes as x07, and separated by tabs.



                            c splits the string by the tabs.



                            XzG translates (X) the input (z) from the alphabet (G) to this "Morse alphabet".



                            s sums (joins) the Morse symbols together. For empty inputs, returns 0, but this is not a problem.



                            _I checks if the result does not change (I) when reversed (_). For empty input, checks if 0 does not change when negated.






                            share|improve this answer














                            Pyth, 35 33 bytes



                            The code contains unprintable characters, so here's a hexdump.



                            00000000: 5f49 7358 7a47 632e 2207 0901 3f08 82ee _IsXzGc."...?...
                            00000010: bd3f c256 9d54 c381 7dac 6590 37d3 c8f5 .?.V.T..}.e.7...
                            00000020: 52 R


                            Try it online. Test suite.



                            Explanation



                            Starting from ." the end of the code generates the Morse alphabet, with dots as x08 and dashes as x07, and separated by tabs.



                            c splits the string by the tabs.



                            XzG translates (X) the input (z) from the alphabet (G) to this "Morse alphabet".



                            s sums (joins) the Morse symbols together. For empty inputs, returns 0, but this is not a problem.



                            _I checks if the result does not change (I) when reversed (_). For empty input, checks if 0 does not change when negated.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited 16 mins ago

























                            answered 1 hour ago









                            Pietu1998

                            15.3k22680




                            15.3k22680



























                                 

                                draft saved


                                draft discarded















































                                 


                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f174319%2fis-this-string-a-palindrome-in-morse-code%23new-answer', 'question_page');

                                );

                                Post as a guest













































































                                Popular posts from this blog

                                How to check contact read email or not when send email to Individual?

                                Displaying single band from multi-band raster using QGIS

                                How many registers does an x86_64 CPU actually have?