top of page
Writer's pictureLesley

Use AMPScript to output Baby Shark in the shape of a shark

A bit over a year ago, the group at HowToSFMC issued a challenge to produce a CloudPage that output the lyrics to Baby Shark using the fewest characters possible. I thought I was up to the challenge and spent many hours trying to eliminate characters in my code. Eventually I obtained insider info that my character count was nowhere near the lowest, and came to accept that did not quite have the programming chops to write the winning code.


So, I shifted my focus to the most creative category and spent several hours of my life attempting to output the lyrics of Baby Shark in the shape of a shark.


First of all, here was my attempt to use the fewest characters to output the lyrics:


%%[
FOR @c=1 to 20 DO
Output(IIF(mod(@c,10))<1,'Baby ',
      (IIF(mod(@c,10))<2,'Shark',
      (IIF(mod(@c,10))<3,',','!')))
Next
]%%
%[
FOR @c=1 to 36 DO
Output(Concat(IIF(@c<5,'Baby ',IIF(@c<9,'Mommy ',IIF(@c<13,'Daddy ',IIF(@c<17,'Grandma ',IIF(@c<21,'Grandpa ',IIF(@c<25,'Let''s go hunt',IIF(@c<28,'Run away',IIF(@c<33,'Safe at last','It''s the end')))))))),IIF(@c<21,'shark',''),IIF(mod(@c,4)<1,'!',', doo doo doo doo doo doo'),'<br>'))
NEXT
]%%

And here is the code that outputs the lyrics in the shape of a shark:


%%[
Output(Concat('<center>','Baby','<br>','shark, doo','<br>','doo'))
FOR @i=1 to 7 DO
  Output(Concat('&nbsp;'))
NEXT @i 
Output(Concat('doo','<br>','doo'))
FOR @x=1 to 5 DO
 FOR @i=1 to 2 DO
   Output(Concat('&nbsp;'))
 NEXT @i
 IF @x == 1 or @x == 3 or @x == 4 then
  Output(Concat('doo'))
 ELSEIF @x == 2 then
  Output(Concat('doo','<br>','Baby shark, doo','<br>','doo'))
 ELSE
  Output(Concat('doo','<br>','d'))
 ENDIF
NEXT @x
FOR @x=1 to 2 DO
 FOR @i=1 to 14 DO
   Output(Concat('&nbsp;'))
 NEXT @i
 IF @x == 1 then
  Output(Concat('o'))
 ELSE
  Output(Concat('o','<br>','Baby shark,'))
 ENDIF
NEXT @x
FOR @i=1 to 2 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo'))
FOR @i=1 to 3 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo','<br>','doo'))
FOR @x=1 to 3 DO
 FOR @i=1 to 5 DO
   Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 3 then
  Output(Concat('doo'))
 ELSE
  Output(Concat('doo','<br>','Baby'))
 ENDIF
NEXT @x
FOR @i=1 to 23 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('shark!','<br>','Mommy shark, doo doo doo','<br>','doo'))
FOR @x=1 to 2 DO
 FOR @i=1 to 14 DO
   Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 2 then
  Output(Concat('doo'))
 ELSE
  Output(Concat('doo','<br>','Mommy'))
 ENDIF
NEXT @x
FOR @x=1 to 4 DO
 FOR @i=1 to 2 DO
   Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 2 then
  Output(Concat('shark,'))
 ELSEIF @x < 4 then
  Output(Concat('doo'))
 ELSE
  Output(Concat('doo','<br>','doo'))
 ENDIF
NEXT @x
FOR @x=1 to 2 DO
 FOR @i=1 to 17 DO
   Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 2 then
  Output(Concat('doo'))
 ELSE
  Output(Concat('doo','<br>','Mommy'))
 ENDIF
NEXT @x
FOR @x=1 to 4 DO
 FOR @i=1 to 3 DO
   Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 2 then
  Output(Concat('shark,'))
 ELSEIF @x < 4 then
  Output(Concat('doo'))
 ELSE
  Output(Concat('doo','<br>','doo'))
 ENDIF
NEXT @x
FOR @x=1 to 2 DO
 FOR @i=1 to 18 DO
   Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 2 then
  Output(Concat('doo'))
 ELSE
  Output(Concat('doo','<br>','Mommy'))
 ENDIF
NEXT @x
FOR @i=1 to 34 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('shark!','<br>','Daddy'))
FOR @x=1 to 2 DO
 FOR @i=1 to 3 DO
   Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 2 then
  Output(Concat('shark,'))
 ELSE
  Output(Concat('doo'))
 ENDIF
NEXT @x
FOR @x=1 to 2 DO
 FOR @i=1 to 2 DO
   Output(Concat('&nbsp;'))
 NEXT @i
 Output(Concat('doo'))
NEXT @x
FOR @i=1 to 3 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo','<br>','doo'))
FOR @i=1 to 46 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo','<br>','Daddy'))
FOR @i=1 to 2 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('shark,'))
FOR @i=1 to 3 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo doo doo doo doo','<br>','d'))
FOR @i=1 to 30 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('o'))
FOR @i=1 to 29 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('o'))
FOR @i=1 to 5 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('<br>','Daddy'))
FOR @x=1 to 7 DO
 FOR @i=1 to 2 DO
   Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 2 then
  Output(Concat('shark,'))
 ELSE
  Output(Concat('doo'))
 ENDIF
NEXT @x
FOR @i=1 to 10 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('<br>','Daddy'))
FOR @i=1 to 56 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('shark!'))
FOR @i=1 to 16 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('<br>','Grandma'))
FOR @i=1 to 3 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('shark,'))
FOR @x=1 to 6 DO
  FOR @i=1 to 3 DO
    Output(Concat('&nbsp;'))
  NEXT @i
  Output(Concat('doo'))
NEXT @x
FOR @i=1 to 21 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('<br>','Grandma'))
FOR @i=1 to 4 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('shark,'))
FOR @x=1 to 6 DO
 FOR @i=1 to 4 DO
   Output(Concat('&nbsp;'))
 NEXT @i
 Output(Concat('doo'))
NEXT @x
FOR @i=1 to 27 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('<br>','Grandma'))
FOR @x=1 to 7 DO
 FOR @i=1 to 5 DO
  Output(Concat('&nbsp;'))
 NEXT @i
 IF @x == 1 then
  Output(Concat('shark,'))
 ELSE
  Output(Concat('doo'))
 ENDIF
NEXT @x
FOR @i=1 to 30 DO
 IF @i < 30 THEN
  Output(Concat('&nbsp;'))
 ELSE
  Output(Concat('&nbsp;','<br>'))
 ENDIF
NEXT @i
FOR @i=1 to 9 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('Grandma'))
FOR @i=1 to 45 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('shark!','<br>'))
FOR @i=1 to 14 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('Grandpa'))
FOR @x=1 to 7 DO
 FOR @i=1 to 2 DO
  Output(Concat('&nbsp;'))
 NEXT @i
 IF @x == 1 THEN
  Output(Concat('shark,'))
 ELSEIF @x < 7 THEN
  Output(Concat('doo'))
 ELSE
  Output(Concat('doo','<br>'))
 ENDIF
NEXT @x
FOR @i=1 to 22 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('Grandpa'))
FOR @x=1 to 7 DO
 FOR @i=1 to 3 DO
  Output(Concat('&nbsp;'))
 NEXT @i
 IF @x == 1 THEN
  Output(Concat('shark,'))
 ELSEIF @x < 7 THEN
  Output(Concat('doo'))
 ELSE
  Output(Concat('doo','<br>'))
 ENDIF
NEXT @x
FOR @i=1 to 30 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('Grandpa'))
FOR @x=1 to 7 DO
 FOR @i=1 to 4 DO
  Output(Concat('&nbsp;'))
 NEXT @i
 IF @x == 1 THEN
  Output(Concat('shark,'))
 ELSEIF @x < 7 THEN
  Output(Concat('doo'))
 ELSE
  Output(Concat('doo','<br>'))
 ENDIF
NEXT @x
FOR @i=1 to 37 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('Grandpa'))
FOR @i=1 to 68 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('shark!','<br>'))
FOR @i=1 to 40 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('Let''s'))
FOR @x=1 to 3 DO
 FOR @i=1 to 4 DO
  Output(Concat('&nbsp;'))
 NEXT @i
 IF @x == 1 THEN
  Output(Concat('go'))
 ELSEIF @x == 2 THEN
  Output(Concat('hunt,'))
 ELSE
  Output(Concat('doo'))
 ENDIF
NEXT @x
FOR @x=1 to 5 DO
 FOR @i=1 to 5 DO
  Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 5 THEN
  Output(Concat('doo'))
 ELSE
  Output(Concat('doo','<br>'))
 ENDIF
NEXT @x
FOR @i=1 to 12 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('Let''s go hunt, doo doo doo doo doo doo','</br>','Let''s go hunt, doo doo doo doo','</br>',
'doo'))
FOR @i=1 to 33 DO
  Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo','<br>','Let''s'))
FOR @x=1 to 2 DO
 FOR @i=1 to 12 DO
  Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 2 THEN
  Output(Concat('go'))
 ELSE
  Output(Concat('hunt!','<br>','Run'))
 ENDIF
NEXT @x
FOR @x=1 to 2 DO
 FOR @i=1 to 2 DO
  Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 2 THEN
  Output(Concat('away,'))
 ELSE
  Output(Concat('doo'))
 ENDIF
NEXT @x
FOR @x=1 to 2 DO
 FOR @i=1 to 3 DO
  Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 2 THEN
  Output(Concat('doo'))
 ELSE
  Output(Concat('doo','<br>','doo'))
 ENDIF
NEXT @x
FOR @i=1 to 13 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo'))
FOR @i=1 to 12 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo','<br>','Run'))
FOR @x=1 to 2 DO
 FOR @i=1 to 2 DO
  Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 2 THEN
  Output(Concat('away,'))
 ELSE
  Output(Concat('doo'))
 ENDIF
NEXT @x
FOR @x=1 to 3 DO
 FOR @i=1 to 3 DO
  Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 3 THEN
  Output(Concat('doo'))
 ELSE
  Output(Concat('<br>','doo'))
 ENDIF
NEXT @x
FOR @i=1 to 15 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo'))
FOR @i=1 to 14 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo'))
FOR @i=1 to 9 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('<br>','Run'))
FOR @x=1 to 5 DO
 FOR @i=1 to 2 DO
  Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 2 THEN
  Output(Concat('away,'))
 ELSE
  Output(Concat('doo'))
 ENDIF
NEXT @x
FOR @i=1 to 12 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('<br>','doo'))
FOR @i=1 to 24 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo','<br>','Run'))
FOR @i=1 to 19 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('away!','<br>','Safe'))
FOR @i=1 to 4 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('at'))
FOR @i=1 to 3 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('last,'))
FOR @i=1 to 4 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo','<br>','doo'))
FOR @x=1 to 2 DO
 FOR @i=1 to 7 DO
  Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 2 THEN
  Output(Concat('doo'))
 ELSE
  Output(Concat('doo','<br>','doo'))
 ENDIF
NEXT @x
FOR @i=1 to 17 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo','<br>','Safe at last, doo','<br>','doo'))
FOR @x=1 to 2 DO
 FOR @i=1 to 2 DO
  Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 2 THEN
  Output(Concat('doo'))
 ELSE
  Output(Concat('doo','<br>','doo'))
 ENDIF
NEXT @x
FOR @i=1 to 8 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo','<br>','Safe at last,','<br>','doo'))
FOR @i=1 to 6 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo','<br>','doo'))
FOR @i=1 to 7 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo','<br>','doo'))
FOR @i=1 to 10 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo','<br>','Safe'))
FOR @x=1 to 2 DO
 FOR @i=1 to 5 DO
  Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 2 THEN
  Output(Concat('at'))
 ELSE
  Output(Concat('last!','<br>','It''s the end, doo doo','<br>','doo'))
 ENDIF
NEXT @x
FOR @x=1 to 3 DO
 FOR @i=1 to 5 DO
  Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 3 THEN
  Output(Concat('doo'))
 ELSE
  Output(Concat('doo','<br>','It''s the end, doo doo doo doo','<br>','doo'))
 ENDIF
NEXT @x
FOR @i=1 to 40 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo','<br>','It''s','&nbsp;&nbsp;&nbsp;','the'))
FOR @i=1 to 18 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('end,'))
FOR @x=1 to 2 DO
 FOR @i=1 to 3 DO
  Output(Concat('&nbsp;'))
 NEXT @i
 IF @x < 2 THEN
  Output(Concat('doo'))
 ELSE
  Output(Concat('doo','<br>','doo'))
 ENDIF
NEXT @x
FOR @i=1 to 33 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('doo doo doo','<br>','It''s'))
FOR @i=1 to 44 DO
 Output(Concat('&nbsp;'))
NEXT @i
Output(Concat('the end!','</center>'))
]%%

Here is what the output looks like:





48 views0 comments

Comments


bottom of page