38
\$\begingroup\$

The goal of this challenge is to print the following tongue twister:

She sells seashells by the seashore,
The shells she sells are seashells, I'm sure.
So if she sells seashells on the seashore,
Then I'm sure she sells seashore shells.

This is more complicated than just calling your language's print equivalent. Since there are a lot of repeated words and phrases, you can greatly decrease the size of your code by using other tactics.

Rules:

  • No querying another website which will respond with the full twister
  • You must include all the punctuation and line breaks in the original text.
  • You can end with a trailing newline

This is , so the shortest code wins!

Good luck!

\$\endgroup\$
6
  • 13
    \$\begingroup\$ While there's a long history of natural-language text compression challenges coming down to a few built-in compression tools and tactics, I'm cautiously optimistic that this text's varied repetition and length will lead to some interesting solutions in at least some languages. \$\endgroup\$
    – xnor
    Commented Jul 1, 2020 at 10:44
  • 8
    \$\begingroup\$ Probably just a pet-peeve of mine, but it always annoys me when a sentence ends in a comma, and the sentence on the next line is capitalized regardless. (Although that might also be related to not being able to use a sentence-capitalize builtin, haha. ;p) \$\endgroup\$ Commented Jul 1, 2020 at 12:25
  • 1
    \$\begingroup\$ It would be easier if the first line used on instead of by. \$\endgroup\$
    – user92069
    Commented Jul 1, 2020 at 12:51
  • \$\begingroup\$ What I made to find optimal solution(s) \$\endgroup\$
    – branboyer
    Commented Jul 9, 2020 at 1:37
  • 1
    \$\begingroup\$ 142 bytes is far from being the shortest answer. That would be "my pronoun is monicareinstate"s Bubblegum answer with 78 bytes. Shortest non-eso answer is my 126 bytes PHP as far as I can see. \$\endgroup\$
    – Titus
    Commented Jul 15, 2020 at 16:19

34 Answers 34

15
\$\begingroup\$

Python 3, 166 \$\cdots\$ 142 135 bytes

Saved a whopping 13 18 bytes thanks to ovs!!!
Saved 4 bytes thanks to user253751!!!
Saved a byte thanks to branboyer!!!
Saved 7 bytes thanks to dingledooper!!!

Note: There's lots of unprintables in the following code so please avert your eyes if you're sensitive to such things! :D

print("Sh by are,.\nSo if onnore.".translate("| seash|ells|ore,\nThe| sh|e s| I'm sure| the".split("|")))

Try it online!

Based on Netråm's C# answer.

\$\endgroup\$
8
  • 1
    \$\begingroup\$ 152 bytes with translate and without the d replacement. (There are some unprintables in the string) \$\endgroup\$
    – ovs
    Commented Jul 1, 2020 at 16:57
  • \$\begingroup\$ 147 bytes by using more unprintables and modifying the first replacement. \$\endgroup\$
    – ovs
    Commented Jul 1, 2020 at 17:11
  • \$\begingroup\$ @user253751 That wasn't saving any bytes in previous incarnations (in fact it was adding bytes) but is now saving 4 bytes - thanks! :-) \$\endgroup\$
    – Noodle9
    Commented Jul 2, 2020 at 22:22
  • \$\begingroup\$ Your string still repeats sea thrice, you could add that too \$\endgroup\$ Commented Jul 3, 2020 at 5:48
  • 2
    \$\begingroup\$ I know this is an old challenge, but here is a 135 byte solution I found with a brute-forcer. \$\endgroup\$ Commented Jan 14, 2021 at 4:06
12
\$\begingroup\$

Retina 0.8.2, 106 103 bytes


S230 by41h012 are30,5.¶So if1230 on4n5123ore1h0.
5
 I'm1ure
4
 the3ore,¶The
3
1eash
2
he10
1
 s
0
ells

Try it online! Explanation: In Retina, a substitution only makes sense if it's long enough l for the number n of repetitions. The substitution saves n(l-1) bytes in the compressed text but costs l+3 bytes in the replacement stages. This gives the minimum length required to be useful as follows:

  • 2 repetitions: length > 5
  • 3 repetitions: length > 3
  • 4 repetitions: length > 3
  • 5 repetitions: length > 2
  • 6+ repetitions: length > 1

Edit: As @Arnauld pointed out, you can count repetitions from the substitution entries as well. This means that although there were only 5 repetitions of space+s in my previous encoded text, there are also 3 repetitions in the substitutions, thus allowing me to save 3 bytes overall. (@Arnauld himself had only spotted 2 of the 3 repetitions.)

\$\endgroup\$
7
  • 1
    \$\begingroup\$ Your first line isn't quite right. Here is a 111-byter I came up with, but you might be able to fix this at no cost. \$\endgroup\$
    – ovs
    Commented Jul 1, 2020 at 11:51
  • \$\begingroup\$ @ovs Ugh, I wonder how far back I accidentally introduced that while golfing... \$\endgroup\$
    – Neil
    Commented Jul 1, 2020 at 12:28
  • \$\begingroup\$ @ovs well, 106 bytes seems reasonable now. would be 100 bytes if the first line used "on" instead of "by" (see Wikipedia). Try it online! \$\endgroup\$
    – Neil
    Commented Jul 1, 2020 at 12:40
  • \$\begingroup\$ 104 bytes with the patterns I used in my answer (except the last one which would result in +1 byte in Retina). \$\endgroup\$
    – Arnauld
    Commented Jul 2, 2020 at 3:09
  • 1
    \$\begingroup\$ @Arnauld Nice, but you missed a trick, you still have two of space+s. \$\endgroup\$
    – Neil
    Commented Jul 2, 2020 at 9:46
11
\$\begingroup\$

JavaScript (ES6),  142  141 bytes

Saved 1 byte thanks to @Neil

_=>`246 / I'm5ure/he56/ the4ore,
The/5eash/ s/ells`.split`/`.reduce((s,p,i)=>s.split(i).join(p),`S0by35h652 are46,1.
So if50on3n1524ore5h6.`)

Try it online!

Compression steps

"ells" -> "6" (9 occurences, saved: 22 bytes)
She s6 seash6 by the seashore,
The sh6 she s6 are seash6, I'm sure.
So if she s6 seash6 on the seashore,
Then I'm sure she s6 seashore sh6.

" s" -> "5" (17 occurences, saved: 14 bytes)
She565eash6 by the5eashore,
The5h65he56 are5eash6, I'm5ure.
So if5he565eash6 on the5eashore,
Then I'm5ure5he565eashore5h6.

"5eash" -> "4" (6 occurences, saved: 18 bytes)
She5646 by the4ore,
The5h65he56 are46, I'm5ure.
So if5he5646 on the4ore,
Then I'm5ure5he564ore5h6.

" the4ore,\nThe" -> "3" (2 occurences, saved: 10 bytes)
She5646 by35h65he56 are46, I'm5ure.
So if5he5646 on3n I'm5ure5he564ore5h6.

"he56" -> "2" (4 occurences, saved: 7 bytes)
S246 by35h652 are46, I'm5ure.
So if5246 on3n I'm5ure524ore5h6.

" I'm5ure" -> "1" (2 occurences, saved: 5 bytes)
S246 by35h652 are46,1.
So if5246 on3n1524ore5h6.

"246 " -> "0" (2 occurences, saved: 1 byte)
S0by35h652 are46,1.
So if50on3n1524ore5h6.
\$\endgroup\$
9
\$\begingroup\$

///, 115 bytes

Port of Neil's answer + accepting nph's suggestion.

/3/ I'm4ure//2/4eash//1/he40//0/ells//4/ s/S120 by the2ore,
The4h041 are20,3.
So if4120 on the2ore,
Then3412ore4h0.

Try it online!

\$\endgroup\$
5
  • 1
    \$\begingroup\$ 126 bytes by using ' s' (notice space) as a substitute. \$\endgroup\$
    – nph
    Commented Jul 1, 2020 at 12:04
  • 1
    \$\begingroup\$ I've bugfixed my answer; does that help you at all? \$\endgroup\$
    – Neil
    Commented Jul 1, 2020 at 12:41
  • \$\begingroup\$ I was... maybe @nph was just confirming that it should help you? \$\endgroup\$
    – Neil
    Commented Jul 1, 2020 at 14:41
  • \$\begingroup\$ @Neil I can't understand nph's behavior... it's bizzare. \$\endgroup\$
    – user92069
    Commented Jul 1, 2020 at 14:55
  • \$\begingroup\$ @Neil I misunderstood. I thought you were talking to me because I just commented. \$\endgroup\$
    – nph
    Commented Jul 1, 2020 at 18:43
9
\$\begingroup\$

05AB1E, 91 86 bytes

“SheÌç1€‹€€0,
The¬•s‚ÎÌ瀙1,2.
So€¬‚ÎÌç1€‰€€0,
Then2‚ÎÌç0¬•s.“2Ý…½š¬•s#'í™ì“I'mˆ•“ª1ú:

Try it online.

Explanation:

“SheÌç1€‹€€0,
The¬•s‚ÎÌ瀙1,2.
So€¬‚ÎÌç1€‰€€0,
Then2‚ÎÌç0¬•s.“  # Push dictionary string "She sells1 by the0,
                 #                         The shells she sells are1,2.
                 #                         So if she sells1 on the0,
                 #                         Then2 she sells0 shells."
2Ý               # Push list [0,1,2]
…½š¬•s           # Push dictionary string "shore shells"
      #          # Split it on spaces: ["shore","shells"]
       'í™ì     '# Prepend dictionary string "sea" in front of both:
                 #  ["seashore","seashells"]
“I'mˆ•“ª        '# Append dictionary string "I'm sure" to this list:
                 #  ["seashore","seashells","I'm sure"]
1ú               # Pad each string with a leading space:
                 #  [" seashore"," seashells"," I'm sure"]
:                # Replace all [0,1,2] with [" seashore"," seashells"," I'm sure"]
                 # (after which the result is output implicitly)

See this 05AB1E tips of mine (section How to use the dictionary?) to understand how the dictionary strings work.

\$\endgroup\$
7
\$\begingroup\$

Bubblegum, 79 78 bytes

removed trailing newline for -1 byte
The text in the tongue twister has many simple patterns. There are enough of them that even "normal" languages can save bytes. However, the only thing DEFLATE does is compressing simple patterns with little overhead...

00000000: 0bce 4855 284e cdc9 2906 9289 c519 6056  ..HU(N..).....`V
00000010: 52a5 4209 5018 2c90 5f94 aac3 1502 e441  R.B.P.,._......A
00000020: e58a e1ea 138b 5211 7a74 143c d573 158a  ......R.zt.<.s..
00000030: 4b8b 52f5 b882 f315 32d3 800a 310d cecf  K.R.....2...1...
00000040: c334 380f ae13 a105 a602 66ab 1e00       .48.......f...

Try it online!

After "writing" this answer, I finally decided to find a way to view the internal representation details of the string (to be specific, information on what characters are printed literally and what substrings are compressed as repetitions via LZ77). I modified kunzip (which already had some useful logging capabilities) to log only the information I want to see. This is the result:

output 83 S
output 104 h
output 101 e
output 32  
output 115 s
output 101 e
output 108 l
output 108 l
output 115 s
len: 3 dist: 6 ( se)
output 97 a
output 115 s
output 104 h
len: 5 dist: 10 (ells )
output 98 b
output 121 y
output 32  
output 116 t
len: 3 dist: 23 (he )
len: 5 dist: 17 (seash)
output 111 o
output 114 r
output 101 e
output 44 ,
output 10
output 84 T
len: 3 dist: 14 (he )
len: 7 dist: 28 (shells )
output 115 s
len: 9 dist: 48 (he sells )
output 97 a
output 114 r
output 101 e
len: 10 dist: 52 ( seashells)
output 44 ,
output 32  
output 73 I
output 39 '
output 109 m
output 32  
output 115 s
output 117 u
output 114 r
output 101 e
output 46 .
output 10
output 83 S
output 111 o
output 32  
output 105 i
output 102 f
len: 3 dist: 41 ( sh)
len: 18 dist: 89 (e sells seashells )
output 111 o
output 110 n
len: 18 dist: 89 ( the seashore,
The)
output 110 n
len: 9 dist: 58 ( I'm sure)
len: 10 dist: 51 ( she sells)
len: 8 dist: 34 ( seashor)
len: 8 dist: 118 (e shells)
output 46 .

I think might will be useful for "normal" language answers.

\$\endgroup\$
5
\$\begingroup\$

C# (Visual C# Interactive Compiler), 171 bytes

string a=" she sells ",b="shells",c="seashore",d=a+"sea"+b;Write(@$"She{d[4..]} by the {c},
The {b}{a}are sea{b}, I'm sure.
So if{d} on the {c},
Then I'm sure{a}{c} {b}.")

Try it online!

The @ allows for line breaks inside string literals.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ You can save 2 bytes by changing the She{d[4..]} to S{d[2..]}. \$\endgroup\$ Commented Jul 2, 2020 at 10:12
  • 1
    \$\begingroup\$ You can save 2 more bytes by changing {b}{a} to {b+a} and {a}{c} to {a+c} \$\endgroup\$ Commented Jul 3, 2020 at 9:30
5
\$\begingroup\$

Stax, 83 bytes

ÇσGª☺Uë\╠╤↑╡V╦⌐∞┐ü9B@♦1ÖFò╫◄«vâ¬♂ƒQn→↨¥p▬♂♥å↓hb½Z╫Éà½♣µ\╩N>.▄┌bæ¼@3▲¡w8╣▐ù☼ve/h{≈ï░

Run and debug it

How?

Unpacked:

`...`'!/|J
`...`      - compressed string "She sells..." with '!' where newlines should be
     '!    - a '!' character
       /   - split the compressed string at '!' characters
        |J - join with newline characters

Maybe making a manual compression using the words will be shorter?

\$\endgroup\$
1
  • \$\begingroup\$ Sometimes using an integer array is shorter. \$\endgroup\$
    – Razetime
    Commented Jan 20, 2021 at 3:35
5
\$\begingroup\$

C# (Visual C# Interactive Compiler), 154 bytes

Write(@"S{0}sea{1} by the {2},
The {1} s{0}are sea{1}, I'm sure.
So if s{0}sea{1} on the {2},
Then I'm sure s{0}{2} {1}.","he sells ","shells","seashore")

Try it online!

\$\endgroup\$
1
5
\$\begingroup\$

Japt, 108 105 104 96 93 92 bytes

`S230 by41h012 ‡e30,d.
So if1230 4˜123Že1h0.`dd` I'm1¨e`4` e3Že,
T”`3`1Á`2`”10`1" s"0`e¥s

Try it online!

Port of the retina answer to Japt.

Explanation

S230 by41h012 ‡e30,d.
So if1230 4˜123Že1h0.

Decompress into the string literal:

S230 by41h012 are30,d.
So if1230 on4nd123ore1h0.

Then we do replacements with:

d
 d` I'm1¨e`     // "d" with " I'm1ure"
 4` e3Že,\nT”`  // "4" with " the3ore,\nThe"
 3`1Á`          // "3" with "1eash"
 2`”10`         // "2" with "he10"
 1" s"          // "1" with " s"
 0`e¥s          // "0" with "ells"
\$\endgroup\$
4
\$\begingroup\$

ink, 129 130 bytes

-(i){|The shells|So if|Then I'm sure} {S|s}he sells {|are |}sea{|||shore }shells{& {on|by} the seashore,|{, I'm sure.|.->END}}
->i

Try it online!

  • +1 byte: A period was missing from the end of a line

Explanation

// Thanks to all the new whitespace, this ungolfed code doesn't quite work as is
-(i)                              // A label
{|The shells|So if|Then I'm sure} // A sequence - the first time we get here we print nothing,
                                  // the second time we print "The shells",
                                  // the third time we print "So if", etc
{S|s}                             // Sequences keep outputting their last value once it's been reached
he sells                          // Plain text just gets printed
{|are |}
sea{|||shore }shells
{& {on|by} the seashore,|{, I'm sure.|.->END}}
                                  // {& marks a repeating sequence.
                                  // Instead of getting stuck on its last value, this it starts over.
                                  // On the fourth pass we hit ->END and terminate the program
->i                               // On the other passes, we get here and go back to the start
\$\endgroup\$
4
\$\begingroup\$

PowerShell, 158 bytes

Because if bash counts then why not...

$1="seash"
$5="ells"
$4="he s$5 "
$6=" I'm sure"
$2="$1$5"
$3="$1`ore"
"S$4$2 by the $3,`nThe $5 s$4`are $2,$6.`nSo if s$4$2 on the $3,`nThen$6 s$4$3 $5"

Try it online!

\$\endgroup\$
2
4
\$\begingroup\$

V (vim), 110 bytes

iS230 by41h012 are30,5.
So if1230 on4n5123ore1h0.Í5/ I'm1ure
Í4/ the3ore,\rThe
Í3/1eash
Í2/he10
Í1/ s
Í0/ells

Try it online!

Port of @Neil's retina answer to V (vim)

\$\endgroup\$
4
\$\begingroup\$

PHP, 133 126 bytes

<?=strtr("S2 s101 by t203,\nT2414e s1 are01,5.\nSo if4e s101 on t203,\nT2n54e s10341.",[" seash",ells,he,ore," sh"," I'm sure"]);

Try it online. Use PHP < 7.2 to avoid warnings

\$\endgroup\$
4
\$\begingroup\$

PowerShell, 134 133 132 bytes

-1 byte thanks @Titus

see similar by Nail and Arnauld

$d='S0by36h461 are54,2.
So if60on3n2615ore6h4.'
"154 #he64# I'm6ure# the5ore,
The#ells#6eash# s"-split'#'|%{$d=$d-replace$i++,$_}
$d

Try it online!

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Lose one more byte by putting " s" last, so you can use it in " seash". Beat my php! \$\endgroup\$
    – Titus
    Commented Jul 6, 2020 at 23:31
  • \$\begingroup\$ Thanks! You made php great again. :) \$\endgroup\$
    – mazzy
    Commented Jul 9, 2020 at 8:28
  • 1
    \$\begingroup\$ Your code inspired me. Excellent shell scripting! I almost wish someone could "bash" me. :D \$\endgroup\$
    – Titus
    Commented Jul 10, 2020 at 17:49
  • \$\begingroup\$ Down to 130 bytes by changing the split syntax and factorizing re \$\endgroup\$
    – Julian
    Commented Mar 29, 2023 at 20:06
3
\$\begingroup\$

Python, 179 176 bytes

print"She sells seashells by the seashore,\nThe shells she sells are seashells, I'm sure.\nSo if she sells seashells on the seashore,\nThen I'm sure she sells seashore shells."

Trivial algorithm, but nobody’s done it yet. I’m working on a better answer in a different language, but I don’t know if it should be posted in another answer or in this one. Shortening advice accepted, but I’m perfectly fine with just hard-coding it for now.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ If you do come up with another answer, you should almost always post it separately. You should generally only include multiple answers in one post if they are extremely similar. Good luck! \$\endgroup\$ Commented Jul 2, 2020 at 4:28
  • 1
    \$\begingroup\$ You have a space you can remove after print, and in Python 2 you can remove the () around the string \$\endgroup\$
    – Stephen
    Commented Jul 2, 2020 at 14:45
3
\$\begingroup\$

JavaScript (V8), 287 bytes

Trying a different way of compressing it, in a different language. Feedback is appreciated!

function s(){a="kdg by the dj,/nThe g care dg, I'm sure./nSo if cdg on the dj,/nThen I'm sure cdj g.".replace(/c|k/g,function(match){return(match=="c")?"she sells ":"She sells ";});c=a.replace(/d|g/g,function(match){return(match=="d")?"sea":"shells";});return (c.replace(/j/g,"shore"));}

Try it online!

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Compressing attempts made it longer, annoyingly. I don't think it can be shorter, but I would appreciate help. \$\endgroup\$ Commented Jul 6, 2020 at 21:14
  • \$\begingroup\$ You could use an arrow function in the replacer? \$\endgroup\$
    – Lebster
    Commented Apr 4, 2021 at 20:31
  • \$\begingroup\$ Hey, you asked for some feedback (a bit late, I know), so I worked through how I'd golf this answer: gist.github.com/dom111/717ecd767f252b883059b9ecaf63ca67 I'm sure there is still a lot of room for improvement, but I hope it's useful! \$\endgroup\$ Commented Jun 18, 2021 at 8:12
3
\$\begingroup\$

Java 8, 169 160 bytes

v->"".format("S%sells by%s shells she sells are seashells, I'm sure.\nSo if s%1$sells on%2$sn I'm sure s%1$sore shells.","he sells seash"," the seashore,\nThe")

Port of @IgbyLargeman's C# answer, so make sure to upvote him as well!
-9 bytes thanks to @branboyer.

Try it online.

(Simply returning as is would be 174 bytes.)

Explanation:

v->           // Method with empty unused parameter and String return-type
  "".format(  //  Return the following formatted string:
     "S%sells by%s
      shells she sells are seashells, I'm sure.\n
     So if s%1$sells on%2$s
     n I'm sure s%1$sore shells.",
    "he sells seash",
              //   Where the first `%s` and all `%1$s` are replaced with "he sells seash"
    " the seashore,\nThe")
              //   and the second `%s` and all `%2$s` are replaced with " the seashore,\n
                                                                         The"
\$\endgroup\$
3
  • 1
    \$\begingroup\$ 160 bytes (This can be ported to the C# code as well of course) I'm attempting to create code that'll find the best solution; that's the best I got right now. \$\endgroup\$
    – branboyer
    Commented Jul 8, 2020 at 2:33
  • 1
    \$\begingroup\$ My github link to the finished project for optimizing this problem (could be used with other similar problems). \$\endgroup\$
    – branboyer
    Commented Jul 9, 2020 at 1:00
  • 1
    \$\begingroup\$ @branboyer Ah nice, I will keep this comment in mind if a similar KC challenge is posted. A brute-forcer to get the shortest substrings is a nice approach. Thanks. \$\endgroup\$ Commented Jul 9, 2020 at 7:19
3
\$\begingroup\$

PicoLisp, 160 157 146 142 138 bytes

(prin(text"S@1 @2 by the @3,
The @5 s@1 are @2,@4.
So if s@1 @2 on the @3,
Then@4 s@1 @3 @5.""he sells"'seashells'seashore" I'm sure"'shells]

Using the template:

S1 by the 2,
The 5 s1 are 2,4.
So if s1 on the 3,
Then4 s1 3 5.

Where 1 is "he sells", 2 is "seashells", 3 is "seashore", and 4 is " I'm sure"

Ideone It!

{ 14 imaginary interweb points for guessing which syntax highlighting I'm using without peeking }

Common Lisp, 160 bytes

(format t"S~a~a by the ~a,~%The shells s~3:*~Aare ~a, I'm sure.~%So if s~3:*~A~a on the ~a,~%Then I'm sure s~3:*~a~*~a shells.""he sells ""seashells""seashore")

https://ideone.com/n7zVUm

\$\endgroup\$
3
\$\begingroup\$

Husk, 77 bytes

ΓJx'p¨½ΞĿ∫Ẏj5pż¦Sβyεḟ?ṡ,ḣŀḢ¦ṠεΞĿ∫äeŻaŀ`◄,İ'm ṡ→.¶ȮSÏf£2₅Φεḟ?ṡ,ḣnİ'm ṡ→⁸ρΘŀḢ¦.

Try it online!

Better than Bubblegum!

Husk's string compression is pretty good for this task, a straightforward compressed string would be 82 bytes long. Here, we apply just a single substitution to make it shorter. The compressed string we use here is

he sells seashpSpells by the seashore,
The shells she sells are seashells, I'm sure.
So if spells on the seashore,
Then I'm sure spore shells.

The structure of the code is:

ΓJx'p¨...
     ¨...  The compressed string
  x'p      split on occurrences of the character 'p'
ΓJ         and joined by interleaving the first substring between the rest

What this does in practice is replacing the character 'p' with "he sells seash" everywhere in the rest of the string. This substitution was the one that generated the shortest compressed string among the ones I've tried; multiple substitutions are possible but they didn't seem worth the longer payload. The letter 'p' was chosen because it generates words like "spell" and "spore" in the text that can be compressed very well by Husk.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ (asking here since the chatroom is locked) What does ƒ do? \$\endgroup\$
    – Razetime
    Commented Jan 20, 2021 at 10:23
3
\$\begingroup\$

Deadfish~, 1313 1234 bytes

iiissiic{ii}icdddc{{d}iii}ic{dd}s{ddd}ic{d}ddddc{i}dddcc{i}dddc{{iiii}iii}dc{dd}s{ddd}ic{d}ddddcddddc{ii}ddc{d}dcdddc{i}dddcc{i}dddc{{iiii}iii}dc{dd}ddsddc{ii}iiic{{d}i}ic{dd}dsdddddc{d}ddcdddc{{d}iii}ic{dd}s{ddd}ic{d}ddddcddddc{ii}ddc{d}dc{i}dddciiic{d}dddc{{ii}}dc{ddd}ddddcdsiiic{ii}cdddc{{d}iii}ic{dd}s{ddd}ic{d}dcdddc{i}dddcc{i}dddc{{iiii}iii}dc{dd}s{ddd}ic{d}dcdddc{{d}iii}ic{dd}s{ddd}ic{d}ddddc{i}dddcc{i}dddc{{iiii}iii}dc{{iii}ii}ic{ii}dddc{d}dddc{{d}iii}ic{dd}s{ddd}ic{d}ddddcddddc{ii}ddc{d}dcdddc{i}dddcc{i}dddc{{d}iii}dc{d}ddc{iiii}ic{ddd}ddddc{{i}ddd}c{{d}ii}iiic{dd}s{ddd}iciicdddc{d}dddc{{ii}}ic{{ii}ii}cdsiic{iii}ddc{{d}ii}ic{{iii}iii}dcdddc{{d}iii}c{dd}s{ddd}ic{d}dcdddc{{d}iii}ic{dd}s{ddd}ic{d}ddddc{i}dddcc{i}dddc{{iiii}iii}dc{dd}s{ddd}ic{d}ddddcddddc{ii}ddc{d}dcdddc{i}dddcc{i}dddc{{iiii}iii}dc{dd}ds{d}cdc{{d}ii}iic{dd}dsdddddc{d}ddcdddc{{d}iii}ic{dd}s{ddd}ic{d}ddddcddddc{ii}ddc{d}dc{i}dddciiic{d}dddc{{ii}}dc{ddd}ddddcdsiiic{ii}cdddc{i}dc{{d}ii}iic{iiii}ic{ddd}ddddc{{i}ddd}c{{d}ii}iiic{dd}s{ddd}iciicdddc{d}dddc{{d}iii}ic{dd}s{ddd}ic{d}dcdddc{{d}iii}ic{dd}s{ddd}ic{d}ddddc{i}dddcc{i}dddc{{iiii}iii}dc{dd}s{ddd}ic{d}ddddcddddc{ii}ddc{d}dc{i}dddciiic{d}dddc{{d}iii}ic{dd}s{ddd}ic{d}dcdddc{i}dddcc{i}dddc{{d}iii}ic

Try it online!

Deadfish, the ungolfing language.

\$\endgroup\$
2
  • \$\begingroup\$ It can be outgolfed best if human mind and generators are combined, nicely done! \$\endgroup\$
    – Wasif
    Commented Jun 15, 2021 at 9:31
  • \$\begingroup\$ @Wasif Not actually human mind, my generator implements that, but not actually anything clever :p \$\endgroup\$
    – emanresu A
    Commented Jun 15, 2021 at 9:36
3
\$\begingroup\$

Deadfish~, 1216 1196 bytes

iiissiici{ii}cdddci{iii{d}}ciii{dd{i}}cdddd{d}cddd{i}ccddd{i}c{{d{{i}}}}ciii{dd{i}}cdddd{d}cddddcdd{ii}cd{d}cdddcddd{i}ccddd{i}c{{d{{i}}}}c{d{i{i}}}ciii{ii}ci{i{d}}c{iiii{iii}}cdd{d}cdddci{iii{d}}ciii{dd{i}}cdddd{d}cddddcdd{ii}cd{d}cddd{i}ciiicddd{d}cd{{ii}}c{d{{i}}}cdsiiic{ii}cdddci{iii{d}}ciii{dd{i}}cd{d}cdddcddd{i}ccddd{i}c{{d{{i}}}}ciii{dd{i}}cd{d}cdddci{iii{d}}ciii{dd{i}}cdddd{d}cddd{i}ccddd{i}c{{d{{i}}}}ci{ii{iii}}cddd{ii}cddd{d}ci{iii{d}}ciii{dd{i}}cdddd{d}cddddcdd{ii}cd{d}cdddcddd{i}ccddd{i}cd{iii{d}}cdd{d}ci{iiii}c{d{{i}}}c{ddd{i}}cd{dd{ii}}ciii{dd{i}}ciicdddcddd{d}ci{{ii}}c{ii{ii}}cdsiicdd{iii}ci{ii{d}}ciii{ddd{i}}cdddc{iii{d}}ciii{dd{i}}cd{d}cdddci{iii{d}}ciii{dd{i}}cdddd{d}cddd{i}ccddd{i}c{{d{{i}}}}ciii{dd{i}}cdddd{d}cddddcdd{ii}cd{d}cdddcddd{i}ccddd{i}c{{d{{i}}}}cd{dd{i}}cdcii{ii{d}}c{iiii{iii}}cdd{d}cdddci{iii{d}}ciii{dd{i}}cdddd{d}cddddcdd{ii}cd{d}cddd{i}ciiicddd{d}cd{{ii}}c{d{{i}}}cdsiiic{ii}cdddcd{i}cii{ii{d}}ci{iiii}c{d{{i}}}c{ddd{i}}cd{dd{ii}}ciii{dd{i}}ciicdddcddd{d}ci{iii{d}}ciii{dd{i}}cd{d}cdddci{iii{d}}ciii{dd{i}}cdddd{d}cddd{i}ccddd{i}c{{d{{i}}}}ciii{dd{i}}cdddd{d}cddddcdd{ii}cd{d}cddd{i}ciiicddd{d}ci{iii{d}}ciii{dd{i}}cd{d}cdddcddd{i}ccddd{i}ci{iii{d}}c

Try it online!

As long as I didn't mess anything up, this should be the shortest possible without () and printing in loops.

\$\endgroup\$
2
\$\begingroup\$

FEU, 112 111 bytes

-1 byte thanks to Neil

a/S256 by43h632 are56,1.\nSo if3256 on4n1325ore3h6.
m/1/ I'm3ure/2/he36/3/ s/4/ the5ore,\nThe/5/ seash/6/ells/g

Try it online!

Port of JavaScript answer.

\$\endgroup\$
1
  • \$\begingroup\$ The 0/256 / replacement only makes sense in the JS answer because the 0 is implicit as the match; here it actually costs you a byte. \$\endgroup\$
    – Neil
    Commented Jul 2, 2020 at 23:47
2
\$\begingroup\$

Python 2, 175 158 bytes

thanks @branboyer for the edit!

print"S{0}ells by{1} shells she sells are seashells, I'm sure.\nSo if s{0}ells on{1}n I'm sure s{0}ore shells.".format("he sells seash"," the seashore,\nThe")

Try it online!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ 158 bytes \$\endgroup\$
    – branboyer
    Commented Jul 9, 2020 at 1:36
  • \$\begingroup\$ 156 bytes Sorry to change so quick \$\endgroup\$
    – branboyer
    Commented Jul 9, 2020 at 2:42
2
\$\begingroup\$

Scala, 155 bytes

printf("S%2$s by%1$s shells%3$sare seashells, I'm sure.\nSo if s%2$s on%1$sn I'm sure%3$sshells."," the seashore,\nThe","he sells seashells"," she sells ")

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Zsh, 128 bytes

<<Z
S${4=${2=he s${1=ells}}${3= seash}$1 }by${5= the$3ore,
The} sh$1 s$2 are$3$1,${6= I'm sure}.
So if s$4on$5n$6 s$2$3ore sh$1.

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Deadfish~, 1269 bytes

iiissiic{ii}icdddc{ddddddd}ic{dd}s{ddd}ic{d}ddddc{i}dddcc{i}dddc{{iiii}iii}dc{dd}s{ddd}ic{d}ddddcddddc{ii}ddc{d}dcdddc{i}dddcc{i}dddc{{iiii}iii}dc{dd}ddsddc{ii}iiic{ddddddddd}ic{dd}dsdddddc{d}ddcdddc{ddddddd}ic{dd}s{ddd}ic{d}ddddcddddc{ii}ddc{d}dc{i}dddciiic{d}dddc{{ii}}dc{ddd}ddddcdsiiic{ii}cdddc{ddddddd}ic{dd}s{ddd}ic{d}dcdddc{i}dddcc{i}dddc{{iiii}iii}dc{dd}s{ddd}ic{d}dcdddc{ddddddd}ic{dd}s{ddd}ic{d}ddddc{i}dddcc{i}dddc{{iiii}iii}dc{{iii}ii}ic{ii}dddc{d}dddc{ddddddd}ic{dd}s{ddd}ic{d}ddddcddddc{ii}ddc{d}dcdddc{i}dddcc{i}dddc{ddddddd}dc{d}ddc{iiii}ic{ddd}ddddc{iiiiiii}c{dddddddd}iiic{dd}s{ddd}iciicdddc{d}dddc{{ii}}ic{{ii}ii}cdsiic{iii}ddc{dddddddd}ic{{iii}iii}dcdddc{ddddddd}c{dd}s{ddd}ic{d}dcdddc{ddddddd}ic{dd}s{ddd}ic{d}ddddc{i}dddcc{i}dddc{{iiii}iii}dc{dd}s{ddd}ic{d}ddddcddddc{ii}ddc{d}dcdddc{i}dddcc{i}dddc{{iiii}iii}dc{dd}ds{d}cdc{dddddddd}iic{dd}dsdddddc{d}ddcdddc{ddddddd}ic{dd}s{ddd}ic{d}ddddcddddc{ii}ddc{d}dc{i}dddciiic{d}dddc{{ii}}dc{ddd}ddddcdsiiic{ii}cdddc{i}dc{dddddddd}iic{iiii}ic{ddd}ddddc{iiiiiii}c{dddddddd}iiic{dd}s{ddd}iciicdddc{d}dddc{ddddddd}ic{dd}s{ddd}ic{d}dcdddc{ddddddd}ic{dd}s{ddd}ic{d}ddddc{i}dddcc{i}dddc{{iiii}iii}dc{dd}s{ddd}ic{d}ddddcddddc{ii}ddc{d}dc{i}dddciiic{d}dddc{ddddddd}ic{dd}s{ddd}ic{d}dcdddc{i}dddcc{i}dddc{ddddddd}ic

Try it online!

\$\endgroup\$
2
\$\begingroup\$

Knight, 138 bytes

O+S=q+=sS=v" shells"4F" se"=tSvT0"sea"F2"S"+" by"+=p" the seashore,
The"+v+s+" are"+t+=u" I'm sure.
So if"+q+S" onn"3Fp+GuF9+s+Gp 4 9+v"."

Try it online!

Fiiiiiiiine, I'll explain it

Attempt at explaining it

Sorry, the indentation is a little inconsistent...

OUTPUT
 +
  # substitute " s" with "S" for initial capitalization
  SUBSTITUTE(
   = _she_sells_seashells
    + = _she_sells
     # inject " se" into "shells"
     # to get "she sells"
     SUBSTITUTE(
       = _shells " shells"
       4
       0
       " se"
      )
    # inject "sea" to get " seashells"
    = _seashells
       SUBSTITUTE(
        _shells
        1
        0
        "sea"
       )
    )
    0
    2
    "S"
   )
  + " by"
  + = _the_seashore_the " the seashore,\nThe"
  + _shells
  + _she_sells
  + " are"
  + _seashells
  + = _im_sure_so_if "  I'm sure.\nSo if"
  + _she_sells_seashells
  # shorter to inject than concatenate
  # to get " on the seashore,\nThen"
  + SUBSTITUTE(
     " onn"
     3
     0
     _the_seashore_the
    )
  # Extract "I'm sure"
  + GET(
     _im_sure_so_if
     0
     9
    )
  + _she_sells
  # " seashore"
  + GET(
     _the_seashore_the
     4
     9
    )
  + _shells
  : "."
\$\endgroup\$
2
  • \$\begingroup\$ explanation por favor \$\endgroup\$
    – Sampersand
    Commented Jun 17, 2021 at 8:03
  • \$\begingroup\$ Even the creator of Knight himself can't decipher my magical code? ¡Ay caramba! \$\endgroup\$
    – EasyasPi
    Commented Jun 17, 2021 at 14:00
1
\$\begingroup\$

Bash, 156 bytes

i=" I'm sure"
h=" she"
k=lls
l=" seashe"$k
s=" seashore"
e=" se"$k
printf "She$e$l by the$s,
The$h$k$h$e are$l,$i.
So if$h$e$l on the$s,
Then$i$h$e$s$h$k."

An expert can probably save some more here.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Consider using Try it online! - it counts your bytes and also creates MarkDown for you. \$\endgroup\$
    – Neil
    Commented Jul 2, 2020 at 23:58
  • \$\begingroup\$ 151 bytes \$\endgroup\$
    – branboyer
    Commented Jul 9, 2020 at 3:27
1
\$\begingroup\$

zlib, 84 bytes

Hex dump:

00000000: 78 9c 0b ce 48 55 28 4e cd c9 29 06 92 89 c5 19  x...HU(N..).....
00000010: 60 56 52 a5 42 09 58 18 28 90 5f 94 aa c3 15 02  `VR.B.X.(._.....
00000020: e2 41 e4 8a e1 ea 13 8b 52 11 7a 74 14 3c d5 73  .A......R.zt.<.s
00000030: 15 8a 4b 8b 52 f5 b8 82 f3 15 32 d3 90 14 22 0c  ..K.R.....2...".
00000040: ce cf c3 34 38 0f ae 13 5d 4b 7e 11 cc 56 3d 00  ...48...]K~..V=.
00000050: 3c 70 3a e6                                      <p:.

Raw hex:

789c0bce4855284ecdc929069289c519605652a54209581828905f94aac31502e241e48ae1ea138b52117a74143cd573158a4b8b52f5b882f31532d39014220ccecfc334380fae135d4b7e11cc563d003c703ae6

Or generate this file yourself:

openssl zlib < seashells.txt > seashells.zlib

You can decompress this file execute this program with:

openssl zlib -d < seashells.zlib

or, presumably, any of the answers here.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Assuming I remember what header is used by gzip and what header is used by zlib, If you remove the first two bytes, this becomes a Bubblegum answer. (note that I already posted a shorter one) \$\endgroup\$ Commented Jul 3, 2020 at 2:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.