A current internet meme is to type 2spooky4me, with a second person typing 3spooky5me, following the (n)spooky(n+2)me pattern.

Your mission is to implement this pattern in your chosen language. You should write a program or function that takes a value n (from standard input, as a function argument, or closest alternative), and outputs the string (n)spooky(n+2)me (without the parentheses; to standard output, as a return value for a function, or closest alternative).

Your solution should work for all inputs, from 1 up to 2 below your language's maximum representable integer value (2^32-3 for C on a 32-bit machine, for example).

Example implementation in Python:

def spooky(n):
    return "%dspooky%dme"%(n,n+2)

spooky(2) -> "2spooky4me"

This is , so standard loopholes are forbidden, and the shortest answer in bytes wins!


The Stack Snippet at the bottom of this post generates the leaderboard from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

To make sure that your answer shows up, please start your answer with a headline, using the following Markdown template:

## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the snippet:

## [><>](http://esolangs.org/wiki/Fish), 121 bytes

<style>body { text-align: left !important} #answer-list { padding: 10px; width: 290px; float: left; } #language-list { padding: 10px; width: 290px; float: left; } table thead { font-weight: bold; } table td { padding: 5px; }</style><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table><script>var QUESTION_ID = 62350; var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk"; var OVERRIDE_USER = 45941; var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page; function answersUrl(index) { return "https://api.stackexchange.com/2.2/questions/" + QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER; } function commentUrl(index, answers) { return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER; } function getAnswers() { jQuery.ajax({ url: answersUrl(answer_page++), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { answers.push.apply(answers, data.items); answers_hash = []; answer_ids = []; data.items.forEach(function(a) { a.comments = []; var id = +a.share_link.match(/\d+/); answer_ids.push(id); answers_hash[id] = a; }); if (!data.has_more) more_answers = false; comment_page = 1; getComments(); } }); } function getComments() { jQuery.ajax({ url: commentUrl(comment_page++, answer_ids), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { data.items.forEach(function(c) { if (c.owner.user_id === OVERRIDE_USER) answers_hash[c.post_id].comments.push(c); }); if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); } getAnswers(); var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/; var OVERRIDE_REG = /^Override\s*header:\s*/i; function getAuthorName(a) { return a.owner.display_name; } function process() { var valid = []; answers.forEach(function(a) { var body = a.body; a.comments.forEach(function(c) { if(OVERRIDE_REG.test(c.body)) body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>'; }); var match = body.match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2], language: match[1], link: a.share_link, }); else console.log(body); }); valid.sort(function (a, b) { var aB = a.size, bB = b.size; return aB - bB }); var languages = {}; var place = 1; var lastSize = null; var lastPlace = 1; valid.forEach(function (a) { if (a.size != lastSize) lastPlace = place; lastSize = a.size; ++place; var answer = jQuery("#answer-template").html(); answer = answer.replace("{{PLACE}}", lastPlace + ".") .replace("{{NAME}}", a.user) .replace("{{LANGUAGE}}", a.language) .replace("{{SIZE}}", a.size) .replace("{{LINK}}", a.link); answer = jQuery(answer); jQuery("#answers").append(answer); var lang = a.language; lang = jQuery('<a>'+lang+'</a>').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang.toLowerCase(), user: a.user, size: a.size, link: a.link}; }); var langs = []; for (var lang in languages) if (languages.hasOwnProperty(lang)) langs.push(languages[lang]); langs.sort(function (a, b) { if (a.lang_raw > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) return -1; return 0; }); for (var i = 0; i < langs.length; ++i) { var language = jQuery("#language-template").html(); var lang = langs[i]; language = language.replace("{{LANGUAGE}}", lang.lang) .replace("{{NAME}}", lang.user) .replace("{{SIZE}}", lang.size) .replace("{{LINK}}", lang.link); language = jQuery(language); jQuery("#languages").append(language); } }</script>

  • 2
    \$\begingroup\$ For bonus points: Input %dspooky%dme, validate and return next in series. \$\endgroup\$ – clapp Oct 31 '15 at 6:13
  • 25
    \$\begingroup\$ True, but Dennis would still win \$\endgroup\$ – clapp Oct 31 '15 at 6:19
  • 8
    \$\begingroup\$ Who is Dennis? :O \$\endgroup\$ – NuWin Feb 15 '16 at 20:39
  • 13
    \$\begingroup\$ @NuWin Dennis is the way. Dennis is the light. \$\endgroup\$ – Alex A. Feb 15 '16 at 23:02
  • 1
    \$\begingroup\$ @NuWin Dennis is love, Dennis is life \$\endgroup\$ – user63571 Jan 25 '17 at 19:40

92 Answers 92


gs2, 15 bytes

I outgolfed Dennis!



Hex dump:

73 70 6f 6f 6b 79 07 6d 65 05 d0 56 12 30 42

At the start of the program, STDIN is pushed (e.g. the string "3") and stored in variable A. The first ten bytes of the program push two strings, "spooky" and "me", to the stack. Then:

  • d0 pushes variable A.
  • 56 parses it as a number.
  • 12 30 increments it by two.
  • 42 swaps the top two elements on the stack, leaving "3" "spooky" 5 "me".

The final stack is printed as 3spooky5me.

  • 4
    \$\begingroup\$ Holy hell, that's short. +1 \$\endgroup\$ – Addison Crump Oct 31 '15 at 23:47
  • 11
    \$\begingroup\$ GJ, but Dennis might come over here and outmod you to preserve his reputation. \$\endgroup\$ – TheDoctor Oct 31 '15 at 23:48
  • 7
    \$\begingroup\$ What no how how did you do that \$\endgroup\$ – a spaghetto Nov 1 '15 at 2:06
  • 3
    \$\begingroup\$ I just realized... does gs2 stand for "golf script 2"? \$\endgroup\$ – mbomb007 Nov 3 '15 at 14:56
  • 5
    \$\begingroup\$ By the way, I've added GS2 to my family of online interpreters, Try it online! \$\endgroup\$ – Dennis Dec 11 '15 at 22:57

GS2, 17 bytes

56 40 27 27 04 73 70 6F 6F 6B 79 05 42 04 6D 65 05


  • 31
    \$\begingroup\$ relevant \$\endgroup\$ – Downgoat Oct 31 '15 at 3:24
  • 3
    \$\begingroup\$ Man, it's so weird that we currently have 4 languages tied for first and 3 languages tied for second :P \$\endgroup\$ – ETHproductions Oct 31 '15 at 20:15

Stuck, 17 bytes



  • 1
    \$\begingroup\$ Hey cool, someone actually using Stuck :D \$\endgroup\$ – Kade Nov 1 '15 at 0:31
  • \$\begingroup\$ @Shebang I actually really like Stuck. Although it would be nice if it had some better methods for manipulating arrays. \$\endgroup\$ – a spaghetto Nov 1 '15 at 2:07

GolfScript, 17 bytes


Try it online on Web GolfScript.

How it works

~        # Evaluate the input.
.2+      # Push a copy and add 2.
"spooky" # Push that string.
\        # Swap it with the computed sum.
"me"     # Push that string.

Chef, 414 bytes


g i
2 g t
115 l s
112 l p
111 l o
107 l k
121 l y
109 l m
101 l e

Take i from refrigerator.Put e into mixing bowl.Put m into mixing bowl.Put i into mixing bowl.Add t.Put y into mixing bowl.Put k into mixing bowl.Put o into mixing bowl.Put o into mixing bowl.Put p into mixing bowl.Put s into mixing bowl.Put i into mixing bowl.Pour contents of mixing bowl into the baking dish.

Serves 1.

A recipe for disaster. Do not try this at home.

  • 7
    \$\begingroup\$ Mm. That's some spooky tastes you got there. \$\endgroup\$ – Addison Crump Nov 8 '15 at 15:36

Pyth - 17 bytes


Try it online here.


CJam, 18 bytes


Try it online.


TeaScript, 18 bytes


Unfortunately this string can't be compressed so this is basically as short as it will get

  • 12
    \$\begingroup\$ Welcome to the 18th byte! :P \$\endgroup\$ – a spaghetto Oct 31 '15 at 2:36

Pip, 18 bytes

Looks like I'm in the second tier of golfing languages here. :^P


Takes the number as a command-line argument and puts the appropriate elements in an array, which is joined together and autoprinted at the end of the program.


dc, 20 bytes


Japt, 17 16 bytes


Japt (Javascript shortened) is a language of my invention. It is newer than this challenge; thus, this answer is non-competing. Unlike my other seven unpublished languages, this one has an actual interpreter that is currently being developed and is already partially working.

I wanted to post this because I like how it's the same length as all the existing first-place second-place answers. Here's how it works:

U+"spooky{U+2}me"    implicit: [U,V,W,X,Y,Z] = eval(input)
U+                   input +
  "spooky     me"     this string
         {U+2}         with input+2 inserted here
                     implicit: output last expression

And there you have it. The spec for all functionality used here was finalized on Oct 29th; nothing was changed to make this answer any shorter. Here's the interpreter, as promised.

  • \$\begingroup\$ I'm sure this was pre-shoco, but I think you could've done {U}2me instead of {U+2}me :P \$\endgroup\$ – Oliver May 1 '18 at 18:27

05AB1E, 14 10 bytes


Try it online.



D                get input n and duplicate it
 Ì               increment by 2
  s              Swap. Stack is now [n+2, n].
   ’ÿæªÿme       Compressed string that expands to "ÿspookyÿme". The first ÿ is then replaced by n and the second by n+2.
  • 3
    \$\begingroup\$ This seems to work with D removed for 9 bytes \$\endgroup\$ – dzaima Nov 10 '17 at 20:09

Julia, 23 bytes


This creates an unnamed lambda function that accepts an integer and returns a string. The output is constructed using Julia's string interpolation.


Gol><>, 21 bytes


I guess I'm... tied with Perl? Try it online.

I:n            Input n, output n
"emykoops"     Push chars
6Ro            Output top 6 chars (spooky)
{2+n           Output n+2
H              Output stack and halt (me)

Vitsy, 21 Bytes

Note: the Z command was made after this challenge began, but was not made for this challenge.

V                      Grab the top item of the stack (the input) and make it a
                       global variable.
 V                     Call it up - push the global variable to the top of the stack.
  N                    Output it as a number.
   "ykoops"            Push 'spooky' to the stack.
           Z           Output it all.
            V2+N       Call the global variable again, add two, then output as num.
                "em"Z  Push 'me' to the stack and output it all.

More spoopy variation using multiple stacks (27 Bytes):


&                           Make a new stack and move to it.
 "ykoops"                   Push 'spooky' to the current stack.
         &"em"              Do the last to things with 'me'.
              ?             Move over a stack.
               DN           Output the input.
                 ?Z         Move over a stack (the one with 'spooky') and print it.
                   ??       Move back to the original stack.
                     2+N    Add 2 to the input and output it as a number.
                        ??Z Move to the stack with 'me' in it and print it.

Try it online!

  • \$\begingroup\$ Just wondering, why are strings inverted? \$\endgroup\$ – Cyoce Feb 23 '16 at 2:32
  • \$\begingroup\$ It's pushing chars to the stack one by one. \$\endgroup\$ – Soham Chowdhury Mar 23 '16 at 8:45

Ruby, 25 bytes


This creates an unnamed lambda that accepts an integer and returns a string. The string is constructed using Ruby's string interpolation.


APL, 25 22 bytes


This creates an unnamed monadic function train that accepts an integer on the left and returns a string.

Numeric values are converted to strings using . The array of strings is joined into a single string using .

Try it online

Saved 3 bytes thanks to Thomas Kwa!


Javascript(ES6) 23 21 Bytes

A simple function that will be crushed by golfing lanqs:



Special thanks to ETHproductions for saving 2 bytes

  • \$\begingroup\$ NOICE! You might be able to shorten the template strings, but I can't think of any way to do so \$\endgroup\$ – MayorMonty Oct 31 '15 at 17:21
  • \$\begingroup\$ Two bytes saved: _=>_+`spooky${_+2}me` \$\endgroup\$ – ETHproductions Oct 31 '15 at 20:18
  • \$\begingroup\$ Thank you, but now the fix seems so obvious I feel stupid. I think this is the shortest possible way to do this in Javascript, I could be wrong( I hope I'm wrong) \$\endgroup\$ – Generic User Oct 31 '15 at 21:11

PHP, 55 47 46 42 34 bytes


Accepts the number as command line input.

Credits :)

Thanks to manatwork for saving 4 bytes!

Thanks to insertusernamehere for saving 8 bytes!

  • \$\begingroup\$ function a($a){echo$a,"spooky",$a+2,"me";} \$\endgroup\$ – manatwork Oct 31 '15 at 12:25
  • \$\begingroup\$ You could save 4 bytes by removing the "s. You could even save 4 more bytes by taking a command line argument and discard the function, like this: <?=($a=$argv[1]).spooky.($a+2).me;. \$\endgroup\$ – insertusernamehere Oct 31 '15 at 20:07

Chaîne, 15 bytes

noncompeting, language postdates question

{i~}            | input duplicate write
    :   :       | access dictionary with inner base-93 key
     -,}        | entry for "spooky"
         {2+}   | push 2, add previous two, write
             me | write me

Implicit output.

  • \$\begingroup\$ The output is `spookyme 4 2" (newline separated) \$\endgroup\$ – Fabian Schmengler Nov 1 '15 at 10:35
  • \$\begingroup\$ @fschmengler I must have messed something up whilst updating the interpreter. Please stand by. \$\endgroup\$ – Conor O'Brien Nov 1 '15 at 17:11
  • \$\begingroup\$ @fschmengler Alright, bugs have been fixed. It should work now. \$\endgroup\$ – Conor O'Brien Nov 1 '15 at 17:17

Simplex v.0.7, 20 bytes

Simplex simply isn't feeling golfy today. >_<

i@                   ~~ take input and copy to register
  R"spooky"          ~~ write that string to the strip (increment byte after every character)
           &II       ~~ write the register (incremented twice) to the strip
              R"me"  ~~ write that string to the strip
                   g ~~ output the strip
  • \$\begingroup\$ You still beat Vitsy. o-o \$\endgroup\$ – Addison Crump Oct 31 '15 at 15:53
  • \$\begingroup\$ @VoteToClose Don't feel too bad. Last Simplex version would've been ~25+ characters. Either way, 20 or 21 bytes doesn't come close to 17 ;-; \$\endgroup\$ – Conor O'Brien Oct 31 '15 at 16:00
  • 2
    \$\begingroup\$ Dennis wins again. \$\endgroup\$ – Addison Crump Oct 31 '15 at 16:02
  • 1
    \$\begingroup\$ @VoteToClose What did you expect? He's a mod XD \$\endgroup\$ – Conor O'Brien Oct 31 '15 at 16:02
  • 3
    \$\begingroup\$ We need to add this to the meme list. \$\endgroup\$ – Addison Crump Oct 31 '15 at 16:03

C, 58 bytes


atoi() may be unnecessary.

  • \$\begingroup\$ 1. Fails on my gcc, because it depends on evaluation order. 2. Save a byte with int**b. \$\endgroup\$ – ugoren Nov 3 '15 at 15:11

Mathematica, 45 27 bytes



Thanks to Martin Büttner for the significant improvement (and the warm welcome).

  • 2
    \$\begingroup\$ Welcome to PPCG! Unnamed functions are fine, so you don't need the g= and I think Print[#,"spooky",#+2,"me"]& should work as well. :) \$\endgroup\$ – Martin Ender Oct 31 '15 at 14:19
  • \$\begingroup\$ What about Row@{#,spooky,#+2,me}&? The output is visually similar if the variables are not defined. \$\endgroup\$ – 2012rcampion Nov 1 '15 at 7:06

Minkolang 0.10, 49 bytes

I have no way to convert integers to strings (yet!), so this is much longer.


Try it here.


(dl%"0"+$rl:d) does the job of converting an int to a string. If this were replaced by a single character (like Z), then my solution would be just 23 bytes.


nd takes an integer from input and duplicates it. 2+ adds 2 and 2g later gets the initial input and puts it on top of stack. $O. outputs the whole stack as integers and stops.

  • \$\begingroup\$ Surely it's shorter to just output the numbers as numbers? \$\endgroup\$ – Sp3000 Nov 1 '15 at 7:49
  • \$\begingroup\$ Outputting as number automatically adds a space to the output. So it'd be "2 spooky4 me". \$\endgroup\$ – El'endia Starman Nov 1 '15 at 20:50

Lua for windows, 41 bytes

n=io.read()print(n.."spooky"..n+2 .."me")

test with lua for windows

it takes the input through io.read then stored in variable n then on the same line prints the variable n then "spooky" then n+2 finally it prints "me"

  • 1
    \$\begingroup\$ Remove whitespace and save bytes n=io.read()print(n.."spooky"..n+2.."me") \$\endgroup\$ – Digital Veer Oct 31 '15 at 15:44
  • 1
    \$\begingroup\$ @DigitalVeer - Without the whitespace 2. will be treated as a number. \$\endgroup\$ – Egor Skriptunoff Nov 1 '15 at 9:30
  • \$\begingroup\$ p.lua: print(.....'spooky'.. ...+2 ..'me') How to run: lua51.exe p.lua 2 Size = 35 bytes. \$\endgroup\$ – Egor Skriptunoff Nov 1 '15 at 9:37

Rotor, 15 bytes


Language was created after the challenge. Does not work in the online interpreter (uses input eval.)

  • \$\begingroup\$ Dam son. You outgolfed Dennis. Finally. Hooray! \$\endgroup\$ – Addison Crump Jan 10 '16 at 6:15
  • 1
    \$\begingroup\$ Rotor is dead to me don't try to resurrect it please. \$\endgroup\$ – a spaghetto Jan 10 '16 at 15:09
  • 1
    \$\begingroup\$ Nice job, even in Rotor!! You should reward it with life. \$\endgroup\$ – Rɪᴋᴇʀ Mar 22 '16 at 21:33

Cookie, 16 bytes (non-competing)

Note that the recent changes to the Github page were not made for this challenge, Cookie is still in development.



w                 start write command
 ŕ                take input
  spooky          write spooky
        [r+2]     compute input + 2
             me   write me
               "  close write command.
  • \$\begingroup\$ @Mego Why did you add non-competing? Just asking. \$\endgroup\$ – user51533 Mar 23 '16 at 7:42
  • \$\begingroup\$ The language was created 5 months after the challenge was posted. \$\endgroup\$ – user45941 Mar 23 '16 at 7:46
  • \$\begingroup\$ @Mego Didn't know about that system. Thanks for enlightening me ;) \$\endgroup\$ – user51533 Mar 23 '16 at 7:48
  • \$\begingroup\$ Glad to help. If a submission is valid, but the language(s)/feature(s) used didn't exist prior to the posting of the challenge (either on main or in the Sandbox), it must be marked as non-competing, unless the challenge specifically allows newer languages/features to compete. \$\endgroup\$ – user45941 Mar 23 '16 at 7:50
  • \$\begingroup\$ Right. That makes sense. \$\endgroup\$ – user51533 Mar 23 '16 at 7:50

Jelly, non-competing

13 bytes This answer is non-competing, since the challenge predates the creation of Jelly.



Try it online!

How it works

+0,2ż“×¥X“ŀ`»  Main link. Input: n

+0,2           Add [0, 2] to n, resulting in [n, n + 2].
     “×¥X“ŀ`»  Yield ['spooky, 'me'] by indexing into a dictionary.
    ż          Zip the results to left and right with each other.
               This yields [[n, 'spooky'], [n + 2, 'me']], which is flattened
               before printing.
  • 7
    \$\begingroup\$ One does not simply outgolf... quartata? \$\endgroup\$ – Arcturus Mar 31 '16 at 2:23
  • \$\begingroup\$ I can't seem to outgolf quartata, but, since the answer is non-competing, I can give some help. +2ṭż“×¥X“ŀ`» \$\endgroup\$ – Erik the Outgolfer Feb 15 '17 at 17:45

Perl 5, 20 19 bytes


The code requires the -p switch. Thanks to @Xcali for golfing off 1 byte!

Try it online!


Python, 31 bytes

lambda n:"%dspooky%dme"%(n,n+2)

Ask and you shall receive.

  • \$\begingroup\$ Python 3.6+ lambda n:f'{n}spooky{n+2}me' for 28 bytes. \$\endgroup\$ – mypetlion Nov 10 '17 at 23:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy