Text compression

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











up vote
1
down vote

favorite
1












With the given text below, there are some words in the text that repeats several times in the text. Use any programming language to write a short code that compresses the text to display it. Or in other words, use the smallest number of bytes to display the text.

The Text is:



Peter Piper picked a peck of pickled peppers. 
A peck of pickled peppers Peter Piper picked.
If Peter Piper picked a peck of pickled peppers,
Where's the peck of pickled peppers Peter Piper picked?









share|improve this question



























    up vote
    1
    down vote

    favorite
    1












    With the given text below, there are some words in the text that repeats several times in the text. Use any programming language to write a short code that compresses the text to display it. Or in other words, use the smallest number of bytes to display the text.

    The Text is:



    Peter Piper picked a peck of pickled peppers. 
    A peck of pickled peppers Peter Piper picked.
    If Peter Piper picked a peck of pickled peppers,
    Where's the peck of pickled peppers Peter Piper picked?









    share|improve this question

























      up vote
      1
      down vote

      favorite
      1









      up vote
      1
      down vote

      favorite
      1






      1





      With the given text below, there are some words in the text that repeats several times in the text. Use any programming language to write a short code that compresses the text to display it. Or in other words, use the smallest number of bytes to display the text.

      The Text is:



      Peter Piper picked a peck of pickled peppers. 
      A peck of pickled peppers Peter Piper picked.
      If Peter Piper picked a peck of pickled peppers,
      Where's the peck of pickled peppers Peter Piper picked?









      share|improve this question















      With the given text below, there are some words in the text that repeats several times in the text. Use any programming language to write a short code that compresses the text to display it. Or in other words, use the smallest number of bytes to display the text.

      The Text is:



      Peter Piper picked a peck of pickled peppers. 
      A peck of pickled peppers Peter Piper picked.
      If Peter Piper picked a peck of pickled peppers,
      Where's the peck of pickled peppers Peter Piper picked?






      code-golf string kolmogorov-complexity






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 1 hour ago









      Mr. Xcoder

      30.9k758195




      30.9k758195










      asked 2 hours ago









      Monolica

      15719




      15719




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          2
          down vote














          Bubblegum, 73 bytes



          00000000: 0b48 2d49 2d52 08c8 2c00 9205 99c9 d9a9 .H-I-R..,.......
          00000010: 290a 890a 05a9 c9d9 0af9 6960 811c a048 ).........i`...H
          00000020: 416a 0150 be58 8fcb 1197 9442 0086 397a Aj.P.X.....B..9z
          00000030: 5c9e 6958 8471 1baf c315 9e91 5a94 aa5e .iX.q......Z..^
          00000040: ac50 9291 4a82 45f6 00 .P..J.E..


          Try it online!






          share|improve this answer



























            up vote
            2
            down vote














            JavaScript (SpiderMonkey), 117 bytes





            print(`$S='Peter Piper picked' a$O=' peck of pickled peppers'.
            A$O $S.
            If $S a$O,
            Where's the$O $S?`)


            Try it online!



            I would claim this answer is from ovs, anyway, 19 bytes saved.






            share|improve this answer


















            • 1




              117 bytes
              – ovs
              1 hour ago










            • 114 bytes.
              – Arnauld
              29 mins ago

















            up vote
            0
            down vote














            R, 106 bytes





            "["=gsub
            cat(1["Peter Piper picked",2[" peck of pickled peppers","1 a2.
            A2 1.
            If 1 a2,
            Where's the2 1?"]])


            Try it online!






            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%2f173965%2ftext-compression%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
              2
              down vote














              Bubblegum, 73 bytes



              00000000: 0b48 2d49 2d52 08c8 2c00 9205 99c9 d9a9 .H-I-R..,.......
              00000010: 290a 890a 05a9 c9d9 0af9 6960 811c a048 ).........i`...H
              00000020: 416a 0150 be58 8fcb 1197 9442 0086 397a Aj.P.X.....B..9z
              00000030: 5c9e 6958 8471 1baf c315 9e91 5a94 aa5e .iX.q......Z..^
              00000040: ac50 9291 4a82 45f6 00 .P..J.E..


              Try it online!






              share|improve this answer
























                up vote
                2
                down vote














                Bubblegum, 73 bytes



                00000000: 0b48 2d49 2d52 08c8 2c00 9205 99c9 d9a9 .H-I-R..,.......
                00000010: 290a 890a 05a9 c9d9 0af9 6960 811c a048 ).........i`...H
                00000020: 416a 0150 be58 8fcb 1197 9442 0086 397a Aj.P.X.....B..9z
                00000030: 5c9e 6958 8471 1baf c315 9e91 5a94 aa5e .iX.q......Z..^
                00000040: ac50 9291 4a82 45f6 00 .P..J.E..


                Try it online!






                share|improve this answer






















                  up vote
                  2
                  down vote










                  up vote
                  2
                  down vote










                  Bubblegum, 73 bytes



                  00000000: 0b48 2d49 2d52 08c8 2c00 9205 99c9 d9a9 .H-I-R..,.......
                  00000010: 290a 890a 05a9 c9d9 0af9 6960 811c a048 ).........i`...H
                  00000020: 416a 0150 be58 8fcb 1197 9442 0086 397a Aj.P.X.....B..9z
                  00000030: 5c9e 6958 8471 1baf c315 9e91 5a94 aa5e .iX.q......Z..^
                  00000040: ac50 9291 4a82 45f6 00 .P..J.E..


                  Try it online!






                  share|improve this answer













                  Bubblegum, 73 bytes



                  00000000: 0b48 2d49 2d52 08c8 2c00 9205 99c9 d9a9 .H-I-R..,.......
                  00000010: 290a 890a 05a9 c9d9 0af9 6960 811c a048 ).........i`...H
                  00000020: 416a 0150 be58 8fcb 1197 9442 0086 397a Aj.P.X.....B..9z
                  00000030: 5c9e 6958 8471 1baf c315 9e91 5a94 aa5e .iX.q......Z..^
                  00000040: ac50 9291 4a82 45f6 00 .P..J.E..


                  Try it online!







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 1 hour ago









                  ovs

                  17.7k21058




                  17.7k21058




















                      up vote
                      2
                      down vote














                      JavaScript (SpiderMonkey), 117 bytes





                      print(`$S='Peter Piper picked' a$O=' peck of pickled peppers'.
                      A$O $S.
                      If $S a$O,
                      Where's the$O $S?`)


                      Try it online!



                      I would claim this answer is from ovs, anyway, 19 bytes saved.






                      share|improve this answer


















                      • 1




                        117 bytes
                        – ovs
                        1 hour ago










                      • 114 bytes.
                        – Arnauld
                        29 mins ago














                      up vote
                      2
                      down vote














                      JavaScript (SpiderMonkey), 117 bytes





                      print(`$S='Peter Piper picked' a$O=' peck of pickled peppers'.
                      A$O $S.
                      If $S a$O,
                      Where's the$O $S?`)


                      Try it online!



                      I would claim this answer is from ovs, anyway, 19 bytes saved.






                      share|improve this answer


















                      • 1




                        117 bytes
                        – ovs
                        1 hour ago










                      • 114 bytes.
                        – Arnauld
                        29 mins ago












                      up vote
                      2
                      down vote










                      up vote
                      2
                      down vote










                      JavaScript (SpiderMonkey), 117 bytes





                      print(`$S='Peter Piper picked' a$O=' peck of pickled peppers'.
                      A$O $S.
                      If $S a$O,
                      Where's the$O $S?`)


                      Try it online!



                      I would claim this answer is from ovs, anyway, 19 bytes saved.






                      share|improve this answer















                      JavaScript (SpiderMonkey), 117 bytes





                      print(`$S='Peter Piper picked' a$O=' peck of pickled peppers'.
                      A$O $S.
                      If $S a$O,
                      Where's the$O $S?`)


                      Try it online!



                      I would claim this answer is from ovs, anyway, 19 bytes saved.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited 1 hour ago

























                      answered 1 hour ago









                      tsh

                      7,55611343




                      7,55611343







                      • 1




                        117 bytes
                        – ovs
                        1 hour ago










                      • 114 bytes.
                        – Arnauld
                        29 mins ago












                      • 1




                        117 bytes
                        – ovs
                        1 hour ago










                      • 114 bytes.
                        – Arnauld
                        29 mins ago







                      1




                      1




                      117 bytes
                      – ovs
                      1 hour ago




                      117 bytes
                      – ovs
                      1 hour ago












                      114 bytes.
                      – Arnauld
                      29 mins ago




                      114 bytes.
                      – Arnauld
                      29 mins ago










                      up vote
                      0
                      down vote














                      R, 106 bytes





                      "["=gsub
                      cat(1["Peter Piper picked",2[" peck of pickled peppers","1 a2.
                      A2 1.
                      If 1 a2,
                      Where's the2 1?"]])


                      Try it online!






                      share|improve this answer
























                        up vote
                        0
                        down vote














                        R, 106 bytes





                        "["=gsub
                        cat(1["Peter Piper picked",2[" peck of pickled peppers","1 a2.
                        A2 1.
                        If 1 a2,
                        Where's the2 1?"]])


                        Try it online!






                        share|improve this answer






















                          up vote
                          0
                          down vote










                          up vote
                          0
                          down vote










                          R, 106 bytes





                          "["=gsub
                          cat(1["Peter Piper picked",2[" peck of pickled peppers","1 a2.
                          A2 1.
                          If 1 a2,
                          Where's the2 1?"]])


                          Try it online!






                          share|improve this answer













                          R, 106 bytes





                          "["=gsub
                          cat(1["Peter Piper picked",2[" peck of pickled peppers","1 a2.
                          A2 1.
                          If 1 a2,
                          Where's the2 1?"]])


                          Try it online!







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered 54 mins ago









                          J.Doe

                          1,381111




                          1,381111



























                               

                              draft saved


                              draft discarded















































                               


                              draft saved


                              draft discarded














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

                              );

                              Post as a guest













































































                              Comments

                              Popular posts from this blog

                              What does second last employer means? [closed]

                              Installing NextGIS Connect into QGIS 3?

                              One-line joke