Greatest common substringShortest Longest Common Subsequence CodeFinding “sub-palindromes” 2: subsequences.Decompose a StringFind Patterns in StringsShortest Longest Common Subsequence CodeMaximal Substring ConstructionVisualize the greatest common divisorShortest Unique SubstringFind the original string, without the repetition without the repetition in the middleMinimal Fresh SubstringsStitch Together a Palindrome from Palindromic Substrings

Folder comparison

Can the Supreme Court overturn an impeachment?

How much character growth crosses the line into breaking the character

List of people who lose a child in תנ"ך

Indicating multiple different modes of speech (fantasy language or telepathy)

Wrapping Cryptocurrencies for interoperability sake

Is possible to search in vim history?

Drawing a topological "handle" with Tikz

What does this horizontal bar at the first measure mean?

Can someone explain how this makes sense electrically?

Greatest common substring

Greco-Roman egalitarianism

Create all possible words using a set or letters

Did US corporations pay demonstrators in the German demonstrations against article 13?

How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?

What is this type of notehead called?

MAXDOP Settings for SQL Server 2014

My friend sent me a screenshot of a transaction hash, but when I search for it I find divergent data. What happened?

Proof of Lemma: Every nonzero integer can be written as a product of primes

Longest common substring in linear time

Will adding a BY-SA image to a blog post make the entire post BY-SA?

How must one send away the mother bird?

Can a significant change in incentives void an employment contract?

Has Darkwing Duck ever met Scrooge McDuck?



Greatest common substring


Shortest Longest Common Subsequence CodeFinding “sub-palindromes” 2: subsequences.Decompose a StringFind Patterns in StringsShortest Longest Common Subsequence CodeMaximal Substring ConstructionVisualize the greatest common divisorShortest Unique SubstringFind the original string, without the repetition without the repetition in the middleMinimal Fresh SubstringsStitch Together a Palindrome from Palindromic Substrings













4












$begingroup$


Create a program or function which takes a list of strings as input, and outputs the longest string that is a substring of all input strings. If there are several substrings of equal length, and no longer substring, output any one of them.



  • This may mean outputting the empty string.

  • If there are several valid outputs, you may output any one of them. You are not required to give consistent outpput for a given input so long as the output is always valid.

  • There will always be at least one string in the input, but there might not be a non-empty string.

  • All printable ASCII characters may appear in the input. You may assume those are the only characters that appear.

  • You may take input or produce output by any of the default methods.


  • Standard loopholes aren't allowed.

  • This is code-golf - the fewer bytes of code, the better.

Test cases:



[Inputs] -> [Valid outputs (choose one)]



["hello", "'ello"] -> ["ello"]
["very", "much", "different"] -> [""]
["empty", "", "STRING"] -> [""]
["identical", "identical"] -> ["identical"]
["string", "stRIng"] -> ["st", "ng"]
["this one", "is a substring of this one"] -> ["this one"]
["just one"] -> ["just one"]
["", "", ""] -> [""]
["many outputs", "stuptuo ynam"] -> ["m", "a", "n", "y", " ", "o", "u", "t", "p", "s"]
["many inputs", "any inputs", "ny iii", "yanny"] -> ["ny"]
["%%not&", "ju&#st", "[&]alpha_numeric"] -> ["%"]









share|improve this question











$endgroup$











  • $begingroup$
    Possible duplicate
    $endgroup$
    – Adám
    1 hour ago










  • $begingroup$
    @Adám That question asks for the longest common subsequence, not substring.
    $endgroup$
    – Doorknob
    1 hour ago






  • 1




    $begingroup$
    Will the strings be only alphanumeric, or alphabetic, or only printable-ascii?
    $endgroup$
    – Embodiment of Ignorance
    30 mins ago










  • $begingroup$
    @EmbodimentofIgnorance All printable ASCII characters can appear in the input.
    $endgroup$
    – Sara J
    16 mins ago















4












$begingroup$


Create a program or function which takes a list of strings as input, and outputs the longest string that is a substring of all input strings. If there are several substrings of equal length, and no longer substring, output any one of them.



  • This may mean outputting the empty string.

  • If there are several valid outputs, you may output any one of them. You are not required to give consistent outpput for a given input so long as the output is always valid.

  • There will always be at least one string in the input, but there might not be a non-empty string.

  • All printable ASCII characters may appear in the input. You may assume those are the only characters that appear.

  • You may take input or produce output by any of the default methods.


  • Standard loopholes aren't allowed.

  • This is code-golf - the fewer bytes of code, the better.

Test cases:



[Inputs] -> [Valid outputs (choose one)]



["hello", "'ello"] -> ["ello"]
["very", "much", "different"] -> [""]
["empty", "", "STRING"] -> [""]
["identical", "identical"] -> ["identical"]
["string", "stRIng"] -> ["st", "ng"]
["this one", "is a substring of this one"] -> ["this one"]
["just one"] -> ["just one"]
["", "", ""] -> [""]
["many outputs", "stuptuo ynam"] -> ["m", "a", "n", "y", " ", "o", "u", "t", "p", "s"]
["many inputs", "any inputs", "ny iii", "yanny"] -> ["ny"]
["%%not&", "ju&#st", "[&]alpha_numeric"] -> ["%"]









share|improve this question











$endgroup$











  • $begingroup$
    Possible duplicate
    $endgroup$
    – Adám
    1 hour ago










  • $begingroup$
    @Adám That question asks for the longest common subsequence, not substring.
    $endgroup$
    – Doorknob
    1 hour ago






  • 1




    $begingroup$
    Will the strings be only alphanumeric, or alphabetic, or only printable-ascii?
    $endgroup$
    – Embodiment of Ignorance
    30 mins ago










  • $begingroup$
    @EmbodimentofIgnorance All printable ASCII characters can appear in the input.
    $endgroup$
    – Sara J
    16 mins ago













4












4








4





$begingroup$


Create a program or function which takes a list of strings as input, and outputs the longest string that is a substring of all input strings. If there are several substrings of equal length, and no longer substring, output any one of them.



  • This may mean outputting the empty string.

  • If there are several valid outputs, you may output any one of them. You are not required to give consistent outpput for a given input so long as the output is always valid.

  • There will always be at least one string in the input, but there might not be a non-empty string.

  • All printable ASCII characters may appear in the input. You may assume those are the only characters that appear.

  • You may take input or produce output by any of the default methods.


  • Standard loopholes aren't allowed.

  • This is code-golf - the fewer bytes of code, the better.

Test cases:



[Inputs] -> [Valid outputs (choose one)]



["hello", "'ello"] -> ["ello"]
["very", "much", "different"] -> [""]
["empty", "", "STRING"] -> [""]
["identical", "identical"] -> ["identical"]
["string", "stRIng"] -> ["st", "ng"]
["this one", "is a substring of this one"] -> ["this one"]
["just one"] -> ["just one"]
["", "", ""] -> [""]
["many outputs", "stuptuo ynam"] -> ["m", "a", "n", "y", " ", "o", "u", "t", "p", "s"]
["many inputs", "any inputs", "ny iii", "yanny"] -> ["ny"]
["%%not&", "ju&#st", "[&]alpha_numeric"] -> ["%"]









share|improve this question











$endgroup$




Create a program or function which takes a list of strings as input, and outputs the longest string that is a substring of all input strings. If there are several substrings of equal length, and no longer substring, output any one of them.



  • This may mean outputting the empty string.

  • If there are several valid outputs, you may output any one of them. You are not required to give consistent outpput for a given input so long as the output is always valid.

  • There will always be at least one string in the input, but there might not be a non-empty string.

  • All printable ASCII characters may appear in the input. You may assume those are the only characters that appear.

  • You may take input or produce output by any of the default methods.


  • Standard loopholes aren't allowed.

  • This is code-golf - the fewer bytes of code, the better.

Test cases:



[Inputs] -> [Valid outputs (choose one)]



["hello", "'ello"] -> ["ello"]
["very", "much", "different"] -> [""]
["empty", "", "STRING"] -> [""]
["identical", "identical"] -> ["identical"]
["string", "stRIng"] -> ["st", "ng"]
["this one", "is a substring of this one"] -> ["this one"]
["just one"] -> ["just one"]
["", "", ""] -> [""]
["many outputs", "stuptuo ynam"] -> ["m", "a", "n", "y", " ", "o", "u", "t", "p", "s"]
["many inputs", "any inputs", "ny iii", "yanny"] -> ["ny"]
["%%not&", "ju&#st", "[&]alpha_numeric"] -> ["%"]






code-golf string subsequence






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 12 mins ago







Sara J

















asked 1 hour ago









Sara JSara J

1715




1715











  • $begingroup$
    Possible duplicate
    $endgroup$
    – Adám
    1 hour ago










  • $begingroup$
    @Adám That question asks for the longest common subsequence, not substring.
    $endgroup$
    – Doorknob
    1 hour ago






  • 1




    $begingroup$
    Will the strings be only alphanumeric, or alphabetic, or only printable-ascii?
    $endgroup$
    – Embodiment of Ignorance
    30 mins ago










  • $begingroup$
    @EmbodimentofIgnorance All printable ASCII characters can appear in the input.
    $endgroup$
    – Sara J
    16 mins ago
















  • $begingroup$
    Possible duplicate
    $endgroup$
    – Adám
    1 hour ago










  • $begingroup$
    @Adám That question asks for the longest common subsequence, not substring.
    $endgroup$
    – Doorknob
    1 hour ago






  • 1




    $begingroup$
    Will the strings be only alphanumeric, or alphabetic, or only printable-ascii?
    $endgroup$
    – Embodiment of Ignorance
    30 mins ago










  • $begingroup$
    @EmbodimentofIgnorance All printable ASCII characters can appear in the input.
    $endgroup$
    – Sara J
    16 mins ago















$begingroup$
Possible duplicate
$endgroup$
– Adám
1 hour ago




$begingroup$
Possible duplicate
$endgroup$
– Adám
1 hour ago












$begingroup$
@Adám That question asks for the longest common subsequence, not substring.
$endgroup$
– Doorknob
1 hour ago




$begingroup$
@Adám That question asks for the longest common subsequence, not substring.
$endgroup$
– Doorknob
1 hour ago




1




1




$begingroup$
Will the strings be only alphanumeric, or alphabetic, or only printable-ascii?
$endgroup$
– Embodiment of Ignorance
30 mins ago




$begingroup$
Will the strings be only alphanumeric, or alphabetic, or only printable-ascii?
$endgroup$
– Embodiment of Ignorance
30 mins ago












$begingroup$
@EmbodimentofIgnorance All printable ASCII characters can appear in the input.
$endgroup$
– Sara J
16 mins ago




$begingroup$
@EmbodimentofIgnorance All printable ASCII characters can appear in the input.
$endgroup$
– Sara J
16 mins ago










4 Answers
4






active

oldest

votes


















0












$begingroup$


Jelly, 12 bytes



Ẇ€œ&/LÐṀḢ¹L?


Try it online!



Last four bytes are there because of the requirement to only output one answer.






share|improve this answer









$endgroup$




















    0












    $begingroup$


    JavaScript (Node.js), 114 105 bytes





    a=>(F=(l,n,w=a[0].substr(n,l))=>l?n<0?F(--l,L-l):a.some(y=>y.search(w)<0)?F(l,n-1):w:"")(L=a[0].length,0)


    Try it online!



    Probably still golfable.
    y.indexOf must be used in place of y.search if the strings may contain special regex characters, at the cost of 1 more byte.






    share|improve this answer











    $endgroup$




















      0












      $begingroup$


      Brachylog (v2), 3 bytes



      sᵛw


      Try it online!



      Full program. Input from standard input (as a JSON-style list of strings), output to standard output.



      Explanation



      sᵛw
      s Find a substring
      ᵛ of every element of the input; the same one for each
      w and output it.


      Tiebreak order here is set by the s, favouring the longest substring (the secondary tiebreak doesn't matter, but IIRC it's position within the first element of the input).



      Brachylog's s doesn't return empty substrings, so we need a bit of a trick to get around that: instead of making a function submission (which is what's normally done), we write a full program, outputting to standard output. That way, if there's a common substring, we just output it, and we're done. If there isn't a common substring, the program errors out – but it still prints nothing to standard output, thus it outputs the null string as intended.






      share|improve this answer











      $endgroup$




















        0












        $begingroup$


        Python 3, 174 bytes





        def a(b):
        a=();c=list(sum((list(d[f:e]for f in range(e+1))for e in range(len(d)+1)),[])for d in b)
        for i in c[0]:
        if all(i in j for j in c):a+=(i,)
        return max(a,key=len)


        Try it online!






        share|improve this answer










        New contributor




        Artemis Fowl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        $endgroup$












        • $begingroup$
          You may want to use single spaces as indentation instead of 4 that seems to shave more than 100 bytes.
          $endgroup$
          – Shieru Asakoto
          1 hour ago










        • $begingroup$
          @ShieruAsakoto Oops yeah.
          $endgroup$
          – Artemis Fowl
          1 hour ago










        • $begingroup$
          135 bytes by simplifying the c declaration and condensing the for loop. I would recommend adding the title and bytecount to the header, or using TIO's formatter to create the body of your post
          $endgroup$
          – Jo King
          30 mins ago











        • $begingroup$
          102 bytes by using set operators instead
          $endgroup$
          – Jo King
          26 mins ago










        • $begingroup$
          @JoKing tio.run/…
          $endgroup$
          – Artemis Fowl
          7 mins ago










        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',
        autoActivateHeartbeat: false,
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        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%2f182134%2fgreatest-common-substring%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        0












        $begingroup$


        Jelly, 12 bytes



        Ẇ€œ&/LÐṀḢ¹L?


        Try it online!



        Last four bytes are there because of the requirement to only output one answer.






        share|improve this answer









        $endgroup$

















          0












          $begingroup$


          Jelly, 12 bytes



          Ẇ€œ&/LÐṀḢ¹L?


          Try it online!



          Last four bytes are there because of the requirement to only output one answer.






          share|improve this answer









          $endgroup$















            0












            0








            0





            $begingroup$


            Jelly, 12 bytes



            Ẇ€œ&/LÐṀḢ¹L?


            Try it online!



            Last four bytes are there because of the requirement to only output one answer.






            share|improve this answer









            $endgroup$




            Jelly, 12 bytes



            Ẇ€œ&/LÐṀḢ¹L?


            Try it online!



            Last four bytes are there because of the requirement to only output one answer.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 1 hour ago









            Nick KennedyNick Kennedy

            92147




            92147





















                0












                $begingroup$


                JavaScript (Node.js), 114 105 bytes





                a=>(F=(l,n,w=a[0].substr(n,l))=>l?n<0?F(--l,L-l):a.some(y=>y.search(w)<0)?F(l,n-1):w:"")(L=a[0].length,0)


                Try it online!



                Probably still golfable.
                y.indexOf must be used in place of y.search if the strings may contain special regex characters, at the cost of 1 more byte.






                share|improve this answer











                $endgroup$

















                  0












                  $begingroup$


                  JavaScript (Node.js), 114 105 bytes





                  a=>(F=(l,n,w=a[0].substr(n,l))=>l?n<0?F(--l,L-l):a.some(y=>y.search(w)<0)?F(l,n-1):w:"")(L=a[0].length,0)


                  Try it online!



                  Probably still golfable.
                  y.indexOf must be used in place of y.search if the strings may contain special regex characters, at the cost of 1 more byte.






                  share|improve this answer











                  $endgroup$















                    0












                    0








                    0





                    $begingroup$


                    JavaScript (Node.js), 114 105 bytes





                    a=>(F=(l,n,w=a[0].substr(n,l))=>l?n<0?F(--l,L-l):a.some(y=>y.search(w)<0)?F(l,n-1):w:"")(L=a[0].length,0)


                    Try it online!



                    Probably still golfable.
                    y.indexOf must be used in place of y.search if the strings may contain special regex characters, at the cost of 1 more byte.






                    share|improve this answer











                    $endgroup$




                    JavaScript (Node.js), 114 105 bytes





                    a=>(F=(l,n,w=a[0].substr(n,l))=>l?n<0?F(--l,L-l):a.some(y=>y.search(w)<0)?F(l,n-1):w:"")(L=a[0].length,0)


                    Try it online!



                    Probably still golfable.
                    y.indexOf must be used in place of y.search if the strings may contain special regex characters, at the cost of 1 more byte.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited 29 mins ago

























                    answered 39 mins ago









                    Shieru AsakotoShieru Asakoto

                    2,750317




                    2,750317





















                        0












                        $begingroup$


                        Brachylog (v2), 3 bytes



                        sᵛw


                        Try it online!



                        Full program. Input from standard input (as a JSON-style list of strings), output to standard output.



                        Explanation



                        sᵛw
                        s Find a substring
                        ᵛ of every element of the input; the same one for each
                        w and output it.


                        Tiebreak order here is set by the s, favouring the longest substring (the secondary tiebreak doesn't matter, but IIRC it's position within the first element of the input).



                        Brachylog's s doesn't return empty substrings, so we need a bit of a trick to get around that: instead of making a function submission (which is what's normally done), we write a full program, outputting to standard output. That way, if there's a common substring, we just output it, and we're done. If there isn't a common substring, the program errors out – but it still prints nothing to standard output, thus it outputs the null string as intended.






                        share|improve this answer











                        $endgroup$

















                          0












                          $begingroup$


                          Brachylog (v2), 3 bytes



                          sᵛw


                          Try it online!



                          Full program. Input from standard input (as a JSON-style list of strings), output to standard output.



                          Explanation



                          sᵛw
                          s Find a substring
                          ᵛ of every element of the input; the same one for each
                          w and output it.


                          Tiebreak order here is set by the s, favouring the longest substring (the secondary tiebreak doesn't matter, but IIRC it's position within the first element of the input).



                          Brachylog's s doesn't return empty substrings, so we need a bit of a trick to get around that: instead of making a function submission (which is what's normally done), we write a full program, outputting to standard output. That way, if there's a common substring, we just output it, and we're done. If there isn't a common substring, the program errors out – but it still prints nothing to standard output, thus it outputs the null string as intended.






                          share|improve this answer











                          $endgroup$















                            0












                            0








                            0





                            $begingroup$


                            Brachylog (v2), 3 bytes



                            sᵛw


                            Try it online!



                            Full program. Input from standard input (as a JSON-style list of strings), output to standard output.



                            Explanation



                            sᵛw
                            s Find a substring
                            ᵛ of every element of the input; the same one for each
                            w and output it.


                            Tiebreak order here is set by the s, favouring the longest substring (the secondary tiebreak doesn't matter, but IIRC it's position within the first element of the input).



                            Brachylog's s doesn't return empty substrings, so we need a bit of a trick to get around that: instead of making a function submission (which is what's normally done), we write a full program, outputting to standard output. That way, if there's a common substring, we just output it, and we're done. If there isn't a common substring, the program errors out – but it still prints nothing to standard output, thus it outputs the null string as intended.






                            share|improve this answer











                            $endgroup$




                            Brachylog (v2), 3 bytes



                            sᵛw


                            Try it online!



                            Full program. Input from standard input (as a JSON-style list of strings), output to standard output.



                            Explanation



                            sᵛw
                            s Find a substring
                            ᵛ of every element of the input; the same one for each
                            w and output it.


                            Tiebreak order here is set by the s, favouring the longest substring (the secondary tiebreak doesn't matter, but IIRC it's position within the first element of the input).



                            Brachylog's s doesn't return empty substrings, so we need a bit of a trick to get around that: instead of making a function submission (which is what's normally done), we write a full program, outputting to standard output. That way, if there's a common substring, we just output it, and we're done. If there isn't a common substring, the program errors out – but it still prints nothing to standard output, thus it outputs the null string as intended.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            answered 26 mins ago


























                            community wiki





                            ais523






















                                0












                                $begingroup$


                                Python 3, 174 bytes





                                def a(b):
                                a=();c=list(sum((list(d[f:e]for f in range(e+1))for e in range(len(d)+1)),[])for d in b)
                                for i in c[0]:
                                if all(i in j for j in c):a+=(i,)
                                return max(a,key=len)


                                Try it online!






                                share|improve this answer










                                New contributor




                                Artemis Fowl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                Check out our Code of Conduct.






                                $endgroup$












                                • $begingroup$
                                  You may want to use single spaces as indentation instead of 4 that seems to shave more than 100 bytes.
                                  $endgroup$
                                  – Shieru Asakoto
                                  1 hour ago










                                • $begingroup$
                                  @ShieruAsakoto Oops yeah.
                                  $endgroup$
                                  – Artemis Fowl
                                  1 hour ago










                                • $begingroup$
                                  135 bytes by simplifying the c declaration and condensing the for loop. I would recommend adding the title and bytecount to the header, or using TIO's formatter to create the body of your post
                                  $endgroup$
                                  – Jo King
                                  30 mins ago











                                • $begingroup$
                                  102 bytes by using set operators instead
                                  $endgroup$
                                  – Jo King
                                  26 mins ago










                                • $begingroup$
                                  @JoKing tio.run/…
                                  $endgroup$
                                  – Artemis Fowl
                                  7 mins ago















                                0












                                $begingroup$


                                Python 3, 174 bytes





                                def a(b):
                                a=();c=list(sum((list(d[f:e]for f in range(e+1))for e in range(len(d)+1)),[])for d in b)
                                for i in c[0]:
                                if all(i in j for j in c):a+=(i,)
                                return max(a,key=len)


                                Try it online!






                                share|improve this answer










                                New contributor




                                Artemis Fowl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                Check out our Code of Conduct.






                                $endgroup$












                                • $begingroup$
                                  You may want to use single spaces as indentation instead of 4 that seems to shave more than 100 bytes.
                                  $endgroup$
                                  – Shieru Asakoto
                                  1 hour ago










                                • $begingroup$
                                  @ShieruAsakoto Oops yeah.
                                  $endgroup$
                                  – Artemis Fowl
                                  1 hour ago










                                • $begingroup$
                                  135 bytes by simplifying the c declaration and condensing the for loop. I would recommend adding the title and bytecount to the header, or using TIO's formatter to create the body of your post
                                  $endgroup$
                                  – Jo King
                                  30 mins ago











                                • $begingroup$
                                  102 bytes by using set operators instead
                                  $endgroup$
                                  – Jo King
                                  26 mins ago










                                • $begingroup$
                                  @JoKing tio.run/…
                                  $endgroup$
                                  – Artemis Fowl
                                  7 mins ago













                                0












                                0








                                0





                                $begingroup$


                                Python 3, 174 bytes





                                def a(b):
                                a=();c=list(sum((list(d[f:e]for f in range(e+1))for e in range(len(d)+1)),[])for d in b)
                                for i in c[0]:
                                if all(i in j for j in c):a+=(i,)
                                return max(a,key=len)


                                Try it online!






                                share|improve this answer










                                New contributor




                                Artemis Fowl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                Check out our Code of Conduct.






                                $endgroup$




                                Python 3, 174 bytes





                                def a(b):
                                a=();c=list(sum((list(d[f:e]for f in range(e+1))for e in range(len(d)+1)),[])for d in b)
                                for i in c[0]:
                                if all(i in j for j in c):a+=(i,)
                                return max(a,key=len)


                                Try it online!







                                share|improve this answer










                                New contributor




                                Artemis Fowl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                Check out our Code of Conduct.









                                share|improve this answer



                                share|improve this answer








                                edited 4 mins ago





















                                New contributor




                                Artemis Fowl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                Check out our Code of Conduct.









                                answered 1 hour ago









                                Artemis FowlArtemis Fowl

                                1013




                                1013




                                New contributor




                                Artemis Fowl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                Check out our Code of Conduct.





                                New contributor





                                Artemis Fowl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                Check out our Code of Conduct.






                                Artemis Fowl is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                                Check out our Code of Conduct.











                                • $begingroup$
                                  You may want to use single spaces as indentation instead of 4 that seems to shave more than 100 bytes.
                                  $endgroup$
                                  – Shieru Asakoto
                                  1 hour ago










                                • $begingroup$
                                  @ShieruAsakoto Oops yeah.
                                  $endgroup$
                                  – Artemis Fowl
                                  1 hour ago










                                • $begingroup$
                                  135 bytes by simplifying the c declaration and condensing the for loop. I would recommend adding the title and bytecount to the header, or using TIO's formatter to create the body of your post
                                  $endgroup$
                                  – Jo King
                                  30 mins ago











                                • $begingroup$
                                  102 bytes by using set operators instead
                                  $endgroup$
                                  – Jo King
                                  26 mins ago










                                • $begingroup$
                                  @JoKing tio.run/…
                                  $endgroup$
                                  – Artemis Fowl
                                  7 mins ago
















                                • $begingroup$
                                  You may want to use single spaces as indentation instead of 4 that seems to shave more than 100 bytes.
                                  $endgroup$
                                  – Shieru Asakoto
                                  1 hour ago










                                • $begingroup$
                                  @ShieruAsakoto Oops yeah.
                                  $endgroup$
                                  – Artemis Fowl
                                  1 hour ago










                                • $begingroup$
                                  135 bytes by simplifying the c declaration and condensing the for loop. I would recommend adding the title and bytecount to the header, or using TIO's formatter to create the body of your post
                                  $endgroup$
                                  – Jo King
                                  30 mins ago











                                • $begingroup$
                                  102 bytes by using set operators instead
                                  $endgroup$
                                  – Jo King
                                  26 mins ago










                                • $begingroup$
                                  @JoKing tio.run/…
                                  $endgroup$
                                  – Artemis Fowl
                                  7 mins ago















                                $begingroup$
                                You may want to use single spaces as indentation instead of 4 that seems to shave more than 100 bytes.
                                $endgroup$
                                – Shieru Asakoto
                                1 hour ago




                                $begingroup$
                                You may want to use single spaces as indentation instead of 4 that seems to shave more than 100 bytes.
                                $endgroup$
                                – Shieru Asakoto
                                1 hour ago












                                $begingroup$
                                @ShieruAsakoto Oops yeah.
                                $endgroup$
                                – Artemis Fowl
                                1 hour ago




                                $begingroup$
                                @ShieruAsakoto Oops yeah.
                                $endgroup$
                                – Artemis Fowl
                                1 hour ago












                                $begingroup$
                                135 bytes by simplifying the c declaration and condensing the for loop. I would recommend adding the title and bytecount to the header, or using TIO's formatter to create the body of your post
                                $endgroup$
                                – Jo King
                                30 mins ago





                                $begingroup$
                                135 bytes by simplifying the c declaration and condensing the for loop. I would recommend adding the title and bytecount to the header, or using TIO's formatter to create the body of your post
                                $endgroup$
                                – Jo King
                                30 mins ago













                                $begingroup$
                                102 bytes by using set operators instead
                                $endgroup$
                                – Jo King
                                26 mins ago




                                $begingroup$
                                102 bytes by using set operators instead
                                $endgroup$
                                – Jo King
                                26 mins ago












                                $begingroup$
                                @JoKing tio.run/…
                                $endgroup$
                                – Artemis Fowl
                                7 mins ago




                                $begingroup$
                                @JoKing tio.run/…
                                $endgroup$
                                – Artemis Fowl
                                7 mins ago

















                                draft saved

                                draft discarded
















































                                If this is an answer to a challenge…



                                • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                  Explanations of your answer make it more interesting to read and are very much encouraged.


                                • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.


                                More generally…



                                • …Please make sure to answer the question and provide sufficient detail.


                                • …Avoid asking for help, clarification or responding to other answers (use comments instead).




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f182134%2fgreatest-common-substring%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                How should I use the fbox command correctly to avoid producing a Bad Box message?How to put a long piece of text in a box?How to specify height and width of fboxIs there an arrayrulecolor-like command to change the rule color of fbox?What is the command to highlight bad boxes in pdf?Why does fbox sometimes place the box *over* the graphic image?how to put the text in the boxHow to create command for a box where text inside the box can automatically adjust?how can I make an fbox like command with certain color, shape and width of border?how to use fbox in align modeFbox increase the spacing between the box and it content (inner margin)how to change the box height of an equationWhat is the use of the hbox in a newcommand command?

                                Doxepinum Nexus interni Notae | Tabula navigationis3158DB01142WHOa682390"Structural Analysis of the Histamine H1 Receptor""Transdermal and Topical Drug Administration in the Treatment of Pain""Antidepressants as antipruritic agents: A review"

                                inputenc: Unicode character … not set up for use with LaTeX The Next CEO of Stack OverflowEntering Unicode characters in LaTeXHow to solve the `Package inputenc Error: Unicode char not set up for use with LaTeX` problem?solve “Unicode char is not set up for use with LaTeX” without special handling of every new interesting UTF-8 characterPackage inputenc Error: Unicode character ² (U+B2)(inputenc) not set up for use with LaTeX. acroI2C[I²C]package inputenc error unicode char (u + 190) not set up for use with latexPackage inputenc Error: Unicode char u8:′ not set up for use with LaTeX. 3′inputenc Error: Unicode char u8: not set up for use with LaTeX with G-BriefPackage Inputenc Error: Unicode char u8: not set up for use with LaTeXPackage inputenc Error: Unicode char ́ (U+301)(inputenc) not set up for use with LaTeX. includePackage inputenc Error: Unicode char ̂ (U+302)(inputenc) not set up for use with LaTeX. … $widehatleft (OA,AA' right )$Package inputenc Error: Unicode char â„¡ (U+2121)(inputenc) not set up for use with LaTeX. printbibliography[heading=bibintoc]Package inputenc Error: Unicode char − (U+2212)(inputenc) not set up for use with LaTeXPackage inputenc Error: Unicode character α (U+3B1) not set up for use with LaTeXPackage inputenc Error: Unicode characterError: ! Package inputenc Error: Unicode char ⊘ (U+2298)(inputenc) not set up for use with LaTeX