37
\$\begingroup\$

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".

Scoring

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.

Rules

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

Leaderboard

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>

\$\endgroup\$
16
  • 20
    \$\begingroup\$ For the bonuses: What does the fox say? \$\endgroup\$ Nov 1, 2015 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, 2015 at 9:06
  • 2
    \$\begingroup\$ Cats say meow.. \$\endgroup\$ Nov 1, 2015 at 11:37
  • 1
    \$\begingroup\$ Instead of double quotes, can you use single ones? Also, can you output to stderr? \$\endgroup\$
    – Blue
    Nov 1, 2015 at 12:47
  • 5
    \$\begingroup\$ Why is there no link to this in this challenge? \$\endgroup\$
    – Jan
    Nov 1, 2015 at 20:50

70 Answers 70

1
\$\begingroup\$

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

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

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

\$\endgroup\$
4
  • \$\begingroup\$ Pretty nice! Sorry the backslashes are necessary, I thought I had fixed that. \$\endgroup\$ Jan 3, 2016 at 16:07
  • \$\begingroup\$ Since the code contains an unprintable character, which Markdown discards, could you please add a link? \$\endgroup\$ Jan 3, 2016 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, 2016 at 16:42
  • \$\begingroup\$ I have no clue. I can't seem to reproduce this. \$\endgroup\$ Jan 3, 2016 at 17:03
1
\$\begingroup\$

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

My first ever Pyth program!

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

Try it here

Explaination

   _"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.
\$\endgroup\$
1
\$\begingroup\$

05AB1E, score: -136 (214 bytes - 31*10 - 15 - 25)

'¨›Qi“What‚à€€ ÿ…è“ë“ÓÕŸâÍݹÐÀ¼Û˗Ĭ…ЧÀÛÆÓ‹·»ÑÐœ²èàæÑåÚÆÚØåÊÓ³âÌ–ÔĤ•ã‚í„ÄŠêÂÝ¢“#sk©di.•QÀ}£≠‰ŒΛ(Ïûвrüéä[ñøuF½3¡üÃïßåιQÊçdï€]Üвβ`šŠû©ª«ĀLΩÝβ\à¨TĆηÎ.₄₆öª$γâôΘ:Æ™{¹и5|Âć®λ¬¡¸αâË::´óýÏƶ5~¦m.škα†#Ð6λ•#®è™s“ÿ—± "ÿ"

Bonuses:

  • -15 for not using cat
  • -25 for outputting What does the fox say when the input is fox
  • 31 times -10 for the animals and sounds: ["bat screech","bear roar","bee buzz","tiger roar","lion roar","jaguar snarl","cat meow","chicken cluck","cow moo","cricket chirp","deer bellow","dog bark","wolf howl","duck quack","eagle screech","elephant trumpet","frog croak","horse neigh","mouse squeak","monkey scream","pig oink","rabbit squeak","seal bark","sheep baa","snake hiss","turkey gobble","whale sing","ass heehaw","rat squeak","goat bleat","lamb baa"]

Try it online or verify all used animals.

Explanation:

'¨›                  '# Push dictionary word "fox"
   Qi                 # If the (implicit) input-string equal "fox":
     “What‚à€€ ÿ…è“   #  Push dictionary string "What does the ÿ say"
                      #  (where the `ÿ` is automatically filled with the implicit input)
   ë                  # Else:
    “ÓÕŸâÍÝ...ÄŠêÂÝ¢“ #  Push dictionary string "bar bear bee ... rat goat lamb"
    #                 #  Split it on spaces
    sk                #  Get the index of the input-string in this list (-1 if not found)
    ©                 #  Store this index in variable `®` (without popping)
    di                #  If this index is non-negative (>= 0):
      .•QÀ...Ð6λ•    #   Push compressed string "screech roar ... bleat baa"
      #               #   Split it on spaces
      ®è              #   Index variable `®` into this list
      ™               #   Titlecase this sound
      s               #   Swap to get the (implicit) input-string at the top of the stack
      “ÿ—± "ÿ"        #   Push dictionary string 'ÿ goes "ÿ"'
                      #   (where the first `ÿ` is the input at the top of the stack,
                      #    and the second `ÿ` is the titlecased sound below it)
                      # (after which the top of the stack is output implicitly as result,
                      #  which will be the (implicit) input itself for any other input)

See this 05AB1E tip of mine (sections How to use the dictionary? and How to compress strings not part of the dictionary?) to understand why:

  • '¨› is "fox"
  • “What‚à€€ ÿ…è“ is "What does the ÿ say"
  • “ÓÕŸâÍݹÐÀ¼Û˗Ĭ…ЧÀÛÆÓ‹·»ÑÐœ²èàæÑåÚÆÚØåÊÓ³âÌ–ÔĤ•ã‚í„ÄŠêÂÝ¢“ is "bat bear bee tiger lion jaguar cat chicken cow cricket deer dog wolf duck eagle elephant frog horse mouse monkey pig rabbit seal sheep snake turkey whale ass rat goat lamb"
  • .•QÀ}£≠‰ŒΛ(Ïûвrüéä[ñøuF½3¡üÃïßåιQÊçdï€]Üвβ`šŠû©ª«ĀLΩÝβ\à¨TĆηÎ.₄₆öª$γâôΘ:Æ™{¹и5|Âć®λ¬¡¸αâË::´óýÏƶ5~¦m.škα†#Ð6λ• is "screech roar buzz roar roar snarl meow cluck moo chirp bellow bark howl quack screech trumpet croak neigh squeak scream oink squeak bark baa hiss gobble sing heehaw squeak bleat baa"
  • and “ÿ—± "ÿ" is 'ÿ goes "ÿ"'
\$\endgroup\$
1
\$\begingroup\$

Pyth, 132 - 150 (animals) - 15 (no cat) = -33 bytes

pJjb.zp.x++" goes \""[email protected]\ic."ay-ÝÏåâšB²ÅuŠ°µ²¦DIJÖì |t`2“‚Êôë¨}èÔèw:ÿÊ_OƒÄ<Ú›ø‚î½ùÛ&L°„6a<9-¾¹™,Uø0é6Œû²Ù²ËyÊ·%C"\lJ4\"k

Try it online!

Uses a packed string to fit in animals for less than 10 bytes each

Full list:

parrot goes "Squack"
cat goes "Meow"
rook goes "Caw"
ass goes "Bray"
goose goes "Honk"
dog goes "Woof"
duck goes "Quack"
sheep goes "Baa"
ox goes "Moo"
raven goes "Caw"
goat goes "Baa"
swan goes "Cry"
frog goes "Croak"
toad goes "Croak"
monkey goes "Chatter"

Edit 1: Almost forgot the no cat bonus :P

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

GolfScript, 25 - 15 = 10 bytes

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

Try it online!

Example

."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
\$\endgroup\$
1
\$\begingroup\$

Nim, 65 - 15 = 56 50 bytes

Does not use the word cat. Supports only cat and then "Meow", no other animals.

while 1>0:
 var i=readLine stdin;echo if i=="ca"&"t":"Meow"else:i

Attempt This Online!

(-6 bytes thanks to Steffan)

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

TI-Basic, 48 bytes

Input Str1
Str1="cat
If Ans
Disp Str1+" goes Meow
If not(Ans
Disp Str1

All those lowercase letters are increasing the bytecount by a lot.

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

Vyxal, 285 - 310 - 15 - 25 = -65 bytes

`∷¾`=[`λ⟩ ƛ∪ λλ ∷¾ ∨¶`|`Ḃṙ ∞¨ εċ ṗµ √₇ Ṁ⋎ ¢₌ β¡ ¦‹ √⊍ ₃⇩ •ƈ ṡƒ ¦ø ḟ₇ Ẇ⟑ µɽ ½ż Þ‡ ₃⅛ Ḣ⟨ ₈Ḋ ġṄ ⁋ė Ċṁ ∴† Ẏ₇ ass ₀⌈ ⌊ṫ Ȯ⁰`⌈?ḟ:£0≥[`s⇩⋏↳⋎ r⋎« Ȧ¨ r⋎« r⋎« sn₴£ m□ŀ cḟĿ moo ch↲Ṗ Ǎ⟩⟑ṙ •øk h⋎₄ qꜝ½k s⇩⋏↳⋎ t≥⁋⌐¨ crβ⁰ ne⋏ṫ sȧ‛ak s›‹ o›₌ sȧ‛ak •øk baa λµs £⁋ǎʁ ⟩ɽ hee¥↓ sȧ‛ak bl↓⟑ baa`⌈¥i`% ¢₃ `?%$+

Try it Online!

Port of Kevin Cruijssen's 05AB1E answer.

Vyxal, 42 - 15 - 25 = 2 bytes

`¢₌`=[`¢₌ ¢₃ "M□ŀ"`|`∷¾`=[`λ⟩ ƛ∪ λλ ∷¾ ∨¶`

Try it Online!

Bonuses:

  • -15 for not using cat
  • -25 for responding to fox with What does the fox say

Vyxal, 19 - 15 = 4 bytes

`¢₌`=[`¢₌ ¢₃ "M□ŀ"`

Try it Online!

Bonuses:

  • -15 for not using cat

Explanation

Most of it is just string compression:

  • `¢₌` is cat
  • `¢₌ ¢₃ "M□ŀ"` is cat goes "meow"
  • `∷¾` is fox
  • `λ⟩ ƛ∪ λλ ∷¾ ∨¶` is What does the fox say
\$\endgroup\$
0
\$\begingroup\$

Pyth, 31 - 15 = 16 bytes

You can try it out here

In+C99"at"zz;E+z" goes \"Meow\"

Explaination:

I                                # If-statement
 n                               # not equal
  +C99"at"                       # Adds the char 99 with the string "at" = "cat"
          z                      # z, the user input
           z                     # Print the user input
            ;                    # Ends all open parentheses
             E                   # Else-statement
              +z" goes \"Meow\"  # Adds ' goes "Meow"' to z and prints the result
\$\endgroup\$
1
  • 1
    \$\begingroup\$ C99 can be replaced with \C. It's still +\C"at", so you can keep the bonus. \$\endgroup\$
    – clapp
    Nov 2, 2015 at 1:19
0
\$\begingroup\$

C, 76 bytes

main(){char a[99];gets(a);printf("%s%s",a,strcmp(a,"cat")?"":" goes meow");}
\$\endgroup\$
0
\$\begingroup\$

PHP, 70-15 = 55 bytes

<?=$l=rtrim(stream_get_contents(STDIN),~òõ),$l==~œž‹?~ߘšŒßݲšˆÝ:'';

(saved as ISO-8859-1)

Uses inverted undefined constants as string literals:

  • ~òõ == "\r\n"
  • ~œž‹ == 'cat'
  • ~ߘšŒßݲšˆÝ == ' goes "Meow"'

Everything is combined in a single echo statement, shorthanded with <?=

\$\endgroup\$
0
\$\begingroup\$

Ruby, 35 + 2 (-p flag) - 15 = 22 bytes

$_==?c'at
'&&$_[-2]+=' goes "Meow"'

Inspired by trying to improve Peter Lenkefi's solution.

\$\endgroup\$
0
\$\begingroup\$

Ruby, 110 + 2 (-p flag) -60 (cow, ox, dog, bee, pig and crow) -15 (no cat) = 37 bytes

(h=Hash[*%W(cow Moo ox Low c\141t Meow dog Woof bee Buzz pig Oink crow Caw)][$_.chop])&&$_[-2]+=' goes "'+h+?"

Multiple animal Ruby solution... As long as the animal+sound is <8 characters, it shrinks for each one added. Gross abuse of Ruby. :)

\$\endgroup\$
0
\$\begingroup\$

Ruby, 26 + 1 = 27

With command-line flag -p, run

sub /^cat$/,'\& goes Meow'

Getting the no-cat bonus costs 2 bytes, which isn't actually worth it:

sub /^c at$/x,'\& goes Meow'
\$\endgroup\$
0
\$\begingroup\$

Hassium, 67 Bytes

func main()if((x=input())=="cat")print(x+" goes meow")else print(x)

See expanded here

\$\endgroup\$
1
  • \$\begingroup\$ It's fine to link to an online interpreter so that readers can test the code themselves, but you should still include sufficient explanation or expansion in the post such that a casual reader could convince themself that your submission is correct. \$\endgroup\$
    – Alex A.
    Dec 22, 2015 at 5:39
0
\$\begingroup\$

JacobFck, 31 Bytes

I really like the golfed version of this.

"cat"<|=_e>!:e"cat goes Meow">

See commented and expanded here

\$\endgroup\$
0
\$\begingroup\$

Python 2, 149-95 = 54 bytes

-8*10 extra animals, -15 for no "cat"

u=raw_input()
l="ca""t badger rhino okapi moose stag tiger hippo lion".split()
print u+' goes "%s"'%["Growl","Bellow","Meow"][`l`.find(u)%3]*(u in l)

Supported animals:

  • moose, stag, okapi, rhino (all Bellow)
  • tiger, badger, lion, hippo (all Growl)

This is not the shortest Python answer, but at least it does bother to try at some other animals! I add it here because the answer i had previously did not work, and I'm confident this will become the shortest Pyth answer once I translate it and golf it there.

How it works:

  1. Take input
  2. Create a list of animals in a very precise order.
  3. Print the input, and if the input is in the list, use the location of the input in the string representation of the list to index an array of sounds, and append the appropriate "goes" string.
\$\endgroup\$
0
\$\begingroup\$

Arcyóu, 38 bytes (non-competitive)

Since this version of the language was made after the challenge was posted, it is not eligible.

(: s(q))(?(= s "cat")"cat goes Meow" s

Arcyóu is a LISP-like golfing language.

Explanation:

(: s(q))           ; Set the variable s to the contents of STDIN
(? (= s "cat")     ; If-statement. Condition is s == "cat"
  "cat goes Meow"  ; If true: return the string "cat goes Meow"
  s                ; Otherwise, return what was entered

Arcyóu automatically prints the result of the last expression evaluated. In this case, it is the ? statement. It also allows you to leave off trailing close-parens.

\$\endgroup\$
0
\$\begingroup\$

Emacs Lisp (67 Bytes)

(set'a(read-string""))(message(pcase a("cat""cat goes meow")(_ a)))

It uses pattern matching to distinguish cats from other input. This could be extended to fit other animals in as well, but as most of them take up more than 10 characters, there is not much to be gained from that.

\$\endgroup\$
0
\$\begingroup\$

Milky Way 1.5.16, 29 bytes - 15 = 14

"c""at"+'?{b_" goes Meow"+_}!

Doesn't use a "cat" string.


Explanation

"c""at"      " goes Meow"      # push string to the stack
       +                 +     # add the TOS and the STOS
        '                      # read input from the command line
         ?{ _             _}   # if statement
           b                   # equality of the TOS and the STOS
                            !  # output the TOS

Usage

python3 milkyway.py <path-to-code> -i <input>
\$\endgroup\$
0
\$\begingroup\$

Perl, 13 bytes

The string "cat" does not appear in my code (Special thanks to Dennis for shaving 15 bytes off of the code, and teaching me some new Perl tricks):

s/^(c)at$/$& goes Meow/
\$\endgroup\$
4
  • \$\begingroup\$ Neither of those are mentioned in the OP, unless I am missing something? It simply needs to take input and replace "cat" with cat goes Meow. I'm not sure if I missed something but I think my answer is valid. \$\endgroup\$
    – Codefun64
    Dec 12, 2015 at 18:06
  • \$\begingroup\$ In other words, unless the string is exactly the string "cat" it should not be reached. \$\endgroup\$
    – quintopia
    Dec 13, 2015 at 0:33
  • \$\begingroup\$ Ah, I see what you mean. Very well, I'll make a minor edit to it. \$\endgroup\$
    – Codefun64
    Dec 13, 2015 at 3:03
  • \$\begingroup\$ Alternatively, s/^(c)at$/$& goes Meow/ with the -p switch. \$\endgroup\$
    – Dennis
    Dec 13, 2015 at 3:24
0
\$\begingroup\$

C#6, 302 - 110 - 15 = 177 bytes

This works for 12 different animals, including cat. It does not include the word "cat" verbatim.

using static System.Console;class P{static void Main(){var a=ReadLine();var d="bee,Buzz,c\x61t,Meow,cow,Moo,crow,Caw,dog,Bark,hog,Oink,lamb,Baa,lion,Roar,ox,Low,owl,Hoo,pig,Oink,rook,Caw,seal,Bark,sheep,Baa,swan,Cry".Split(',');int i=22;while(--i>0&&d[--i]!=a);Write(i<0?a:d[i]+" goes '"+d[i+1]+"'");}}

Indentation and new lines for clarity.

using static System.Console;
class P{
    static void Main(){
        var a=ReadLine();
        var d="bee,Buzz,c\x61t,Meow,cow,Moo,crow,Caw,dog,Bark,hog,Oink,lamb,Baa,lion,Roar,ox,Low,owl,Hoo,pig,Oink,rook,Caw,seal,Bark,sheep,Baa,swan,Cry".Split(',');
        int i=22;
        while(--i>0&&d[--i]!=a);
        Write(i<0?a:d[i]+" goes '"+d[i+1]+"'");
    }
}
\$\endgroup\$
0
\$\begingroup\$

DIG, 163 - 15 = 148 bytes

Disclaimer: Due to the fact that DIG was created after the challenge, this answer is non-competing.

Beautiful cats

Zoomed in (Note: This file will NOT compile, due to the nature of the language)

Impossible Cats

While I have no idea if this is considered a valid language for PPCG, it does complete the challenge. Documentation for the language can be found here and the interpreter can be found here.

\$\endgroup\$
1
  • \$\begingroup\$ Welcome to Programming Puzzles & Code Golf! This language is pretty cool but I think the community and readers would benefit if you took this approach and included as well an enlarged version of the image -- even zooming on this one is too small. \$\endgroup\$
    – cat
    Dec 16, 2015 at 1:40
0
\$\begingroup\$

Swift 2.0, 71 68-15 (no "cat") = 53 bytes

func a(s:String)->String{return s=="c\u{61}t" ?s+" goes \"Meow\"":s}

For some reason, a compilation error is thrown if there isn't a space before the ternary operator ?

Ungolfed

func a(s: String) -> String{
    return s == "c\u{61}t" ? s + " goes \"Meow\"" : s
}

This doesn't use "cat" in it by replacing the a with the unicode literal \u{61}. You can test this code here

\$\endgroup\$
0
\$\begingroup\$

JavaScript, 35 - 15 (-p no cat) = 20 Bytes

c=i=>(i=='c\at')?i+' says "Meow"':i

Can someone check to see that I did the header right?

\$\endgroup\$
0
\$\begingroup\$

Retina, 23 - 15 = 8 bytes

^ca\0*t$
$& goes "Meow"
\$\endgroup\$
0
0
\$\begingroup\$

Pylongolf2, 33-15=18 bytes

"tac"╨1cd_@0=b?" goes Meow"¿~

Explanations:

"tac"╨1cd_@0=b?" goes Meow"¿~
"tac"                         push "tac" to stack
     ╨1                       reverse it
       cd                     read input and then select latest item in stack
         _                    duplicate input
          @0                  select first item in stack
            =b                compare then swap places
              ?               if true,
               " goes Meow"¿  push " goes Meow" to stack and end if statement
                            ~ print it.
\$\endgroup\$
0
\$\begingroup\$

Lua 5.3.2, 229 - 25 - 15 - 80 (extra animals) = 109 bytes

r={...}a={['\99\97\116']='Meow',duck='Quack',sheep='Baa',bee='Buzz',frog='Croak',bat='Screech',elk='Bugle',swan='Cry',pig='Oink'}print(r[1]=='fox' and 'What does the fox say' or(a[r[1]] and r[1]..' goes "'..a[r[1]]..'"' or r[1]))

Ungolfed

local Args = {...}
local Sounds = {
    ['\99\97\116'] = 'Meow',
    duck = 'Quack',
    sheep = 'Baa',
    bee = 'Buzz',
    frog = 'Croak',
    bat = 'Screech',
    elk = 'Bugle',
    swan = 'Cry',
    pig = 'Oink'
}
print(
    Args[1] == 'fox' and 'What does the fox say' or (
        Sounds[Args[1]] and Args[1] .. ' goes "' .. Sounds[Args[1]] .. '"' or Args[1]
    )
)

I tried to make the logic a little clearer by putting it on multiple lines.
It's essentially a ternary operator ?:

\$\endgroup\$
0
\$\begingroup\$

AWK, 32 - 15 = 17

/^[c]at$/{$0=$0" goes 'Meow'"}1

I think this counts as not using "cat". Could have saved a couple bytes if "cat" were allowed to be anywhere in the line.

For giggles I also put together one with more animals, but it's not competitive, especially with trying to capture the correct verb to use, but here's what I came up with :)

{for(;I<split("ca""t,Meow,bees,Buzz,bird,Song,cow,Moo,crow,Caw,dog,Woof,duck,Quack,frogs,Croak,hog,Oink,ox,Low,pig,Oink,sheep,Baa,swan,Cry",a,",");)
m[a[I-1]="'"a[I+=2]"'"}
m[$0]{$0=$0($0~/s$/?" go ":" goes ")m[$0]}
/^fox$/{$0="What does the fox say"}
1
\$\endgroup\$

Your Answer

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