Sing Baby Shark

73

15

"Baby Shark" is a children's song about a family of sharks. Having long been popular as a campfire song, it has been popularized since the mid-2000s by social media, online video and radio. - Wikipedia

Write program that takes no input, and writes the following text to the standard output or an arbitrary file:

Baby Shark doo doo doo doo doo doo
Baby Shark doo doo doo doo doo doo
Baby Shark doo doo doo doo doo doo
Baby Shark!
Daddy Shark doo doo doo doo doo doo
Daddy Shark doo doo doo doo doo doo
Daddy Shark doo doo doo doo doo doo
Daddy Shark!
Mommy Shark doo doo doo doo doo doo
Mommy Shark doo doo doo doo doo doo
Mommy Shark doo doo doo doo doo doo
Mommy Shark!
Grandpa Shark doo doo doo doo doo doo
Grandpa Shark doo doo doo doo doo doo
Grandpa Shark doo doo doo doo doo doo
Grandpa Shark!
Grandma Shark doo doo doo doo doo doo
Grandma Shark doo doo doo doo doo doo
Grandma Shark doo doo doo doo doo doo
Grandma Shark!

This is code golf — shortest code wins.

Found this on Reddit^1^2, and it seems like an interesting challenge to golf.

Updates:

No newline between stanzas, that makes it too easy :)

Leading/trailing newlines are okay.

njha

Posted 2019-02-16T01:36:20.137

Reputation: 939

6Is a newline between each stanza (each shark) acceptable? (That's always how I've seen the lyrics written) – Quintec – 2019-02-16T02:00:28.743

1(See above comment, since you've responded to my other ones but seem to have skipped this one) – Quintec – 2019-02-16T15:15:56.260

Updated original post. I know you could save a few bytes by doing \n before every stanza (that way you don't have to avoid making a newline at the end), but people already started doing it this way so I think keeping it as is is fair. – njha – 2019-02-16T15:46:03.160

6Eh, missing a few verses, like all the ones about the swimmers swimming and losing limbs in shark attacks. – mbomb007 – 2019-02-16T17:23:43.203

1Are leading or trailing newlines or spaces permitted? Can we return an array of lines? – Shaggy – 2019-02-16T19:57:37.293

Leading/trailing newlines are okay, arrays wouldn't be (unless they printed to stdout/a file in the correct format. – njha – 2019-02-16T20:54:45.330

Why is the mommy/daddy and grandma/grandpa order switched in your post? I'd be susprised if any of the answers change byte counts if you corrected it. – MooseBoys – 2019-02-17T06:43:15.460

2"doo doo doo doo doo doo" is really over-simplified. – R.. GitHub STOP HELPING ICE – 2019-02-17T23:54:29.520

27As a parent, I feel the strongest urge to downvote this one. I'm repressing the urge because that's not how Stack Exchange works. But if I find myself humming "doo doo doo doo" later today, I'm coming back here and holding you accountable! – Cort Ammon – 2019-02-18T17:22:42.113

5How many people's days ruined now that this is on HNQs? – CactusCake – 2019-02-18T19:49:07.147

@CactusCake, our days are often ruined here by some of the challenges that make into HNQ! :D – Shaggy – 2019-02-18T21:53:19.247

2I find myself restraining myself to say "doo doo doo doo" after reading this challenge. – MilkyWay90 – 2019-02-20T03:36:48.987

2@CortAmmon I personally found the song so bad I couldn't listen to it long enough for it to become an earworm. I see "doo doo doo" and think "come on and do the conga" instead. Well, that or "push pineapple, shake a tree" – Baldrickk – 2019-02-20T12:07:15.580

1How does the Wikipedia article for this not have any lyrics or describe the hand motions? I guess adults are just that tired of this song... – JPhi1618 – 2019-02-20T15:11:27.437

1The new FizzBuzz? :) – Captain Man – 2019-02-20T17:01:32.343

@CortAmmon been there, done that, got the t-shirt (Christmas present from my daughter). In fact now I'm humming in danger of humming it to a metal backing track! – Chris H – 2019-02-21T12:09:19.840

Amazing! I can't believe this is the first time this was thought of. – AJFaraday – 2019-11-20T16:09:54.737

@nija I don't think removing the newline makes it any harder... – None – 2020-01-23T06:03:17.357

Answers

10

SOGL, 40 bytes

o⅝ηvΒvPΝ┘÷ΖnΨ‘θ{"nOe;‘+ū:" doo”6*+TTPPļ!

Try it here!

dzaima

Posted 2019-02-16T01:36:20.137

Reputation: 19 048

78

Emojicode, 292 bytes (140 characters)

Baby➡️bDaddy➡️yMommy➡️oGrandpa➡️gGrandma➡️a Shark➡️s doo➡️db y o g a➡️fm fi⏩⏩0 3❗️m s d d d d d d️❗️m s!❗️

Run it

Expanded out:


  Baby ➡️ b
  Daddy ➡️ y
  Mommy ➡️ o
  Grandpa ➡️ g
  Grandma ➡️ a
   Shark ➡️ s
   doo ➡️ d
  b y o g a➡️f
  m f
    i⏩⏩0 3❗️
      m s d d d d d d️❗️
    
    m s!❗️
  

Explained (per the Emojicode doc):


The same as a { and } (e.g. a code block)


The "program start" (e.g. int main())

Baby ➡️ b

Variable assignment (e.g. const char* b = "Baby";)

b y o g a➡️f

Says, create a list of values between and and assign (➡️) to f (e.g. const char* f[] = {b,y,o,g,a};)

m f ... 

This line says to loop over the elements in f using the alias m, where the ... is the code between and .

 i ⏩⏩ 0 3❗️ ... 

This line says to loop over the range [0,3), where the ... is the code between and .

 ... ️❗️

This line says to print the format specified in ... (e.g. printf("%s\n");)

The code translated to C:

#include <stdio.h>

int main() {
  const char* b = "Baby";
  const char* y = "Daddy";
  const char* o = "Mommy";
  const char* g = "Grandpa";
  const char* a = "Grandma";
  const char* s = " Shark";
  const char* d = " doo";
  const char* f[] = {b,y,o,g,a};
  int m = 0, i = 0;
  for (; m < 5; ++m) {
    for (i = 0; i < 3; ++i) {
      printf("%s%s%s%s%s%s%s%s\n", f[m], s, d, d, d, d, d, d);
    }
    printf("%s%s!\n", f[m], s);
  }
  return 0;
}

Following this, the original code (posted below for posterity) had some issues; mostly that the block was not included for those who wish to run it, and the emoji's were not actually properly escaped, to that, here is the actual running version of that code:

Original modified to run: Emojicode, 224 bytes (67 characters)

➡️fm fi⏩⏩0 3❗️m️❗️m!❗️

Expanded out:


  
    
    
    
    
    
   ➡️ f
   m f 
     i ⏩⏩ 0 3❗️
      m️❗️
    
    m!❗️
  

Which produces the output:




!



!



!



!



!

Run it

Where in you have the individual emoji's representing the words:

 -> Baby
 -> Daddy
 -> Mommy
 -> Grandpa
 -> Grandma
 -> Shark
 -> doo

Original: Emojicode, 138 bytes (47 characters)

➡️fm fi⏩⏩0 3❗️m❗️m!❗️

Expanded out:

➡️f
m f
   i ⏩⏩ 0 3❗️
     m ❗️
  
   m !❗️

txtechhelp

Posted 2019-02-16T01:36:20.137

Reputation: 845

32Points for creativity, but this doesn't produce the required output – Jo King – 2019-02-17T10:23:56.417

15Welcome to the site! As JoKing was getting at we require that answers do exactly what the question ask here. This means that while your interpretation of the challenge is creative this answer should either be fixed to produce the correct output or deleted. – Post Rock Garf Hunter – 2019-02-17T14:10:49.373

12While this answer is creative, it does not follow the requirements of the challenge, and thus is not valid - the text must be output exactly as stated in the challenge. – Mego – 2019-02-17T20:17:30.757

8Please either modify this answer to produce the correct output, or delete it. – mbomb007 – 2019-02-18T19:55:03.437

5You need half the poop emojis, since is "doo doo" :) While I agree it's not a valid entry, you definitely deserve points for creativity. – Flater – 2019-02-19T09:44:01.123

6

Welcome to the site! When I try to run this code online, I get an error. (It also counts 98 characters instead of 94). Am I missing something?

– James – 2019-02-19T18:28:21.107

2+1 now you've also included the textual output. :) But I indeed noticed the same thing as @DJMcMayhem in both Emojicode and Emojicode 0.5 on TIO. Is TIO a different version and it therefore errors? Or is your submission a function instead of full program and do we need anything more in the header/footer? I don't know Emojicode, but I'm curious why it doesn't work on TIO. – Kevin Cruijssen – 2019-02-20T07:45:18.313

2@DJMcMayhem .. I honestly didn't think this would get such recognition, so I learned Emojicode in about 5 minutes and threw together this answer in about 15 minutes for fun :) That being said, I've since had a few more minutes to learn the language more and have modified the answer to run properly. That'll teach me to joke around!❗️ – txtechhelp – 2019-02-21T00:06:14.837

This answer has earned more reputation than I have. Emojicode for the win! – MilkyWay90 – 2019-03-02T19:46:09.273

35

IBM PC DOS, 8088 assembly, 108 bytes

00000000: bd43 01e8 1600 bd48 01e8 1000 bd4e 01e8  .C.....H.....N..
00000010: 0a00 bd54 01e8 0400 c646 056d b409 b103  ...T.....F.m....
00000020: 8bd5 cd21 ba5c 01cd 21e3 1249 b306 ba63  ...!.\..!..I...c
00000030: 01cd 214b 75fb ba69 01cd 21eb e3ba 6801  ..!Ku..i..!...h.
00000040: cd21 c342 6162 7924 4461 6464 7924 4d6f  .!.Baby$Daddy$Mo
00000050: 6d6d 7924 4772 616e 6470 6124 2053 6861  mmy$Grandpa$ Sha
00000060: 726b 2420 646f 6f24 210d 0a24            rk$ doo$!..$

Unassembled:

BD 0143         MOV  BP, OFFSET BABY        ; Baby Shark
E8 011C         CALL VERSE
BD 0148         MOV  BP, OFFSET DADDY       ; Daddy Shark
E8 011C         CALL VERSE
BD 014E         MOV  BP, OFFSET MOMMY       ; Mommy Shark
E8 011C         CALL VERSE
BD 0154         MOV  BP, OFFSET GRAND       ; Grandpa/ma Shark
E8 011C         CALL VERSE
C6 46 05 6D     MOV  BYTE PTR [BP][5], 'm'  ; change 'p' to 'm'
                                            ; fall through for last verse
            VERSE:
B4 09           MOV  AH, 9                  ; DOS API display string function
B1 03           MOV  CL, 3                  ; loop verse three times
            LOOP_VERSE:
8B D5           MOV  DX, BP                 ; load shark name from BP
CD 21           INT  21H                    ; display shark name
BA 015C         MOV  DX, OFFSET SHARK       ; load 'Shark'
CD 21           INT  21H                    ; display 'Shark'
E3 12           JCXZ LAST_VERSE             ; if last verse, skip to !
49              DEC  CX                     ; decrement verse count
B3 06           MOV  BL, 6                  ; loop 'doo' 6 times
BA 0163         MOV  DX, OFFSET DOO         ; load  'doo' string
            LOOP_DOO:
CD 21           INT  21H                    ; display 'doo'
4B              DEC  BX                     ; decrement doo count
75 FB           JNZ  LOOP_DOO               ; if not last doo, start again
BA 0169         MOV  DX, OFFSET CRLF        ; load CRLF string
CD 21           INT  21H                    ; display CRLF
EB E3           JMP  LOOP_VERSE
            LAST_VERSE:
BA 0168         MOV  DX, OFFSET BANG        ; display !, CRLF
CD 21           INT  21H
C3              RET                         ; return from CALL / return to DOS

BABY    DB  'Baby$'
DADDY   DB  'Daddy$'
MOMMY   DB  'Mommy$'
GRAND   DB  'Grand'
PA      DB  'pa$'
SHARK   DB  ' Shark$'
DOO     DB  ' doo$'
BANG    DB  '!'
CRLF    DB  0DH,0AH,'$'

Output

DOS DIR, SHARK

Download SHARK.COM!

  • -5 bytes thanks to @Deadcode

640KB

Posted 2019-02-16T01:36:20.137

Reputation: 7 149

7You absolute madman. – MGOwen – 2019-02-20T00:34:46.627

9When you said Download SHARK.COM!, I immediately thought of computer viruses. – MilkyWay90 – 2019-02-20T16:40:22.757

@gwaugh I was kidding – MilkyWay90 – 2019-02-20T16:46:07.640

@gwaugh But it's 109 bytes – MilkyWay90 – 2019-02-20T16:50:24.230

21

Python 2, 93 bytes

for w in"Baby Daddy Mommy Grandpa Grandma".split():w+=" Shark";print(w+" doo"*6+"\n")*3+w+"!"

Try it online!

94 bytes

for w in"Baby Daddy Mommy Grandpa Grandma".split():print((" doo"*6+"\n%s Shark"%w)*4)[25:]+"!"

Try it online!

xnor

Posted 2019-02-16T01:36:20.137

Reputation: 115 687

18

05AB1E, 50 41 bytes

“‡ÍÊТ×myîºpaîºma“#ð«'㢫™v…doo6иyšÐy'!«»

Last part v4FN3Qiy'!«ë…doo6иyšðý}, can definitely be golfed a bit.. And I was right, -9 bytes thanks to @Emigna (even more than I was expecting).

Try it online.

Explanation:

“‡ÍÊТ×myîºpaîºma“ # Push dictionary string "baby daddy mommy grandpa grandma"
 #                 # Split by spaces: ["baby","daddy","mommy","grandpa","grandma"]
  ð«               # Append a space to each
    '㢫          '# Append dictionary string "shark" to each
        ™          # Title-case each word
v                  # Loop `y` over these strings
 …doo              #  Push string "doo"
     6и            #  Repeat it 6 times as list
       yš          #  Prepend the string `y` at the front of the list
         Ð         #  Triplicate this list
 y'!«             '#  Push string `y`, concatted with a "!"
 »                 #  Join everything on the stack by newlines
                   #  (and each list implicitly by spaces)
                   # (and after the loop, output the result implicitly)

See this 05AB1E tip of mine (section How to use the dictionary?) to understand why “‡ÍÊТ×myîºpaîºma“ is "baby daddy mommy grandpa grandma" and '㢠is "shark".

Kevin Cruijssen

Posted 2019-02-16T01:36:20.137

Reputation: 67 575

2You can golf 9 bytes of that last bit with v…doo6иyšÐy'!«» – Emigna – 2019-02-16T16:01:03.433

@Emigna You even golfed more than I was expected, thanks! Smart way of using the triplicate and »! – Kevin Cruijssen – 2019-02-16T17:27:11.270

15

PowerShell, 88 86 85 80 79 76 bytes

-5 bytes thanks to @mazzy
-1 byte thanks to @Joey
-3 bytes thanks to @AdmBorkBork

echo Baby Daddy Mommy Grandpa Grandma|%{,(($a="$_ Shark")+" doo"*6)*3;"$a!"}

Try it online!

We've certainly come a long way.

PowerShell (with Text to Speech), 156 bytes

This is NOT up to spec, but it's kinda funny. Thanks to @rkeet for the idea!

Add-Type -a System.Speech;echo Baby Daddy Mommy Grandpa Grandma|%{(New-Object Speech.Synthesis.SpeechSynthesizer).Speak((($a="$_ Shark")+" doo"*6)*3+" $a")}

.NET Text to speech pronunciation is... well... interesting. Keep this in mind when listening. Enjoy!

Gabriel Mills

Posted 2019-02-16T01:36:20.137

Reputation: 778

280 bytes :) – mazzy – 2019-02-16T07:29:49.560

1You can save another byte by assigning "$_ Shark" to a variable and re-using it. – Joey – 2019-02-18T11:00:30.290

276 bytes using echo instead of -split. – AdmBorkBork – 2019-02-19T20:27:21.970

1

I think you should have a "text to speech" in there as well :p For the hell of it tried to combine it a bit with this code, didn't quite work :-)

– rkeet – 2019-02-20T09:04:43.680

@rkeet Challenge accepted! I am currently puzzling this out. – Gabriel Mills – 2019-02-20T14:34:42.507

11

Java (JDK), 135 bytes

v->{for(var s:"Baby Daddy Mommy Grandpa Grandma".split(" "))System.out.println(((s+=" Shark")+" doo".repeat(6)+"\n").repeat(3)+s+"!");}

Try it online!

Olivier Grégoire

Posted 2019-02-16T01:36:20.137

Reputation: 10 647

Which JDK version? I'm guessing 8+ (lambdas). – NoOneIsHere – 2019-02-17T19:46:58.217

3@NoOneIsHere Given the repeat method, it's version 11+ – Olivier Grégoire – 2019-02-17T21:44:06.507

9

Python 3, 105 97 96 bytes

for x in"Baby","Daddy","Mommy","Grandpa","Grandma":z=x+' Shark';print((z+' doo'*6+"\n")*3+z+"!")

Try it online!

A simple Python 3 solution. (9 bytes saved by Jo King and Quintec)

njha

Posted 2019-02-16T01:36:20.137

Reputation: 939

2The parentheses around ' doo'*6 are unnecessary and you have unnecessary whitespace there – Quintec – 2019-02-16T02:06:12.927

1

What quintec said... 97 bytes

– Jo King – 2019-02-16T02:07:17.717

Huh, didn't know you could do lists without [], or that you didn't need a newline for :. Thanks! – njha – 2019-02-16T02:12:21.273

2@ReverseCold technically where there's no [] it's a tuple not a list, but that's not relevant to this program – Stephen – 2019-02-16T02:58:16.370

296 bytes by setting x+' Shark' to a variable – Jo King – 2019-02-16T08:07:58.013

1This seems to work in 2.7 as well? – uhoh – 2019-02-19T01:54:58.540

1@uhoh In 2.7 you can get rid of the brackets in the print function and cut it down to 94 bytes – LogicianWithAHat – 2019-02-19T09:20:55.150

You can shave one more character if you do x+= instead of z=x+ (replacing subsequent uses of z with x) – wordbug – 2019-02-25T17:00:50.003

9

Retina 0.8.2, 77 75 74 bytes


Baby¶Daddy¶MommyGpaGma
G
¶Grand
.+
$&s$&s$&s$&S!
s
S6$*O¶
O
 doo
S
 Shark

Try it online! Explanation:


Baby¶Daddy¶MommyGpaGma
G
¶Grand

Insert the relations on separate lines.

.+
$&s$&s$&s$&S!¶

Expand into four lines.

s
S6$*O¶
O
 doo
S
 Shark

Expand the placeholders.

69 68 bytes in Retina 1:


Baby¶Daddy¶MommyGpaGma
G
¶Grand
.+
$& Shark
.+
3*$($&6*$( doo)¶)$&!

Try it online! Explanation:


Baby¶Daddy¶MommyGpaGma
G
¶Grand

Insert the relations on separate lines.

.+
$& Shark

Append Shark to each.

.+
3*$($&6*$( doo)¶)$&!

Expand into whole verses.

Neil

Posted 2019-02-16T01:36:20.137

Reputation: 95 035

9

Haskell, 122 113 108 106 104 bytes

s=" Shark";m=do x<-words"Baby Daddy Mommy Grandpa Grandma";("aaa">>x++s++(s>>" doo")++"\n")++x++s++"!\n"

Try it online!

  • "aaa">>x replicates x 3 times, as "aaa" has length 3.

  • s>>" doo" replicates " doo" 6 times, as " Shark" has length 6!

  • 2 bytes saved thanks to @Fox

  • 2 bytes saved thanks to @Laikoni

starsandspirals

Posted 2019-02-16T01:36:20.137

Reputation: 91

2

Welcome to the site! We allow just generating a fixed output string as an expression, so you can omit the main=putStr. See also the Haskell rules summary.

– xnor – 2019-02-16T21:54:49.977

1Welcome to PPCG. Nice saving with s>>. – Shaggy – 2019-02-16T22:05:26.207

@xnor thanks for the links! – starsandspirals – 2019-02-16T22:09:13.150

@starsandspirals I also recommend taking a look at the Haskell golf tips if you haven't already.

– xnor – 2019-02-16T22:20:46.170

1m=(stuff) can just be m=stuff for two fewer bytes – Fox – 2019-02-17T21:42:10.127

1

104 bytes by using do-notation: Try it online!

– Laikoni – 2019-02-18T07:55:23.270

8

bash, 78 bytes

printf %s\\n {Baby,Daddy,Mommy,Grand{p,m}a}\ Shark{" `echo doo{,,}{,}`"{,,},!}

TIO

73 bytes if trailing space is allowed

echo '
'{Baby,Daddy,Mommy,Grand{p,m}a}\ Shark{" `echo doo{,,}{,}`"{,,},!}

Nahuel Fouilleul

Posted 2019-02-16T01:36:20.137

Reputation: 5 582

7

Perl 6, 79 78 bytes

(<Baby Daddy Mommmy Grandpa Grandma>X~" Shark"X~ |((" doo"x 6)xx 3),'!')>>.say

Try it online!

Pretty simple.

Explanation:

 <...>X~                                  # Combine family members
        " Shark"X~                        # With "Shark" and
                   |((" doo"x 6)xx 3)     # doo repeated 6 times then 3 times
                                     ,'!' # Then !
(                                        )>>.say  # And print each line

Jo King

Posted 2019-02-16T01:36:20.137

Reputation: 38 234

7

JavaScript, 104 bytes

More golfing to follow.

_=>`Baby
Daddy
Mommy
Grandpa
Grandma`.replace(/.+/g,x=>(s=(x+=` Shark`)+` doo`.repeat(6)+`
`)+s+s+x+`!`)

Try It Online!

Shaggy

Posted 2019-02-16T01:36:20.137

Reputation: 24 623

1This technically isn't a valid solution since it neither writes to a file or logs it. Though if you make it a valid solution by wrapping with a console.log(), you can make it not a lambda declaration (only 10 character gain) – Delioth – 2019-02-18T21:13:27.637

3@Delioth, returning from a function is perfectly valid on this site. Have a look on Meta for our default I/O rules. – Shaggy – 2019-02-18T21:43:12.303

2I would generally agree, but this question specifically states that the program "writes the following text to the standard output or an arbitrary file" – Delioth – 2019-02-18T21:51:30.337

6

///, 124 bytes

/*/$!
//)/Grand//(/Baby//'/Mommy//&/Daddy//%/ doo//$/ Shark//#/a")//"/$%%%%%%
/("("("(*&"&"&"&*'"'"'"'*)p#p#p#pa*)m#m#m#ma$!

Try it online!

Conor O'Brien

Posted 2019-02-16T01:36:20.137

Reputation: 36 228

6

Ruby, 82 bytes

%w(Baby Daddy Mommy Grandpa Grandma).map{|a|puts [a+" Shark"]*4*(" doo"*6+?\n)+?!}

Try it online!

Kirill L.

Posted 2019-02-16T01:36:20.137

Reputation: 6 693

It took me a while to understand that you used the "doo" part as array seperators. Good job :) – Idva – 2019-02-18T13:11:13.357

?\n can be replaced with $/. – Value Ink – 2019-11-20T21:27:36.103

6

PostgreSQL, 162 156 138 bytes

select a||' Shark'||replace(b,'1',repeat(' doo',6))from unnest('{Baby,Daddy,Mommy,Grandpa,Grandma}'::text[])a,unnest('{1,1,1,!}'::text[])b

Ungolfed

select 
    a || ' Shark' || replace(b,'1',repeat(' doo',6))
from unnest('{Baby,Daddy,Mommy,Grandpa,Grandma}'::text[]) a
    ,unnest('{1,1,1,!}'::text[]) b

Saved 6 24 bytes thanks to @Nahuel Fouilleul!

  • use || instead of concat()
  • use unnest('{foo,bar}'::text[]) instead of regexp_split_to_table('foo,bar')

DB<>fiddle

Peter Vandivier

Posted 2019-02-16T01:36:20.137

Reputation: 211

2

-6 bytes using ||instead of concat View on DB Fiddle

– Nahuel Fouilleul – 2019-02-18T09:22:48.950

2select a||' Shark'||replace(b,'1',repeat(' doo',6))from unnest('{Baby,Daddy,Mommy,Grandpa,Grandma}'::text[])a,unnest('{1,1,1,!}'::text[])b – Nahuel Fouilleul – 2019-02-18T09:48:29.373

5

><>, 158 115 bytes

Saved a lot of bytes thanks to Jo King

>4>1-&0'krahS '0l3-.
~ ^oa~<
ooo:?!/1-'ood 'o
\ao'!'^?$6:&~
\!?:o
^'ybaB'
^'yddaD'
^'ymmoM'
^'apdnarG'
^'amdnarG'
;

Try it online! You may also want to paste the code in at fishlanguage.com, where you can see an animation of it swimming running.

DLosc

Posted 2019-02-16T01:36:20.137

Reputation: 21 213

121 bytes, mostly through rearranging the baby/daddy/... to multiple lines instead of one line. There's more to golf though – Jo King – 2019-02-16T08:58:22.320

115 bytes – Jo King – 2019-02-16T09:24:52.097

@JoKing Ah, thanks. I tend to assume (mostly from working with BitCycle) that fewer lines are better, but in this case that's not true because of the different string lengths. – DLosc – 2019-02-16T21:27:13.187

5

Haskell, 97 bytes

unlines[x++s++p|x<-words"Baby Daddy Mommy Grandpa Grandma",p<-[a,a,a,"!"]]
s=" Shark"
a=s>>" doo"

Try it online!

This is an optimization of the Haskell solution by starsandspirals. The new trick is to iterate over the rows of each stanza with an inner loop, and join the lines using unlines, saving the need to explicitly insert newlines.

The suffixes of the four lines are [a,a,a,"!"], where a is " doo" replicated 6 times with a=s>>" doo", where starsandspirals cleverly reuses the six-character-long s=" Shark". Writing [a,a,a,...] looks a bit silly, but I'm not seeing a shorter way.

A list-monad version is the same length but it looks cool.

unlines$(++).(++s)<$>words"Baby Daddy Mommy Grandpa Grandma"<*>[a,a,a,"!"]
s=" Shark"
a=s>>" doo"

Try it online!

xnor

Posted 2019-02-16T01:36:20.137

Reputation: 115 687

5

Emotion, 65 bytes

Explanation

 Push literal doo
 Push five copies of the first stack value.
 Collapse all stack values into a string seperated by spaces, then push that string.
 Push literal  Shark 
 Push the difference of the second and first stack values.
 Store the first stack value in the a register.
 Push literal Grandma
 Push literal Grandpa
 Push literal Mommy
 Push literal Daddy
❤ Push literal Baby
 Push literal 6
 Push stack values into a list of the size of the first stack value starting with the second stack value.
 Enter an iteration block over the first stack value and push the iteration element register at the begining of each loop.
 Push three copies of the first stack value.
 Push literal 3
 Enter an iteration block over the first stack value.
 Push the value contained in the a register.
 Push the sum of the second and first stack values.
 Print the first stack value, then a newline.
 Ends a control flow structure.
 Push literal  Shark!
 Push the sum of the second and first stack values.
 Print the first stack value, then a newline.
 Ends a control flow structure.

Try it online!

Quantum64

Posted 2019-02-16T01:36:20.137

Reputation: 371

4

C# (Visual C# Interactive Compiler), 153 131 bytes

foreach(var i in"Baby Daddy Mommy Grandpa Grandma".Split()){var a=i+" Shark doo doo doo doo doo doo\n";Write(a+a+a+i+" Shark!\n");}

Thanks to @Destrogio for saving 30 bytes!

Try it online!

Embodiment of Ignorance

Posted 2019-02-16T01:36:20.137

Reputation: 7 014

133 - Try it online!

– Destroigo – 2019-02-19T15:48:02.127

4

R, 131 122 120 bytes

-9 bytes thanks to Giuseppe

-2 more bytes, also Giuseppe

`?`=c
s="Shark"
for(x in "Baby"?"Daddy"?"Mommy"?"Grandpa"?"Grandma")cat(rep("
"?x?s?rep("doo",6),3)?"
"?x?paste0(s,"!"))

Try it online!

Quite proud of this actually, especially with R being rather poor at handling strings. I started out using cat(sapply(...)), but realized a for loop shaves off a few bytes.

Abusing the "?"=c significantly reduced the amount of parentheses needed.

I also tried to do "*"=rep to repeat the individual lines of the stanzas and the "doos", but that did not shave off any bytes.

111 bytes

Giuseppe and ASCII-only's alternative, (and better) solution that fixes some spacing issues.

write(paste0(rep(c("Baby","Daddy","Mommy","Grandpa","Grandma"),,,4)," Shark",c(rep(strrep(" doo",6),3),"!")),1)

Try it online!

Sumner18

Posted 2019-02-16T01:36:20.137

Reputation: 1 334

1122 bytes – Giuseppe – 2019-02-19T16:06:29.013

As always, thank you for your wise input @Giuseppe. I should have noticed those golfs – Sumner18 – 2019-02-19T17:59:04.260

1120 bytes – Giuseppe – 2019-02-19T19:08:53.280

I think you should ask OP whether leading spaces are ok – ASCII-only – 2019-02-19T22:35:29.020

@ASCII-only I'm pretty certain it's a leading newline, and the additional rules near the bottom say that that is okay. The OP even detailed this concern in the comments, saying "Updated original post. I know you could save a few bytes by doing \n before every stanza (that way you don't have to avoid making a newline at the end), but people already started doing it this way so I think keeping it as is is fair." – Sumner18 – 2019-02-19T23:08:13.720

Do you not also print two spaces before every line since you're printing a vector :| – ASCII-only – 2019-02-19T23:27:52.377

@ASCII-only I found a 120 byter that has none of these problems.

– Giuseppe – 2019-02-21T14:21:17.213

1

@Giuseppe wow, vectorization, nice. I forgot R has nice vectorization like this. 114? also 114?

– ASCII-only – 2019-02-21T22:49:52.043

1also 114 – ASCII-only – 2019-02-21T22:55:01.130

@ASCII-only hah, I had found a very similar 115 byter commented below...So naturally we can combine to get this 111 byte monstrosity

– Giuseppe – 2019-02-21T23:03:26.953

3

C (gcc), 123 122 bytes

-1 byte thanks to ceilingcat

#define A" doo doo"
f(i){for(i=20;i--;)printf("%.7s Shark%s\n","GrandmaGrandpaMommy\0 Daddy\0 Baby"+i/4*7,i%4?A A A:"!");}

Try it online!

gastropner

Posted 2019-02-16T01:36:20.137

Reputation: 3 264

What are the rules for C? No need for main(), or #include for printf? – BoBTFish – 2019-02-21T08:19:19.800

@BoBTFish: Not C-specific but generally it is allowed to use any function (name doesn't matter, indeed it can be an unnamed lambda or similar). And languages are defined by their (any) implementation, since this works on gcc (only generates warnings, but compiles fine) it is valid. – ბიმო – 2019-02-22T14:27:29.790

I realised the lack of #include was only an error because I was still compiling as C++, but I still couldn't get it to compile without renaming your function to main. – BoBTFish – 2019-02-22T15:30:59.230

3

whenyouaccidentallylose100endorsementsinnationstates - 123,065 121,716 113,695 100,889 98,554 bytes

The program

I'll golf this later. Done.

I'll golf this more (later) Done.

I'll golf this even more later. DONE.

I'll get the byte count to 5 digits later. YAY.

I'll get the byte count to 4 digits (I don't know if this is possible, but I do know it is impossible to get 3 digits with my current approach).

MilkyWay90

Posted 2019-02-16T01:36:20.137

Reputation: 2 264

What the hell is this? I love it – Adrian Zhang – 2019-02-19T01:21:51.367

@AdrianZhang A programming language hard to program it. Also, the program looks like it's a person screaming ('AAAAAAAAAAA...') – MilkyWay90 – 2019-02-19T01:47:51.403

3

PHP, 104 bytes

foreach([Baby,Daddy,Mommy,Grandpa,Grandma]as$s)echo$t=$s.str_pad($u=" Shark",30," doo"),"
$t
$t
$s$u!
";

Run with php -nr '<code>' or try it online.

Titus

Posted 2019-02-16T01:36:20.137

Reputation: 13 814

1103 bytes – Night2 – 2019-09-02T11:37:03.763

3

R, 139 138 137 bytes

s='Shark';d='doo';cat(paste(rep(c('Baby','Daddy','Mommy','Grandpa','Grandma'),e=4),c(rep(paste(s,d,d,d,d,d,d),3),paste0(s,'!'))),sep='
')

There's probably a better way to do the 'doo's but I wasn't able to get it.

Edit:
Replaced '\n' with actual new line at JDL's suggestion;
Removed trailing newline at Giuseppe's suggestion.

Try it online

CT Hall

Posted 2019-02-16T01:36:20.137

Reputation: 591

welcome to ppcg! At the very least, replacing the "\n" with a literal newline will save one byte. – JDL – 2019-02-19T13:34:40.937

Thanks, I did so, and then realized my output was bit off so I updated that, sadly it resulted in more bytes. – CT Hall – 2019-02-19T15:50:41.497

I believe you have a trailing newline for an extra byte – Giuseppe – 2019-02-19T16:08:03.853

3

R, 126 125 bytes

cat(paste(rep(c("Baby","Daddy","Mommy","Grandpa","Grandma"),,,4),c(rep("Shark doo doo doo doo doo doo",3),"Shark!")),sep="
")

This doesn't feel as 'clever' as either CT Hall or Sumner18's answers, but by avoiding the overhead of defining variables it comes out smaller.

Try it online!

Edit: Saved 1 byte by using carriage return as per comment by Jonathan Frech

BobbyBean

Posted 2019-02-16T01:36:20.137

Reputation: 31

Hello and welcome to PPCG! I have added links to the user's answers you mentioned to better compare your solutions. Congratulations on outgolfing both, could you add a link to an online testing environment for ease of verification? – Jonathan Frech – 2019-02-19T13:13:33.130

Thanks for the edit @JonathanFrech. I have now added a link to test the code online (which added a byte to my answer!). – BobbyBean – 2019-02-19T14:07:15.950

You can use an actual new line instead of \n to bring your byte count one back down again. – Jonathan Frech – 2019-02-19T14:10:59.997

125 bytes – Giuseppe – 2019-02-19T16:10:30.173

1Well I've been totally outgolfed; sometimes the simplest option is best. Also highlights how difficult it is to work with strings in R. – CT Hall – 2019-02-19T17:41:42.933

115 bytes -- this is quite similar to my suggested edits to Sumner18's answer, but I've worked on improving all three of the R answers, so now all three approaches have been sloshing in my head and I don't know whose to comment on... – Giuseppe – 2019-02-21T20:18:06.460

3

Plain TeX, 147 Bytes

\input pgffor\def\D{doo~}\def\d{\D\D\D\D\D\D}\def\S{Shark}\def\y{\x~\S~\d\par}\foreach\x in{Baby,Mommy,Daddy,Grandma,Grandpa}{\y\y\y\x~\S!\par}\bye

Rather disappointing, but I haven't posted a TeX answer in ages. Loops are very verbose in teX (and looping over strings isn't even built-in so even this is a bit of a stretch)

Chris H

Posted 2019-02-16T01:36:20.137

Reputation: 581

2

cQuents, 93 89 bytes

|
#20&bk)~" Shark"~(" doo"6,Z,Z,bk)~" Shark!"
:"Baby","Daddy","Mommy","Grandpa","Grandma"

Try it online!

Note that as of posting TIO is not updated to the latest version, so the TIO link may not work.

Explanation

|                               Set delimiter to newline
#20                             n = 20
   &                            Output first n terms in sequence
                                k = 1
                                First term is
    bk)~" Shark"                 kth term from the third line concatenated to " Shark"
                ~(" doo"6,        concatenated to " doo" repeated 6 times
Z,Z,                            Second and third terms equal the first term
    bk)~" Shark!"               Fourth term is the kth term from the third line concatenated to " Shark!"
                                k += 1, restart

Third line                      5 terms, each a string

Stephen

Posted 2019-02-16T01:36:20.137

Reputation: 12 293

2

JavaScript (Node.js), 132 bytes

Probably very golf-able. Generates the "doo doo" line, then creates three of those with the "!" line after, and repeats this for each shark.

a=""
c=" doo"
for(b of["Baby","Daddy","Mommy","Grandpa","Grandma"]){b+=" Shark"
t=b+c+c+c+c+c+c+"\n"
a+=t+t+t+b+"!\n"}console.log(a)

Try it online!

Neil A.

Posted 2019-02-16T01:36:20.137

Reputation: 2 038

A slightly changed solution in Javascript, no gain though: a="";c=" doo";for(b of["Baby","Daddy","Mommy","Grandpa","Grandma"]){b+=" Shark";t=b+c.repeat(6)+"\n";a+=t+t+t+b+"!\n"}console.log(a) – BogdanBiv – 2019-02-19T08:52:24.607

2

Japt -R, 55 bytes

Pretty naïve first pass.

`baß'adÝcomæ²T\`èT\`µ`qi Ë'!i4Æ` Srk`iDhDÎuÃqRi6ç` ºo

Test it

Shaggy

Posted 2019-02-16T01:36:20.137

Reputation: 24 623

2

Stax, 43 bytes

ÇÉ╕µM%╠2'§t╪╝½ôòn=n╢/╬╦Φ▲Vêø■T⌂g^N┴W.ìC↕ƒ·Φ

Run and debug it

recursive

Posted 2019-02-16T01:36:20.137

Reputation: 8 616

2

PHP, 153 147 bytes

<?php $s='Shark';$d=str_pad('',23,'doo ');foreach(explode(' ','Baby Daddy Mommy Grandpa Grandma')as$a){echo str_repeat("$a $s $d\n",3),"$a $s!\n";}

Thanks to @manatwork for saving 6 bytes by pointing out str_pad('',23'doo '); is shorter than rtrim(str_repeat('doo ',6));

Try it online!

EvanBarbour3

Posted 2019-02-16T01:36:20.137

Reputation: 21

Unfortunately even $d='doo doo doo doo doo doo' is shorter than that rtrim()+str_repeat() combination. :( But fortunately $d=str_pad('',23,'doo ') is even shorter. For more optimization tips, see Tips for golfing in PHP.

– manatwork – 2019-02-18T15:33:21.707

@manatwork Thanks for pointing that out, I've updated the post to reflect – EvanBarbour3 – 2019-02-18T16:17:55.390

1

In meantime found some time to play a bit more: Try it online!

– manatwork – 2019-02-18T16:44:57.547

113 bytes. Welcome to PPCG! – Shaggy – 2019-02-18T23:44:07.090

Oop, didn't see your last comment before posting mine, @manatwork. – Shaggy – 2019-02-18T23:45:22.870

2109 bytes – Shaggy – 2019-02-18T23:53:13.247

2

JavaScript (134 126 bytes)

-2 bytes thanks to Stephen! -6 bytes thanks to mgthomas99!

["Baby","Daddy","Mommy","Grandma","Grandpa"].forEach(a=>console.log((a+" shark"+" doo".repeat(6)+"\n").repeat(3)+a+" Shark!"))

JS Fiddle

Aldemaro

Posted 2019-02-16T01:36:20.137

Reputation: 21

Can save two bytes: a + " -> a+" – Stephen – 2019-02-18T16:36:36.253

Wow I was working on a JS solution and barely managed to get to 170 bytes. Your use of repeat is genius! – Matthew Ludwig – 2019-02-18T22:51:54.587

1You can save 2 bytes by removing the parentheses around the arrow function parameters (so that (a)=> becomes a=>). You can save another 2 bytes by removing the braces around the arrow function body. I'm also not certain you need the explicit newline at the end of the console.log statement, and removing that should save you another 2 bytes. – mgthomas99 – 2019-02-19T09:53:50.250

The first shark should be capitalised – Jo King – 2019-03-22T05:26:39.363

2

jq, 87 characters

" Shark"as$s|("Baby Daddy Mommy Grandpa Grandma"/" ")[]|(.+$s+" doo"*6+"\n")*3+.+$s+"!"

Sample run:

bash-4.4$ jq -nr '" Shark"as$s|("Baby Daddy Mommy Grandpa Grandma"/" ")[]|(.+$s+" doo"*6+"\n")*3+.+$s+"!"'
Baby Shark doo doo doo doo doo doo
Baby Shark doo doo doo doo doo doo
Baby Shark doo doo doo doo doo doo
Baby Shark!
Daddy Shark doo doo doo doo doo doo
Daddy Shark doo doo doo doo doo doo
Daddy Shark doo doo doo doo doo doo
Daddy Shark!
Mommy Shark doo doo doo doo doo doo
Mommy Shark doo doo doo doo doo doo
Mommy Shark doo doo doo doo doo doo
Mommy Shark!
Grandpa Shark doo doo doo doo doo doo
Grandpa Shark doo doo doo doo doo doo
Grandpa Shark doo doo doo doo doo doo
Grandpa Shark!
Grandma Shark doo doo doo doo doo doo
Grandma Shark doo doo doo doo doo doo
Grandma Shark doo doo doo doo doo doo
Grandma Shark!

Try it online!

manatwork

Posted 2019-02-16T01:36:20.137

Reputation: 17 865

2

Jelly, 51 bytes

;“¤⁾ċ»;“¡N³»ẋ6¤;”¶ẋ3;;“ß<Ė»
“þɗ“¡þ"“£H$“æf⁵“æeⱮ»Ç€Y

Try it online!

Jelly isn't the best for string manipulation. Still pretty good.

If you expand out the strings to their ungolfed form, the code looks like this:

;“ Shark”;“ doo”ẋ6¤;“¶”ẋ3;;“ Shark!”
“Baby“Daddy“Mommy“Grandpa“Grandma”Ç€Y

(The string compression was done using user202729's compressor).

;“ Shark”;“ doo”ẋ6¤;“¶”ẋ3;;“ Shark!”   Helper Link; take a string and format it into a stanza
;“ Shark”                              Append " Shark" to the string
         ;                             Join
                  ¤                    Previous links as a single nilad
          “ doo”                       " doo"
                ẋ6                            repeated 6 times
                   ;“¶”                Append a newline
                       ẋ3              Repeat 3 times
                         ;             Append the string
                          ;“ Shark!”   Append " Shark!"
“Baby“Daddy“Mommy“Grandpa“Grandma”Ç€Y  Main link
“Baby“Daddy“Mommy“Grandpa“Grandma”     ["Baby", "Daddy", "Mommy", "Grandpa", "Grandma"]
                                  ǀ   For each of these words, format it into the stanza with that family position
                                    Y  Join by newlines

HyperNeutrino

Posted 2019-02-16T01:36:20.137

Reputation: 26 575

2

Farm, 1157 8971 bytes

-260 bytes: apparently only cock a doodle doo needs spaces..

No sharks on my farm:

cock a doodle doomoocotmoobzzcoucoumewmewmewmewmewmewmewgobblehihihimoopiuarfarfarfarfarfarfarfrouuuleomoopiumoosquealhihihimewmooleoarfarfarfrouuuleomoomoocotmoopiuarfarfarfmooleoarfarfarfarfmoomoocoucouarfarfarfssscoinsssgruntcoinblatcoinssscoinblatcoinssscoinblatmoosssgruntmooblatarfarfarfarfarfarfsssmoogruntmoogruntmoogruntgruntcoincoincoinmewblatmoosssmooblatmoosssmooblatcoinmewblatcoinsssgruntcoinblatcoinssscoinblatcoinssscoinblatmoosssgruntmooblatcotarfgruntsssmewblatmoosssmooblatmoogobblesquealmewmoopiuarfmoopiumooroararfmooarfarfarfarfarfarfarfarfarfarfmoohihihimooarfarfmooarfarfarfmoopiumoosssmewmooarfcoinblatroararfarfarfmoomoohihihimooleoarfarfrouuuleomooleomooleoarfarfmooarfarfarfarfarfarfarfarfarfmoomoohihihipiumooleoarfarfarfmoopiuarfarfarfmoomewmoopiumooleoarfarfarfarfarfmooroararfarfarfarfarfarfmooarfarfarfarfarfarfarfarfarfarfmoohihihimoomewmewmewsssmooblathihihihowl

Try it online!


1: Could be 9 less by using cocorico over cock a doodle doo..

ბიმო

Posted 2019-02-16T01:36:20.137

Reputation: 15 345

Why not use cocorico then :P – ASCII-only – 2019-02-22T14:16:04.100

1@ASCII-only: Because I found the language by searching doo on esolangs, lol – ბიმო – 2019-02-22T14:17:10.447

1The self-graduating add-on for PPCG leaderboard thinks that this is 1 byte. Can you change the <sup>1</sup> to <sup>see bottom</sup> – MilkyWay90 – 2019-06-05T22:01:07.860

2

Javascript, 125 123 bytes

['Baby','Daddy','Mommy','Grandpa','Grandma'].flatMap(x=>[...[,,,].fill(' doo'.repeat(6)),'!'].map(y=>x+' Shark'+y)).join`
`

Try it online!

Coert Grobbelaar

Posted 2019-02-16T01:36:20.137

Reputation: 131

2

Jelly, 42 bytes

“¡N³»ẋ6Wẋ3;”!ṭ€;Y
“¡ʂɓṙṢ®ÑR+£ṭỤṙ»Ḳ瀓¤⁾ċ»Y

Try it online!

How?

“¡N³»ẋ6Wẋ3;”!ṭ€;Y - Link 1: make a verse: familyMember; space+animalName
                  -                        e.g. "Baby"; " Shark"
“¡N³»             - dictionary word " doo"
     ẋ6           - repeat 6 times -> " doo doo doo doo doo doo"
       W          - wrap in a list -> [" doo d..."]
        ẋ3        - repeat 3 times -> [" doo d..."," doo d..."," doo d..."]
           ”!     - literal '!' character
          ;       - concatenate    -> [" doo d..."," doo d..."," doo d...","!"]
               ;  - concatenate inputs ["Baby Shark"]
             ṭ€   - tack for €ach  -> [["Baby Shark"," doo d..."],...,["Baby Shark","!"]]
                Y - join with newline characters

“¡ʂɓṙṢ®ÑR+£ṭỤṙ»Ḳ瀓¤⁾ċ»Y - Main Link: no arguments
“¡ʂɓṙṢ®ÑR+£ṭỤṙ»          - dictionary words "Baby"+" Daddy"+" Mommy"+" Grandpa"+" Grandma"
               Ḳ         - split at spaces -> ["Baby","Daddy","Mommy","Grandpa","Grandma"]
                  “¤⁾ċ»  - dictionary word " Shark"
                ç€       - call last Link (1) as a dyad for €ach
                       Y - join with newline characters
                         - implicit print

Jonathan Allan

Posted 2019-02-16T01:36:20.137

Reputation: 67 804

2

05AB1E, 39 38 bytes

”‡ÍÊТ×myîºpaîºma”#„o€·À6×3и'!ª”㢔ìâ»

Try it online!

”‡ÍÊТ×myîºpaîºma”                # compressed string "Baby Daddy Mommy Grandpa Grandma"
                  #               # split on spaces
„o€·                              # dictionary string "o do"
    À                             # rotated left: " doo"
     6×                           # string-repeat 6 times: " doo doo doo doo doo doo"
       3и                         # list-repeat 3 times
         '!ª                      # append "!" to that list
            ”ã¢”ì                 # prepend "Shark" to each element of that list
â                                 # cartesian product
 »                                # join by newlines
                                  # implicit output

Grimmy

Posted 2019-02-16T01:36:20.137

Reputation: 12 521

2

Kotlin 121 bytes

"Baby Daddy Mommy Grandpa Grandma".split(" ").map{(println(("${"$it Shark${" doo".repeat(6)}\n".repeat(3)}$it Shark!")))}


Try it online!

JeRoll

Posted 2019-02-16T01:36:20.137

Reputation: 21

1

J, 85 bytes

echo('Shark'(,&'!',~(24$' doo')(3#,:)@,~])@,~]);.2'Baby Daddy Mommy Grandpa Grandma '

Try it online!

Note: This assumes a blank line between stanzas is ok. If that's not the case, prepending ,/ to my solution for +2 bytes.

Jonah

Posted 2019-02-16T01:36:20.137

Reputation: 8 729

1

Attache, 79 bytes

$Baby'$Daddy'$Mommy'$Grandpa'$Grandma+" Shark":>Print@{(_+" doo"*6+lf)*3+_+"!"}

Try it online!

An attempt at compressing the above iteration array is NTS@N=>Split[S@FromBase[Ords@")!-ZOW]NE.kK3(*F(a3\\z6fXD_\\yEM"-32,95],"00"], which is significantly longer than the trivial encoding above. Compressing the string using base conversion in its entirety would likely come out to be longer.

Alternatives

81 bytes: Print@{(_+" doo"*6+lf)*3+_+"!"}=>($Baby'$Daddy'$Mommy'$Grandpa'$Grandma+" Shark")

82 bytes: Output!{(_+" doo"*6+lf)*3+_+"!"}=>($Baby'$Daddy'$Mommy'$Grandpa'$Grandma+" Shark")

86 bytes: Output!(""'3&(" doo"*6+lf)'"!")&Join=>($Baby'$Daddy'$Mommy'$Grandpa'$Grandma+" Shark")

87 bytes: Output!(""'3&(" doo"*6+lf)'"!")&Join@`+&" Shark"=>$Baby'$Daddy'$Mommy'$Grandpa'$Grandma

Conor O'Brien

Posted 2019-02-16T01:36:20.137

Reputation: 36 228

1

Perl 5, 84 bytes

print (map{join(" doo"x6,("\n$_ Shark")x4),"!"}qw(Baby Daddy Mommy Grandpa Grandma))

Try it online!

Rubio

Posted 2019-02-16T01:36:20.137

Reputation: 111

73 bytes – Nahuel Fouilleul – 2019-02-17T19:27:32.503

168 bytes – Xcali – 2019-02-19T03:19:09.767

1

VBA (Excel), 152 118 bytes

-34 bytes. Thanks @TaylorScott

Using Immediate Window.

a=Split("Baby Daddy Mommy Grandpa Grandma"):b=" Shark":c=" doo":For d=0To 19:?a(Int(d/4))b &IIf((d+1)Mod 4=0,"!",Join(Split(String$(6,"."),"."),c)):Next

a=Split("Baby Daddy Mommy Grandpa Grandma"):b=" Shark":For d=0To 19:?a(d\4)b;IIf((d+1)Mod 4,[Rept(" doo",6)],"!"):Next

remoel

Posted 2019-02-16T01:36:20.137

Reputation: 511

1You should use integer division instead of casting an int over division - so Int(d/4) goes to d\4 , you can rearrange the arguements of the IIf statement to get rid of the =0 and then you can convert that really nifty join split statement with a Rept statement. All together this becomes a=Split("Baby Daddy Mommy Grandpa Grandma"):b=" Shark":For d=0To 19:?a(d\4)b;IIf((d+1)Mod 4,[Rept(" doo",6)],"!"):Next for 118 Bytes – Taylor Scott – 2019-02-18T22:03:41.560

Totally forgot Rept function lol. Your answer is way better than mine you should've post it as your own answer. Anyways, thanks for cutting off huge bytes to my wall of code. lol. d\4 <-- Didn't know this until now. Thanks! :D – remoel – 2019-02-19T04:48:08.080

1I get far more joy out of helping others get better with VBA, than I do writing it myself - Cheers – Taylor Scott – 2019-02-19T21:54:12.157

1

Clean, 134 bytes

import StdEnv,Text
r=repeatn
f=join"\n"[e+" Shark"+concat s\\e<-split" ""Baby Daddy Mommy Grandpa Grandma",s<-r 3(r 6" doo")++[["!"]]]

Try it online!

Οurous

Posted 2019-02-16T01:36:20.137

Reputation: 7 916

1

F# (.NET Core), 179 bytes

["Baby";"Daddy";"Mommy";"Grandpa";"Grandma"]|>Seq.map(fun i->([0..2]|>Seq.map(fun _->i+" Shark doo doo doo doo doo doo")|>String.concat "\n")+"\n"+i+" Shark!")|>String.concat "\n"

Try it online!

No input, export to a string and to std output in a console.

145 bytes

for i in["Baby";"Daddy";"Mommy";"Grandpa";"Grandma"]do(for _ in[0..2]do printfn"%s"(i+" Shark doo doo doo doo doo doo"));printfn"%s"(i+" Shark!")

Try it online!

No input, export to std output

aloisdg moving to codidact.com

Posted 2019-02-16T01:36:20.137

Reputation: 1 767

1

F# (.NET Core), 160 156 bytes

let c,r,s=String.concat,List.replicate," Shark"
let p n=r 3(c" "(n+s::r 6"doo"))@[n+s+"!"]
["Baby";"Daddy";"Mommy";"Grandpa";"Grandma"]|>Seq.collect p|>c"
"

Try it online!

And based on @aloisdg version, I get this one:

F# (.NET Core), 130 129 bytes

let p,d=printfn"%s Shark%s"," doo doo"
for i in["Baby";"Daddy";"Mommy";"Grandpa";"Grandma"]do(for _ in"123"do p i (d+d+d));p i"!"

Try it online!

Gaining 1 more char by changine [0..2] by "123" wich is also a sequence of 3 items...

thinkbeforecoding

Posted 2019-02-16T01:36:20.137

Reputation: 131

1

groovy, 96 bytes

'Baby Daddy Mommy Grandpa Grandma'.split().any{n="$it Shark";println((n+" doo"*6+'\n')*3+n+'!')}

Try it online!

Matias Bjarland

Posted 2019-02-16T01:36:20.137

Reputation: 420

Protip: esc -> s -> g on the TryItOnline page for a well formatted post – ASCII-only – 2019-02-19T22:37:47.637

close – ASCII-only – 2019-02-20T00:06:58.623

also close – ASCII-only – 2019-02-20T01:17:26.860

1

brainfuck, 627 593 573 bytes

Initialise Array with "Baby\0Daddy\0Mommy\0Grandpa\0Grandma"
Loop runs 71 times
++[++++++++++++++++++
    Get array cells to approximately correct values
    >>>+>>+++++>>+++++>>-->>>>+>>+++++>>+++++>>+++++>>-->>>>+>>-->>-->>-->>-->>>>+>>-->>+++++>>-->>+++++>>-->>+++++>>>>+>>-->>+++++>>-->>+++++>>-->>+++++
    [[<<]<<]>
]
Finish getting cells to correct values
>>>---->>->>>>++++++++>>+>>-->>->>++>>++>>++++++++>>+>>+++++++>>-->>---->>---->>++++++++>>+>>+>>+>>->>--->>++>>->>->>+>>+>>+>>->>--->>++>>---->>-
Inject ones between each cell in the array
[-<+<]>[>>]+

Initialise an exclamation mark; newline; and the string " Shark"
>>>+++++++++++[+++++++
    >------->+>>+>----->+++>+++>---->+++
    <<<<<<<<<
]
>->-->>--->++>->-------->-->++
[<]
Go to the end of the "Baby" Array to loop
<<<<<<[
    >>>
    Loop 3 times
    +++[-
        Go to the first value of the baby array
        <<<[<<]>>>
        Print the word out
        [.>>]
        Go to the shark array
        >[>>]>>>>>
        Print " Shark"
        [.>]
        <[<]
        Loop 6 times
        ++++++[-
            Print a space
            >.
            Change the 'a' in " Shark" to a 'd' and print
            >>>+++.---
            Change the 'r' in " Shark" to an 'o' and print twice
            >---..+++
            <<<<<
        ]
        Print newline
        <<.
        <
    ]
    Go to start of baby array
    <<<[<<]>>
    Print and consume the first string in the array
    ->[.[-]>->]
    Go to shark string
    >[>>]>>>>>
    Print " Shark"
    [.>]
    <[<]
    Print "!\n"
    <.<.
    <<<<
]

-20B thanks to Jo King

Try it online!

Sasha

Posted 2019-02-16T01:36:20.137

Reputation: 431

1

T-SQL, 151 bytes

SELECT REPLACE(a.value+' Shark'+b.value,'Q',REPLICATE(' doo',6))
FROM STRING_SPLIT('Baby,Daddy,Mommy,Grandpa,Grandma',',')a,STRING_SPLIT('Q,Q,Q,!',',')b

Line break for readability only.

SQL's built-in function names are annoyingly long.

STRING_SPLIT works in SQL 2016 and later.

Order isn't 100% guaranteed without an ORDER BY, but this seemed to work in my testing.

BradC

Posted 2019-02-16T01:36:20.137

Reputation: 6 099

It seems sql answers are not popular, very nice answer. Which means a lot comming from me – t-clausen.dk – 2019-04-04T21:31:45.173

Thanks, @t-clausen.dk! – BradC – 2019-04-04T22:00:07.570

1

Japt -R, 58 57 bytes

`BabysDaddysMommysGÎÀpGÎÀµ`qÅ˱` Srk` +` ºo`³²+R ³+D+'!

Run it online

Oliver

Posted 2019-02-16T01:36:20.137

Reputation: 7 160

1

Underload, 93 89 bytes

(Grandma)(Grandpa)(Mommy)(Daddy)(Baby)(~( Shark)*:( doo)::**:**(
)*::**S(!
)*S):^:^:^:^:^

Since Underload is really good at duplicating and concatenation with strings, I decided to give this a go.

Saved 4 bytes by re-arranging things.

Try it online!

Explanation

(Grandma)  Pushes 'Grandma'
(Grandpa)  Pushes 'Grandpa'
(Mommy)  Pushes 'Mommy'
(Daddy)  Pushes 'Daddy'
(Baby)   Pushes 'Baby'
(  Add the next bit of code to the stack
~  Swaps so the name of the Shark (eg: Baby) is on the top of the stack
( Shark)  Pushes ' Shark' to the stack
*  Concatenates ' Shark' to the name of the Shark
:  Duplicates the top of the stack
( doo)  Pushes ' doo'
::**:*  Turns it into ' doo doo doo doo doo doo'
*  Concatenates it to the '[name] Shark'
(<Newline>)*  Concatenates a newline to the string, making it '[Name] Shark doo doo doo doo doo doo[Newline]'
::**   Duplicates it twice
S  Outputs the first three lines of the stanza
(![Newline])*S Concatenates '![Newline]' to the '[Name] Shark' string and prints it
)  Ends the code being added to the stack
:^:^:^:^:  Runs the code in the bracket 5 times, for the 5 different stanzas

EdgyNerd

Posted 2019-02-16T01:36:20.137

Reputation: 1 106

1

Babylang, 2866 bytes

aaag aaag gagu aaag aaag aaag aaag aaag aaag aaag aaag aaag aaag aaag aaag aaag aaag aaag aaag aaag aaag gaga gaga gaga aaag gaga gaga aaag aaag aaag aaag aaag gaga gaga aaag aaag aaag aaag aaag gaga gaga uuug uuug gaga gaga gaga gaga aaag gaga gaga aaag aaag aaag aaag aaag gaga gaga aaag aaag aaag aaag aaag gaga gaga aaag aaag aaag aaag aaag gaga gaga uuug uuug gaga gaga gaga gaga aaag gaga gaga uuug uuug gaga gaga uuug uuug gaga gaga uuug uuug gaga gaga uuug uuug gaga gaga gaga gaga aaag gaga gaga uuug uuug gaga gaga aaag aaag aaag aaag aaag gaga gaga uuug uuug gaga gaga aaag aaag aaag aaag aaag gaga gaga uuug uuug gaga gaga aaag aaag aaag aaag aaag gaga gaga gaga gaga aaag gaga gaga uuug uuug gaga gaga aaag aaag aaag aaag aaag gaga gaga uuug uuug gaga gaga aaag aaag aaag aaag aaag gaga gaga uuug uuug gaga gaga aaag aaag aaag aaag aaag gagu gagu gugu gugu guga gugu gugu guga gaga guga gaga gaga gaga uuug uuug uuug uuug gaga gaga uuug gaga gaga gaga gaga aaag aaag aaag aaag aaag aaag aaag aaag gaga gaga aaag gaga gaga uuug uuug gaga gaga uuug gaga gaga aaag aaag gaga gaga aaag aaag gaga gaga aaag aaag aaag aaag aaag aaag aaag aaag gaga gaga aaag gaga gaga aaag aaag aaag aaag aaag aaag aaag gaga gaga uuug uuug gaga gaga uuug uuug uuug uuug gaga gaga uuug uuug uuug uuug gaga gaga aaag aaag aaag aaag aaag aaag aaag aaag gaga gaga aaag gaga gaga aaag gaga gaga aaag gaga gaga uuug gaga gaga uuug uuug uuug gaga gaga aaag aaag gaga gaga uuug gaga gaga uuug gaga gaga aaag gaga gaga aaag gaga gaga aaag gaga gaga uuug gaga gaga uuug uuug uuug gaga gaga aaag aaag gaga gaga uuug uuug uuug uuug gaga gaga uuug gagu uuug gugu aaag gugu guga gaga gagu gaga gaga guga aaag gaga gaga gaga aaag aaag aaag aaag aaag aaag aaag aaag aaag aaag aaag gagu aaag aaag aaag aaag aaag aaag aaag gaga uuug uuug uuug uuug uuug uuug uuug gaga aaag gaga gaga aaag gaga uuug uuug uuug uuug uuug gaga aaag aaag aaag gaga aaag aaag aaag gaga uuug uuug uuug uuug gaga aaag aaag aaag gugu gugu gugu gugu gugu gugu gugu gugu gugu guga gaga uuug gaga uuug uuug gaga gaga uuug uuug uuug gaga aaag aaag gaga uuug gaga uuug uuug uuug uuug uuug uuug uuug uuug gaga uuug uuug gaga aaag aaag gagu gugu guga gugu gugu gugu gugu gugu gugu gagu gaga gaga gaga aaag aaag aaag gagu uuug gugu gugu gugu gagu gugu gugu guga gaga gaga gaga gagu guuu gaga gaga guga gaga gagu gaga gaga guga gaga gaga gaga gaga gaga gagu guuu gaga guga gugu gagu gugu guga aaag aaag aaag aaag aaag aaag gagu uuug gaga guuu gaga gaga gaga aaag aaag aaag guuu uuug uuug uuug gaga uuug uuug uuug guuu guuu aaag aaag aaag gugu gugu gugu gugu gugu guga gugu gugu guuu gugu guga gugu gugu gugu gagu gugu gugu guga gaga gaga uuug gaga gagu guuu gagu uuug guga gaga uuug gaga guga gaga gagu gaga gaga guga gaga gaga gaga gaga gaga gagu guuu gaga guga gugu gagu gugu guga gugu guuu gugu guuu gugu gugu gugu gugu guga 

user85052

Posted 2019-02-16T01:36:20.137

Reputation:

1

GolfScript, 70 bytes

"Baby
Daddy
Mommy
Grandpa
Grandma"n/{" Shark"+" doo"6*n++...-25<"!"n}/

Try it online!

Explanation:

"Baby
Daddy
Mommy
Grandpa
Grandma"n/                                       Push shark names, then split by newline
          {                               }/     For each name:
           " Shark"+                                 Concatenate with Shark
                    " doo"6*n++                      add doo * 6 then newline
                               ...                   Duplicate line 3 more times
                                  -25<               Cut off the "doo"s
                                      "!"n           Add "!"

Pseudo Nym

Posted 2019-02-16T01:36:20.137

Reputation: 181

0

C (compiled with VC++ (Visual Studio 2017)) 536Bytes

#include "stdafx.h"
#define d "doo "
#define p(x) printf(x);
#define n p("\n")
#define b p(f[i])p(" Shark ")
#define l(x,y) for(int x=0;x<y;x++)
void main(){const char*f[]={"Baby","Daddy","Mommy","Grandpa","Grandma"};l(i,5){l(k,3){b;l(j,6)p(d)n}b;p("\b!\n")}}

this is my naive try: it started from the "good version" where everything is done the neat and tidy way and i just removed the blanks, semicolons where possible and curly braces if possible. i changed main from int to void in order to be able to leave out the return Statement in the end if using a different Compiler (say gcc) the stdafx.h can be ommitted (visual Studio throws an error though (or i just dont know how to do it better...)) although then the use of printf means you either have to include stdio.h instead (=1byte win) or you have to use a Compiler flag to add this to the build path although not mentioned in the Code.... if its no dealbreaker if the exclamation mark is one space away from Baby Shark then the \b can be ommitted (=2 Byte win)

der bender

Posted 2019-02-16T01:36:20.137

Reputation: 21

removing the space between include and " makes a 1byte win. and removing the space between ) and for makes another Maybe you can squeeze out a bit more by modifing the l makro to make curly braces and therefor take one Argument more (=the loopbody) – der bender – 2019-02-17T22:26:16.753

Would also work with a non const char array, no? – B. Go – 2019-04-05T15:41:06.193

i used to compile that with visual studio and that throws an error if not. maybe other compilers aint that strict – der bender – 2019-04-05T15:43:53.120

0

Wolfram Language (Mathematica), 145 bytes

Nothing special, still thinking of a shorter method.

a={"Baby","Daddy","Mommy","Grandpa","Grandma"};c=" Shark";b=c<>StringJoin@Table[" doo",6];Do[Do[Print[a[[i]]<>b],3];Print[a[[i]]<>c<>"!"];,{i,5}]

Try it online!

Kai

Posted 2019-02-16T01:36:20.137

Reputation: 201

141? – ASCII-only – 2019-02-19T08:42:28.647

137? – ASCII-only – 2019-02-19T08:46:01.447

116? – ASCII-only – 2019-02-19T08:49:19.677

btw, join works instead of stringjoin – ASCII-only – 2019-02-19T08:59:27.033

105? also join works only because you <> right after – ASCII-only – 2019-02-19T09:07:15.713

also 105 – ASCII-only – 2019-02-19T09:19:20.383

195? – ASCII-only – 2019-02-19T12:15:57.713

2also 95 but stolen from Haskell answer – ASCII-only – 2019-02-19T12:37:03.727

1@ASCII-only nice improvements. I think that you can take credit for those though, you went a long way from where I started! – Kai – 2019-02-19T15:58:18.150

:P well I still did base it off your solution (I barely know Mathematica), plus as you can probably see I was mostly just reordering things – ASCII-only – 2019-02-19T22:27:49.717

0

Emacs Lisp, 177 bytes

(defmacro w()`(princ(concat i" Shark doo doo doo doo doo doo\n")))
(defmacro z()`(princ(concat i" Shark!\n")))
(loop for i in'("Baby""Daddy""Mommy""Grandpa")do(and(w)(w)(w)(z)))

adl

Posted 2019-02-16T01:36:20.137

Reputation: 351

0

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

"Baby Daddy Mommy Grandpa Grandma".Split().ToList().ForEach(x=>{string a=" doo",m=x+$" Shark{a+a+a+a+a+a}\n";Write(m+m+m+x+" Shark!\n");});

Try it online!

Any thoughts on improvements? I started aiming for a Linq-based solution with a SelectMany but the deferred execution failed me, along with string.join and return x; being quite verbose syntax

Thymine

Posted 2019-02-16T01:36:20.137

Reputation: 101

137 :P (2x3 = 5 occurrences is shorter than 6) – ASCII-only – 2019-02-19T23:26:50.013

134 – ASCII-only – 2019-02-19T23:30:32.673

1131 which is basically the same as the other solution – ASCII-only – 2019-02-19T23:37:55.927

132, close – ASCII-only – 2019-02-19T23:42:21.210

also 132 – ASCII-only – 2019-02-19T23:52:13.397

1Another 132 with foreach – ASCII-only – 2019-02-20T00:02:01.090

0

Swift 4, 149 bytes

var s=" Shark";for i in["Baby","Daddy","Mommy","Grandpa","Grandma"]{for _ in 0...2{print(i+s+(0..<6).map({_ in" doo"}).reduce("",+))};print(i+s+"!")}

Try it online!

thachnb

Posted 2019-02-16T01:36:20.137

Reputation: 101

126 – ASCII-only – 2019-02-20T03:53:05.430

119 – ASCII-only – 2019-02-20T04:02:14.660

0

Wolfram Language (Mathematica), 95 bytes

Do[Print[a," Shark"<>If[i>3,"!",Table[" doo",6]]],{a,{Baby,Daddy,Mommy,Grandpa,Grandma}},{i,4}]

Try it online!

ASCII-only

Posted 2019-02-16T01:36:20.137

Reputation: 4 687

0

ink, 114 113 bytes

-(h)~temp t="{Baby|Daddy|Mommy|Grandma|Grandpa} Shark"
-(l){t}<>{l%4<1:
!
{h>5:->END}->h
}
-(d)\ doo{d%5:->d}
->l

Try it online!

Explained

-(h)~temp t="{Baby|Daddy|Mommy|Grandma|Grandpa} Shark" // Gathers keep track of how many times they've been visited, the sequence takes on the next value each time it's visited. Save into local variable t
-(l){t}<>{l%4<1:                                       // Print t and no newline, then if the number of times we've been here is divisible by 4...
!                                                      // Print an exclamation mark
{h>5:->END}->h                                       // Go to h, or halt if we've already been there more than 5 times
}
-(d)\ doo{d%5:->d}                                     // Print " doo" until we've done it a number of times that is a multiple of 5
->l                                                    // Go to l to print the next line

Sara J

Posted 2019-02-16T01:36:20.137

Reputation: 2 576

0

Wren, 110 108 bytes

Fn.new{["Baby","Daddy","Mommy","Grandpa","Grandma"].map{|i|((i=i+" Shark")+" doo"*6+"
")*3+i+"!"}.join("
")}

Try it online!

user85052

Posted 2019-02-16T01:36:20.137

Reputation:

0

Node.JS, 121 bytes

'Baby Mommy Daddy Grandma Grampa'.replace(/\w+/g,(c,i,s,l=(c+=' Shark')+'doo'.repeat(6)+'\n')=>console.log(l+l+l+c+'!'))

anon

Posted 2019-02-16T01:36:20.137

Reputation: 1

I think the spaces between doo doo are missing. – Jonathan Frech – 2020-01-23T23:07:53.063

-1

x=["Baby shark ", "Mommy shark ", "Daddy shark ","Grandpa shark ", "Grandma shark ", "doo "*6]  
i = 0  
j = 0  
while j <= len(x)-2:  
    while i <= 2:  
        print(x[j] + x[5] + "\n")  
        i = i + 1  
    print(x[j] + "\b!\n")  
    j = j + 1  
    i = 0  

SecretPrimary2

Posted 2019-02-16T01:36:20.137

Reputation: 1

2

Welcome to PPCG! This challenge is tagged code-golf, meaning that the aim is to make your code as short as possible (in bytes). You could start by removing the extraneous whitespace and comment. For further tips, see here.

– Gabriel Mills – 2020-01-23T01:48:46.760

As well as what Gabriel Mills has said you ought to include the language name and the byte count in your answer. If you look at the other answers you can get a feel for the format that people tend to use. This format is not required though. – Post Rock Garf Hunter – 2020-01-23T02:40:09.440

It seems that your program doesn't work... You need colons after the while loops. Also the outer j loop is skipped because the initial looping counter is 0. – None – 2020-01-23T05:28:58.207

@a'_' and Lyxal, please don't approve edits that golf other people's posts. These should be postead as a comment instead, or left to the author's discretion to approve or not – Jo King – 2020-02-02T12:07:21.393