cat goes "Meow"

We are all familiar with the concept of a cat program. The user types something in, it is echoed back to the user. Easy. But all cat programs I've seen so far have missed one fact: a cat goes "Meow". So your task is to write a program that copies all STDIN to STDOUT UNLESS the input is cat, in which case your program should output cat goes "Meow".


This is , so your score is your byte count, with a few modifiers:

  • If your program works for any additional animals other than cat (e.g. cow: cow goes "Moo"), for each additional animal: -10
  • If your program doesn't use the word "cat": -15
  • If your program responds to fox with "What does the fox say": -25

Animals and sounds that go together:

cow goes moo duck goes quack sheep goes baa bees go buzz frogs go croak

Anything else on this list is allowed.


  • Standard loopholes apply
  • You must not write anything to STDERR
  • You can use single quotes/no quotes instead of double quotes.


Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.

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 leaderboard snippet:

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

var QUESTION_ID=62500;var OVERRIDE_USER=46470;function answersUrl(e){return"http://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"http://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(-?\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
<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="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><div id="language-list"> <h2>Winners 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><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>

  • 18
    \$\begingroup\$ For the bonuses: What does the fox say? \$\endgroup\$ Nov 1 '15 at 8:11
  • 1
    \$\begingroup\$ For the bonuses: can each additional animal be singular, or does "bees" always have to be plural, as in your list? \$\endgroup\$
    – ProgramFOX
    Nov 1 '15 at 9:06
  • 2
    \$\begingroup\$ Cats say meow.. \$\endgroup\$ Nov 1 '15 at 11:37
  • 1
    \$\begingroup\$ Instead of double quotes, can you use single ones? Also, can you output to stderr? \$\endgroup\$
    – Blue
    Nov 1 '15 at 12:47
  • 5
    \$\begingroup\$ Why is there no link to this in this challenge? \$\endgroup\$
    – Jan
    Nov 1 '15 at 20:50

64 Answers 64


Pyth, 231-255 = -24 bytes

-24*10 extra animals, -15 for no "cat" string

pzI}zJv.Z"xÚ]Arà E¯âñMOÛ|°
Ø¢mÞ½`&ÉR¯'_ãPÍm1;ñÝ|,F ¹×z#½öÂ÷ÜAPúõMh#Ì©UOC *CÑ°k%¹ö´qÌzj,å<&{jàRFÖ(¥s    ñ`GÂ:çkô#ù\M+üqíéaw ÑuW6Lã,¶w/'87ö×_r]¢:jkz»ÚFÙ¦ÈcÅËØíëûÖOa¿Þµ´6 ø¡ãEþþ:"jk(" goes "N@JzN

Link to code


Auto assign z to input
print z
J = decompress animal-sound dict
if z in J:
    print " goes ", J[z], '"'

Animals it knows:

{'hare': 'squeak', 'seal': 'bark', 'lion': 'growl', 'rook': 'hiss', 'sheep': 'baa', 'hamster': 'squeak', 'moose': 'bellow', 'grasshopper': 'chirp', 'rhinoceros': 'bellow', 'cat': 'meow', 'tiger': 'growl', 'stag': 'bellow', 'crow': 'caw', 'okapi': 'bellow', 'snake': 'hiss', 'cicada': 'chirp', 'badger': 'growl', 'dog': 'bark', 'cricket': 'chirp', 'tapir': 'squeak', 'bird': 'chirp', 'sparrow': 'chirp', 'lamb': 'baa', "frog": "croak", "raven": "croak"}
  • 18
    \$\begingroup\$ I feel like the bonus should be -10%, not -10 bytes. That would give a diminishing return to prevent abuses like this. (And that's 10% multiplied each time, not 10% of original added up, otherwise you'd only need 10 animals to get a score of 0 no matter how long the code was...) \$\endgroup\$ Nov 1 '15 at 14:26
  • \$\begingroup\$ @DarrelHoffman I'll bear that in mind for all future challenges. \$\endgroup\$
    – user46470
    Nov 1 '15 at 16:13
  • 1
    \$\begingroup\$ Well, you successfully made my head explode, and I no longer know what the fox says. +1 \$\endgroup\$ Nov 5 '15 at 3:47
  • \$\begingroup\$ The raven goes croak? \$\endgroup\$ Nov 28 '16 at 18:53
  • \$\begingroup\$ @carusocomputing According to wikipedia it does. I think they go squalk myself \$\endgroup\$
    – Blue
    Nov 28 '16 at 19:53

TeaScript, 29 - 15 = 14 bytes

Doesn't use string cat.

xr(/^c\at$/,'$& goes "Meow"')

"What does the fox say" (length = 21) is longer than the bonus is worth.

  • \$\begingroup\$ The fox bonus is now worth it! \$\endgroup\$
    – user46470
    Nov 2 '15 at 15:43

CJam, 12 bytes

q_:)"dbu"=" goes \"Meow\""*

The program is 27 bytes bytes long and doesn't use the word cat (-15 bytes).

Try it inline in the CJam interpreter.

How it works

q_                e# Read all input and push a copy.
:)                e# Increment all code points of the copy.
"dbu"=            e# Push 1/0 if the result is/isn't "dbu".
" goes \"Meow\""* e# Repeat the string that many times.
  • 11
    \$\begingroup\$ I like the smiley :) \$\endgroup\$ Nov 1 '15 at 16:41

JavaScript, 45 - 15 = 30 / 264 - 235 = 29

alert((s=(d='MeowBuzzSongMooMooCawBarkQuackCroakHissOinkBaaSingRoarLowCooCawBarkBaaHissCryRoarSingC\x61tBeeBirdCattleCowCrowDogDuckFrogHorseHogLambLarkLionOxPigeonRookSealSheepSnakeSwanTigerWhale'.split(/(?=[A-Z])/))[d.indexOf(i=prompt())-23])?i+' goes "'+s+'"':i)

Downside: you have to write the name of the animal with the first letter in uppercase and the rest in lowercase. Look below for another version which fixes this. This version escapes the a in cat with \x61 and includes code for the 22 extra animals from this list (all the allowed animals which had short enough words to be worth it):

bee buzz 7
bird song 8
cattle moo 9
cow moo 6
crow caw 7
dog bark 7
duck quack 9
frog croak 9
horse hiss 9
hog oink 7
lamb baa 7
lark sing 8
lion roar 8
ox low 5
pigeon coo 9
rook caw 7
seal bark 8
sheep baa 8
snake hiss 9
swan cry 7
tiger roar 9
whale sing 9

(thanks to my friend for helping me with the tedious task of making this list)

Ungolfed code:

data = 'MeowBuzzSongMooMooCawBarkQuackCroakHissOinkBaaSingRoarLowCooCawBarkBaaHissCryRoarSingC\x61tBeeBirdCattleCowCrowDogDuckFrogHorseHogLambLarkLionOxPigeonRookSealSheepSnakeSwanTigerWhale'.split(/(?=[A-Z])/);

input = prompt();
index = data.indexOf(input);
sound = data[index-23];
result = sound ? input + ' goes "' + sound + '"' : input;

First version, 45 bytes - 15 bonus = 30

alert((i=prompt())=='\x63at'?i+' goes "Meow"':i)

Yes, I know. I went from 30 to 29 with ALL that extra work. It was fun!

Version that allows full lowercase input, 294 bytes - 235 bonus = 59

alert((s=(d='MeowBuzzSongMooMooCawBarkQuackCroakHissOinkBaaSingRoarLowCooCawBarkBaaHissCryRoarSingC\x61tBeeBirdCattleCowCrowDogDuckFrogHorseHogLambLarkLionOxPigeonRookSealSheepSnakeSwanTigerWhale'.split(/(?=[A-Z])/))[d.indexOf((i=prompt())[0].toUpperCase()+i.slice(1))-23])?i+' goes "'+s+'"':i)

I also tried removing casing from the data array with .join().toLowerCase().split(',') but it ended up taking 297 characters instead.

  • \$\begingroup\$ edit: fixed quote marks and capital on meow (although the question isn't consistent with capitals) \$\endgroup\$
    – Domino
    Nov 5 '15 at 0:57
  • \$\begingroup\$ And... my work here is done, proving that the -10 bonus was just enough :) \$\endgroup\$
    – Domino
    Nov 5 '15 at 1:46

APL (Dyalog), 28 - 15 = 13 bytes

{⍵,' goes "Meow"'/⍨⍵≡⌽'tac'}

Input followed by goes "Meow" if input is equivalent to tac reversed.

Try it online!

{} anonymous function

⌽'tac' reverse the string (to get the -15 bonus by avoiding the characters cat)

⍵≡ Boolean for whether the argument is identical to that

' goes "Meow"'/⍨ use that to filter the string (i.e. returns empty string if false)

⍵, append to the argument


Stack, 51 bytes

'' input dup 'cat' = { 'cat goes "meow"' } if print

JavaScript, 81 - 20 - 15 = 46 bytes 50 - 15 = 35 bytes

(o=prompt()=="ca"+"t")&&o+=' goes "Meow"';alert(o)
  • \$\begingroup\$ You can drop the double-quotes around Meow. \$\endgroup\$ Nov 2 '15 at 16:10
  • \$\begingroup\$ no, that's actually part of the question \$\endgroup\$
    – Domino
    Nov 5 '15 at 0:56
  • 1
    \$\begingroup\$ How about 'c\at' instead of 'ca'+'t'? \$\endgroup\$ Nov 10 '15 at 17:46
  • 1
    \$\begingroup\$ alert({'c\at':'c\at goes "Meow"',fox:'What does the fox say'}[a=prompt()]||a). Why not even drop the alert? It already returns the result to console. \$\endgroup\$ Nov 10 '15 at 17:58

GNU sed, 37 - 15 = 22 bytes

sed -r 's/^(\x63at)$/\1 goes "Meow"/'
  • \$\begingroup\$ sed '/^c[a]t$/s/$/ goes "Meow"/' saves a few bytes. But the new 5% bonus is worthless compared to the original 15 byte bonus for not having "cat". \$\endgroup\$ Nov 2 '15 at 15:03
  • \$\begingroup\$ @GlennRanders-Pehrson Not any more! \$\endgroup\$
    – user46470
    Nov 2 '15 at 15:45

MATLAB, 58 - 15 = 43 bytes

Pretty straight forward, with bonus for not using cat in the code:

x=input('');if isequal(x,'dbu'-1);x=[x ' goes "Meow"'];end;x

Input must be given inside single quotes: ' '.

  • \$\begingroup\$ In its current form, this doesn't output correctly if 'cat' is given as input. You probably forgot x= within the if-statement. \$\endgroup\$
    – slvrbld
    Nov 5 '15 at 16:23
  • \$\begingroup\$ But I'll also give you a tip to win back these bytes plus an additional 2: replace your entire if-statement by: if~any(x-'dbu'+1) \$\endgroup\$
    – slvrbld
    Nov 5 '15 at 16:32
  • \$\begingroup\$ @slvrbld, thanks for noticing, it happened after I made an edit. BTW: your suggestion doesn't work for inputs that aren't 3 characters. =) \$\endgroup\$ Nov 6 '15 at 15:53
  • \$\begingroup\$ Ah, you're correct. I was too focused on the cat and fox and forgot about the rest. \$\endgroup\$
    – slvrbld
    Nov 9 '15 at 8:13

Javascript, 117 bytes

for(c=0,s="bee.Buzz.bird.Song.c\at.Meow.cow.Moo.crow.Caw.dog.Bark.oxen.Low.owl.Who.rook.Caw.sheep.Baa.swan.Cry".split('.'),p=prompt(),a=![];c<s.length;c+=2){if(p==s[c])a=c}if(!a)alert(p=='fox'?'What does the fox say':p);else alert(s[a]+' goes "'+s[a+1]+'"')

I definitely haven't won here, but I've covered a lot of extra animals.

Javascript, 31 bytes

p=prompt();alert(p=='c\at'?p+' goes "Meow"':p)

HALT, 71 - 15 = 56 bytes

1 IF "cat" 2 ELSE 3

HALT is a language I (@Downgoat) made designed for string processing, the only problem is that it's a bit long


1              IF "cat" 2 ELSE 3
3 SET 0      ; GOTO 6

Python 3, 81 70 55 46 - 15 = 31 bytes

Thanks to Stewie Griffin for saving 15 bytes

Thanks to grc for saving 8 bytes.

Not using the string cat gives -15 bytes.

print(y+' goes "Meow"'*(y=="ca""t"))

LOLCODE, 100 109 Bytes

YA RLY,VISIBLE "cat goes Meow"

Try it out online

My first post on this platform, as well as my first code-golf challenge and my first code in LOLCODE, so there's probably lots to improve. I tried avoiding the "cat" with casting the equivalent hex-code ":(63):(61):(74)" instead, but it didn't work out for me. If you know a solution to this, please let me know!

*+9 Bytes because I didn't read the instructions clear enough

  • 1
    \$\begingroup\$ Welcome to CGCC! Your TIO link appears to be blank, though the code itself looks valid \$\endgroup\$
    – Jo King
    Dec 12 '19 at 23:32
  • 1
    \$\begingroup\$ Thanks for pointing that out @JoKing I fixed the link, it should include the code now. \$\endgroup\$
    – Signus
    Dec 13 '19 at 6:44
  • 1
    \$\begingroup\$ the code turns "cat" into "Meow", but it should instead turn it into "cat goes Meow". Still nice code though! \$\endgroup\$
    – Belhenix
    Dec 13 '19 at 17:41
  • \$\begingroup\$ Thanks @Belhenix. I fixed it for the price of adding 9 bytes. Sadly the use of a variable for "cat" would've turned out to be 5 bytes longer, so I chose to stick with the uglier code. \$\endgroup\$
    – Signus
    Dec 17 '19 at 7:16

JavaScript, 48 - 15 = 33 bytes

Uses \x61 as a substitute for the a in cat.

i=prompt();alert(i=="c\x61t"?i+' goes "Meow"':i)

Perl, 46 - 15 = 31

$_=join'',<>;s/(?<=^ca)t$/t goes "Meow"/;print

Ruby, 49 46 50 - 15 = 35 bytes

Pretty straight-forward I guess. Not using cat.

$<.map{|l|puts l==?c+'at
'??c+'at goes "Meow"':l}

Edit: Thanks for @w0lf for saving 3 bytes!

  • \$\begingroup\$ apparently there's no need for chop: ideone.com/lTpShD \$\endgroup\$ Nov 1 '15 at 9:36
  • \$\begingroup\$ @w0lf "cat\n" != "cat" (At least it doesn't work for me) I'm guessing that ideone's STDIN doesn't have a trailing newline \$\endgroup\$ Nov 1 '15 at 9:38
  • \$\begingroup\$ Fair enough, I see where my example was wrong. Then your could consider doing this to shorten the code. \$\endgroup\$ Nov 1 '15 at 9:41
  • \$\begingroup\$ @PeterLenkefi, there are still a few cats left in your code... Did you forget to update it or...? \$\endgroup\$ Nov 1 '15 at 13:03
  • \$\begingroup\$ @StewieGriffin Damn it I did! My multitasking is not on top today. However in 5 mins I'll update it again. \$\endgroup\$ Nov 1 '15 at 13:18

PHP, 1204 - (10 * 64) - 15 - 20 = 529 bytes

<?php $i = $argv[1];$s = json_decode(gzuncompress(hex2bin("78da555351b2db200cbc8a27dfee057a1b192bc018104f40dcbccebb7b25d9499d8fcc588b10abddcddf1b64e4e8a04c3bd1eac86db7df3774e136dfa0744c5451805688bb400bac1e5900cfb42703ba1e3bc6e3ce82dabe8cef6f2d22af52b910b95ad93b72d173a22c8083f4d0f63bc75c131aa2e332d2ae45886e43ed7769082f438afc52027df46b20182af457b83c24537ad2c199484b99f6fe669dd9afcd6cc70ef67972a03bb8c10915abb12aa995bc7206deac48555818a9e80ea46cf8142020fe0aa0ccd761327e0db00e046f745426d0c531610d22af609d47aea8dade91d998ad447aebcef6aef0b32d7d64b8df4ddd84a0173c436b816a35475efbf8110bc254a3bf6a1420b76e7d1788f1a346ceb14f8e61b98c0bc44ddb0a46afe284582b55ea9087e1af2004236b3999278a452726c8cb8bef3c2d0086b14ad362f1f3b4032fe67b8aa59cae88742744aab26ccff3f47a2583af11ad0f344c0a1119910553b2d864929562270577b14a87d10635ea351a3e0895572ffd11f0f8ac0867fadf36898668249c65a732448e387de481c1c96931272598863c8ed09ec6b17020874c5792ac1e5bea8ee234c7c238df1a42faff449360552b55c05660d3d5426c4dcb0a7c26f874ac75f0d7a7da0e079da7145d74f848418fc71f5a75d652947a4e1edd469715fae023e29e96c3b0c748027e847a87c4ef4cc893820438722f666bc9a6cb69facf3f28e87499")));echo array_key_exists($i,$s)?"$i goes {$s->$i}":($i=="fox"?"What does the $i say":$i);

I use a json encoded gz compressed array of animal sounds. This means it works with all 65 allowed animals, but my script is huge. Also works with fox and doesn't have the word cat in it.


MATLAB, 46 bytes

regexprep(input(''),'^cat$','cat goes "Meow"')

Admittedly trivial. The input must be given in single quotes.

  • \$\begingroup\$ I'm not sure, but I think ans = .. is generally not accepted, if the challenge is to print something. I'm not sure if it's a consensus, but it's quite common to use disp or something similar. \$\endgroup\$ Nov 2 '15 at 15:01
  • \$\begingroup\$ +1 though, for being shorter than mine =) \$\endgroup\$ Nov 2 '15 at 15:01

Beam, 208 206 - 15 = 191 bytes

Not a competitive entry, but a bit of fun to do. It checks the first for letters of the input against cat. If it gets a mismatch it will shortcut to the standard cat program. If it matches it will append goes "Meow"

/++++++++++/r /SP''+(++++/
\+)'PSrn@--S/ \rn@`>`)rn'''''>`++++++)++@P'p++++@'p-----@`p++@'p-@``p@++@'''''>`+++++++++)--@'p++@'p-----@++++++++@``p++@H
/@<  (`<     < `<    ''<

Java = 222 bytes (compressed)

public class A {public static void main(String[] args) {Scanner a=new Scanner(System.in);for(;;){String b=a.nextLine();if(!b.equalsIgnoreCase("cat"))System.out.println(b);else {System.out.println("meow");System.exit(0);}}}

Or I could decompress it.

Batch = 52 bytes

set /p k=
if "k"=="cat" (echo cat) ELSE (echo %k%)

Javascript: 48 Characters, 48 Bytes

function(s){return (s=="cat")?"cat goes meow":s}





<="cat goes meow"

  • \$\begingroup\$ Good work! You could drop the parentheses around s=="cat". Also, the cat's string is supposed to be cat goes "Meow", so 'function(s){return s=="cat"?'cat goes "Meow"':s} is completely valid. \$\endgroup\$ Nov 8 '15 at 20:53
  • \$\begingroup\$ If you wanted to save even more, you could use ES6: s=>s=="cat"?s+' goes "Meow"':s (30 bytes) \$\endgroup\$ Nov 8 '15 at 20:54
  • \$\begingroup\$ @ETHproductions OOooh, that's good! I don't know that kind of syntax though, a link perhaps? \$\endgroup\$
    – Fuzzyzilla
    Nov 8 '15 at 23:41
  • \$\begingroup\$ @Fuzzyzilla it's part of a new version of JavaScript called "ES6", link to the new function syntax and overview. Here are also tips for ES6 and tips for JavaScript in general \$\endgroup\$
    – Downgoat
    Nov 9 '15 at 0:22

Haskell, 52-15 = 37 bytes

c"\99at"="\99at goes \"Meow\""
c s=s
main=interact c

Using \99 as a substitute for c in “cat” so as to get the 15 bytes bonus.


O, 22 16 14 bytes

29 bytes - 15

Q"tac"`J=J" goes \"Meow\""+Q?

It's long and can be golfed more


𝔼𝕊𝕄𝕚𝕟, 23 - 15 = 8 chars / 58 - 15 = 43 bytes

ïċɘ㴃탵ˠⓀ㐀攁退胦ްおр夁䰰ᷗȿ 쨀#

Try it here (Firefox only).

The byte to char ratio is real.


Pyth, 82-95 = -13 bytes

+z*}zKc."atÜiÃ'4ãl¾Eªîiû<-È&e"\jjk[d"goes"dNr@c."bw««[áÅ3ÏB"\c%x`Kz3 3N

I finally got around to converting my new functional Python 2 entry to Pyth. It doesn't beat the top contender. Turns out zipping together more animals into a larger dictionary reduces score faster than cleverly associating animals with sounds. This supports 8 animals in addition to cat: rhino, okapi, moose, lion, tiger, badger, hippo, and stag.

Try it online


Japt, 25-15=10 24-15 = 9 bytes

First time trying Japt:

N¦`¯t`?N:`¯t goƒ \"´ow\"

ƒ should be replaced with unprintable character U+0083 Compiles to:

N!="cat"?N:"cat goes \"meow\""

Old solution:

N¥`¯t`?`¯t goƒ \"´ow\"`:N

Try it here

  • \$\begingroup\$ Pretty nice! Sorry the backslashes are necessary, I thought I had fixed that. \$\endgroup\$ Jan 3 '16 at 16:07
  • \$\begingroup\$ Since the code contains an unprintable character, which Markdown discards, could you please add a link? \$\endgroup\$ Jan 3 '16 at 16:11
  • \$\begingroup\$ Added the link, also why does U+0083 get replace U+0192 or ƒ when you run this snippet: "\u0083".charCodeAt() \$\endgroup\$ Jan 3 '16 at 16:42
  • \$\begingroup\$ I have no clue. I can't seem to reproduce this. \$\endgroup\$ Jan 3 '16 at 17:03

Pyth, 26-15 (no "cat") = 11 bytes

My first ever Pyth program!

Iqz_"tac"+z" goes meow";Ez

Try it here


   _"tac"                   # Reverse the string "tac"
Iqz                         # If the input equals "tac" reversed
         +z" goes meow";    # Append " goes meow"
                        Ez  # Else, use the input.
                            # Implicit: print the input, if it's used.

Pyke, 391 -595 = -204 bytes (noncompetitive)

-58*10 extra animals, -15 for no "cat" string


Try it here!

Uses dictionary-based compression to store the words. Pyke is older than the question.

Animals it knows:

{'seals': 'bark', 'turkeys': 'gobble', 'mosquitos': 'whine', 'curlews': 'pipe', 'dogs': 'howl', 'sheep': 'bleat', 'elephants': 'trumpet', 'eagles': 'scream', 'raccoons': 'trill', 'goats': 'bleat', 'donkeys': 'bray', 'monkey': 'whoop', 'snakes': 'hiss', 'wolves': 'howl', 'grasshoppers': 'chirp', 'ferrets': 'dook', 'geese': 'honk', 'ducks': 'quack', 'chinchillas': 'squeak', 'oxen': 'low', 'pigs': 'snort', 'lions': 'snarl', 'antelopes': 'snort', 'crows': 'caw', 'hamsters': 'squeak', 'ravens': 'croak', 'leopards': 'snarl', 'tapirs': 'squeak', 'lambs': 'bleat', 'horses': 'neigh', 'jaguars': 'snarl', 'crickets': 'chirp', 'moose': 'bellow', 'cattle': 'moo', 'deer': 'bellow', 'rooks': 'caw', 'dolphins': 'click', 'whales': 'sing', 'owls': 'hoot', 'walruses': 'groan', 'cicadas': 'chirp', 'tigers': 'snarl', 'chickens': 'cluck', 'giraffes': 'bleat', 'mice': 'squeak', 'peacocks': 'scream', 'songbirds': 'sing', 'geckos': 'croak', 'frogs': 'croak', 'pigeons': 'coo', 'swans': 'cry', 'bitterns': 'boom', 'rhinoceros': 'bellow', 'cats': 'purr', 'badgers': 'growl', 'magpies': 'chatter', 'vultures': 'scream', 'elk': 'bleat'}

C++11, 316 - 11*10 - 15 = 191 bytes

#include <map>
#define t(a,b){#a,#b},
using s=std::string;int main(){std::map<s,s>m{t(cow,moo)t(crow,caw)t(dog,bark)t(hog,oink)t(lark,sing)t(lion,roar)t(oxen,low)t(rook,caw)t(seal,bark)t(sheep,baa)t(swan,cry){"c""at","meow"}};s l;while(int i=~getchar())l+=~i;printf("%s",(m[l]==""?l:l+" goes \""+m[l]+'"').c_str());}

Compiles well with VisualStudio. GCC wants me to #include <string> and #include <cstdio>. It would be shorter if I wouldn't go for bonuses, but I still hope author revises bonuses. I can't think of language where defining cow -> moo or so is way way shorter than 10bytes. Mine cost 3+key+value bytes for additional animal and flat 22+17 bytes for defining structure and so.


#include <map>

#define t(a, b) { #a, #b },
using s = std::string;
int main()
    std::map<s, s> m{
        { "c""at", "meow" }
    s l;
    while (int i = ~getchar())
        l += ~i;
    printf("%s", (m[l] == "" ? l : l + " goes " + m[l]).c_str());
  • \$\begingroup\$ "t(crow,caw)" has a length of 11. So getting rid of that to "t(swan,cry)" would drop 14 bytes. And admittedly make it less fun :( \$\endgroup\$
    – Noodle9
    Nov 2 '15 at 6:33
  • \$\begingroup\$ @user, As I said, I still hope author revises bonuses. \$\endgroup\$
    – Zereges
    Nov 2 '15 at 9:01
  • \$\begingroup\$ You should state C++11 in the headline. Python 2 and 3 are also always distinct noted. While the using is no big deal, the initializer list is. \$\endgroup\$
    – Karl Napf
    Nov 28 '16 at 14:23
  • \$\begingroup\$ @KarlNapf Thanks for pointing that out. \$\endgroup\$
    – Zereges
    Nov 28 '16 at 17:07
  • \$\begingroup\$ You can also change #include <map> to #import<map> for -2 bytes. The space before < can be omitted and #import throws some warnings but is accepted be GCC and MSVC \$\endgroup\$
    – Karl Napf
    Nov 28 '16 at 17:11

GolfScript, 25 - 15 = 10 bytes

."c""at"+=" goes 'Meow'"*

Try it online!


."c""at"+=" goes 'Meow'"*   # Input: cat
."c""at"                    # Duplicate input, push c and at. Stack: cat cat c at
        +                   # Concatenate, Stack: cat cat cat
         =                  # Check if equal, Stack: cat 1
          " goes 'Meow'"*   # " goes 'Meow'" pushed onto stack n times, Stack: "cat" " goes 'Meow'"
                            # Implicitly print

Alternate Example

."c""at"+=" goes 'Meow'"*   # Input: asdf
."c""at"                    # Duplicate input, push c and at. Stack: asdf asdf c at
        +                   # Concatenate, Stack: asdf asdf cat
         =                  # Check if equal, Stack: asdf 0
          " goes 'Meow'"*   # " goes 'Meow'" pushed onto stack n times, Stack: "asdf" ""
                            # Implicitly print

Your Answer

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