[Question]
  [
Everyone knows that cats go meow, but what many don't realise is that caaaats go meeeeoooow. In fact, the length of the vowel sounds that the cat makes are dependant on the length of the vowel with which you address it.
In the same way, cows go moo, but coooows go moooooooo
## Challenge
You are to write a program that takes as input, a word meaning cat, **and** a word meaning cow, determine the number of main vowels, and print one of the following strings, as appropriate:
* `C[]ts go M[]w`
* `C[]ws go M[]`
Where `[]` stands for the vowels, according to the following rules:
* The number of e's and o's in "Meow" must both match the number of vowels found in the input word.
* The number of o's in "Moo" must be double the number of vowels found in the input word.
The program must recognise the input words `cat` and `cow`. Input may use any capitalisation that is most convenient, but the output must be capitalised exactly as shown above.
  
[Answer]
## [Retina](https://github.com/mbuettner/retina), ~~57~~ ~~49~~ ~~44~~ ~~43~~ 41 bytes
~~So close...~~ ~~:)~~ Pyth...
```
.(.+).
$0s go M$1$1
+`aa(\w*$)
e$1ow
wo
o
```
[Try it online.](http://retina.tryitonline.net/#code=LiguKykuCiQwcyBnbyBNJDEkMQorYGFhKFx3KiQpCmUkMW93CndvCm8&input=Q2FhYXQ)
Expects input to be capitalised like `Caaat` or `Coooow`.
### Explanation
```
.(.+).
$0s go M$1$1
```
The regex matches the entire input, and captures the vowels in group `1` (we don't need anchors, because the match cannot fail and will greedily match the entire input). The substitution writes back that input, and appends `s go M`, followed by twice the vowels. For inputs `Caaat` and `Coooow`, we get:
```
Caaats go Maaaaaa
Coooows go Moooooooo
```
The output for cows is already correct. We just need to do something about those cats.
```
+`aa(\w*$)
e$1ow
```
The `+` tells Retina to repeat this stage as often as possible. The regex matches two `a`s in the last part of the string (we ensure this with the `$` anchor, so that we don't replace things inside `Caaats`). This will essentially match everything after `M`, as long as that part still has `a`s. The two `a`s are removed and the entire suffix after it is wrapped in `e...ow`:
```
Caaats go Meaaaaow
Caaats go Meeaaowow
Caaats go Meeeowowow
```
Finally, there are two many `w`s in the result, so we remove those that precede an `o` (to make sure we're not messing up the `w` in `Coooows`):
```
wo
o
```
And we're left with:
```
Caaats go Meeeooow
```
[Answer]
# LabVIEW, 58 [LabVIEW Primitives](http://meta.codegolf.stackexchange.com/a/7589/39490)
creating strings like this is a pain...
The leftmost vis are pattern matching, a+ and o+ respectively search for the lagest amount of as and os in a row. 
Taking the lenght of those i create 3 arrays 1 with lenght os 1 with lenght es and one with 2 times lenght os.
Then all the parts get put together. First the original input, then s go M all the Arrays, the unused one are empty so they will be ignored, and finally a w if the input was cats. (If as were found there will be a t after the match, if not after match is empty)
[![](https://i.stack.imgur.com/Fc5rt.gif)](https://i.stack.imgur.com/Fc5rt.gif)
For the lolz i also implemented the fox with 6 different outputs^^
[![](https://i.stack.imgur.com/C7SA3.gif)](https://i.stack.imgur.com/C7SA3.gif)
[Answer]
# Pyth, 50 44 34
Takes input in the format `["caat", "coow"]`.
```
Pj.bs[rN3"s go M"S*-lN2+Y\o\w)Q"eo
```
[Try it online.](http://pyth.herokuapp.com/?code=Pj.bs%5BrN3%22s%20go%20M%22S%2A-lN2%2BY%5Co%5Cw%29Q%22eo&input=%5B%22caat%22%2C%20%22coow%22%5D&debug=0)
Explained:
```
  .b                                  Map a lambda across two lists in parallel:
                              Q       The input, e.g. ["caat", "coow"]
                               "eo    The string "eo"
    s[                       )            Create and concatenate a list of:
      rN3                                 - The item N in title caps (e.g. "Caat")
         "s go M"                         - The string "s go M"
                 S                        - The sorted version of:
                       +Y\o                   The item Y + "o" ("eo" or "oo")
                  *-lN2                       Times the length of N - 2 (number of vowels)
                           \w             - The string "w"
Pj                                    Join the result on \n and drop the final "w"
```
Thanks to [Jakube](https://codegolf.stackexchange.com/users/29577/jakube) for major reductions in length.
[Answer]
# Perl, ~~66~~ ~~61~~ ~~55~~ 54 bytes
*includes +1 for `-p`*
```
/[ao]+/;$\="s go M".$&=~y/a/e/r.o x($+[0]-1).(w)[/w/]
```
Input is expected to conform to `/^C[ao]+[tw]$/` (no trailing newline!)  
Usage: `/bin/echo -n Caaat | perl -p 55.pl`
### Breakdown
```
/[ao]+/;
$\= "s go M"        # assign to $OUTPUT_RECORD_SEPARATOR, normally `\n`. Saves 1 vs `$_.=`
   . $&             # the matched vowels
     =~ y/a/e/r     # translate `a` to `e`; `/r` returns a copy.
   . o x($+[0]-1)   # append 'o', repeated. $+[0] is string position of last match end.
   . (w)[/w/]       # returns 'w' if there is no /w/ in the input, nothing if there is.
```
---
### Previous version:
```
@l=/[ao]/g;$x=$&[[email protected]](/cdn-cgi/l/email-protection) x@l;$y=$x=~y/a/e/?w:'';s/$/s go M$x$y/
```
*Commented*:
```
@l = /[ao]/g;               # captures $& as vowel and @l as list of vowels
$x = $& x @l .o x @l;       # construct the output vowels
$y = $x =~ y/a/e/ ? w : ''; # correct vowel string for cats (aaaooo->eeeooo); $y='w' if cat.
s/$/s go M$x$y/             # construct the desired output.
```
---
### Example: `Caaat`
* Capture `$&` as `a` and `@l` as `(a,a,a)`.
* Set `$x` to three times `a` followed by 3 times `o`: `aaaooo`.
* Translate all `a` in `$x` to `e`: `eeeooo`. The number of replacements (either 0 or positive) serves as a cat-detector: set `$y` to `w` if so.
* Change the input by appending `s go M`, `eeeooo` and `w`.
---
* *update 61*: Save 5 bytes by using list instead of string
* *update 55*: save 6 bytes by inlining, assigning `$\` rather than `s/$/`, and requiring no trailing newline in input.
* *update 54*: save 1 byte by eliminating @l.
[Answer]
## Python 2, 74 bytes
```
i=input()
l=len(i)-2
print i+'s go M'+['e'*l+'o'*l+'w','o'*l*2][i[-1]>'v']
```
Takes input
`Caaat` or `Cooow`
[Answer]
## CJam (60 57 55 53 bytes)
```
"C%s%ss go M%sw
"2*-2<q"ctw"-S/"teowoo"3/.{(2$,@*$}e%
```
[Online demo](http://cjam.aditsu.net/#code=%22C%25s%25ss%20go%20M%25sw%0A%222*-2%3Cq%22ctw%22-S%2F%22teowoo%223%2F.%7B(2%24%2C%40*%24%7De%25&input=caat%20coow). Input is assumed to be in lower case.
For the same length:
```
"C
s go M"N/_]"w
"a*q"ctw"-S/"teowoo"3/.{(2$,@*$M}]z
```
---
```
'CM"s go M"]2*q"ctw"-S/"teowoo"3/.{(2$,@*$}[MM"w
"]]z
```
[Answer]
## PowerShell, ~~135~~ 132 bytes
```
param($a,$b)
[char[]]"$a$b"|%{if($_-eq'a'){$c++}$d++}
$d-=4+$c
"C$("a"*$c)ts go M$("e"*$c)$("o"*$c)w"
"C$("o"*$d)ws go M$("o"*2*$d)"
```
(linebreaks count same as semicolons, so line-breaked for clarity)
Surprisingly tricky challenge. And I'm reasonably sure this can be golfed further.
Takes input strings as `$a` and `$b`. Concatenates them and casts them as a char-array, then pipes that through a loop `%{}`. Each letter is then checked if it's `-eq`ual to `'a'` and the associated counter variable is incremented appropriately. We then subtract `4+$c` from `$d` to account for `catcw` in the input, and proceed to formulate the output sentences, modifying the vowels output times the corresponding counters. (In PowerShell, `'e'*3` would yield `'eee'`, for example.)
[Answer]
Almost similar to @omulusnr's answer but this produces the correct output and also input is case insensitive.
## PHP, 172
```
$p=$argv[1];
preg_match("/c([ao]+)/i",$p,$e);
$l=strlen($e[1]);
$s=($k=strcmp($e[0][1],'o'))?'eo':'oo';
echo $p,' go M',str_repeat($s[0],$l),str_repeat($s[1],$l),$k?'w':'';
```
[Answer]
## Swift 2, 3̶8̶1̶ 333 bytes
```
func f(i:String)->String{var s=i.lowercaseString;s.replaceRange(s.startIndex...s.startIndex,with:String(s[s.startIndex]).uppercaseString);let c=i.characters.count-2;let l=s.characters.last;return(s+"s go M"+String(count:c,repeatedValue:l=="t" ?"e" :"o" as Character)+String(count:c,repeatedValue:"o" as Character)+(l=="t" ?"w" :""))}
```
**Ungolfed:**
```
func f(i:String)->String{
    var s = i.lowercaseString
    s.replaceRange(s.startIndex...s.startIndex,with:String(s[s.startIndex]).uppercaseString)
    let c = i.characters.count-2
    let l = s.characters.last
    return(s+"s go M"+String(count:c,repeatedValue:l=="t" ?"e" :"o" as Character)+String(count:c,repeatedValue:"o" as Character)+(l=="t" ?"w" :""))
}
```
Takes cat or cow any capitalization. You can try it here:
<http://swiftlang.ng.bluemix.net/#/repl/3f79a5335cb745bf0ba7698804ae5da166dcee6663f1de4b045e3b8fa7e48415>
[Answer]
## MATLAB: ~~190~~ ~~152~~ 118 bytes
```
i=input('','s');b=sum(i=='a');c=sum(i=='o');d=b>c;disp(['C',i(2:2+b+c),'s go M',i(2:1+b)+4,repmat('o',1,b+2*c),'w'*d])
```
Ungolfed:
```
i=input('','s');
b=sum(i=='a');
c=sum(i=='o');
d=b>c;
disp(['C',i(2:2+b+c),'s go M',i(2:1+b)+4,repmat('o',1,b+2*c),'w'*d])
```
Tests:
```
caaaaaaaats
Caaaaaaaats go Meeeeeeeeoooooooow
cooooows
Cooooows go Moooooooooo
```
P.S.: Thanks to @Kenney for nice suggestion (see comments)!
[Answer]
# PHP, 138 bytes
```
echo ucfirst($a=$argv[1]).'s go M'.(($n=substr_count($a,'a'))?str_repeat('e',$n).str_repeat('o',$n).'w':str_repeat('oo',substr_count($a,'o')));
```
---
readable:
```
echo ucfirst($a = $argv[1]) . 's go M'. (
    ($n = substr_count($a, 'a'))
        ? str_repeat('e', $n) . str_repeat('o', $n) . 'w'
        : str_repeat('oo', substr_count($a, 'o'))
);
```
tried shorter but wont work in PHP:
```
#too long -- echo ucfirst($s=$argv[1]).'s go M'.(($o='o'and$n=substr_count($s,'a'))?str_repeat('e',$n).str_repeat($o,$n).'w':str_repeat('oo',substr_count($s,$o)));
#too long -- echo ucfirst($s=$argv[1]).'s go M'.(($o='o'and$f=function($s,$n){return str_repeat($s,$n);}and$n=substr_count($s,'a'))?$f('e',$n).$f($o,$n).'w':$f('oo',substr_count($s,$o)));
```
=)
[Answer]
# OCTAVE,  126 , 108
First version with variables and explanation, 126:
```
L="ao"';S={'eo','oo'},e={'w',' '};a=sum(argv(){1}==L,2);b=find(a);disp([argv(){1},' goes m',vec(ones(sum(a),1)*S{b})',e{b}]);
```
Explanation: L knows which animal contains which letter. S knows what they repeat. e knows the ending. You need to have "automatic broadcasting" turned on for this to work, but it should be by default in all Octaves I've used. Of course there exist shorter ways with for example command regexprep (regular expressions with replacement), but there has already been several such approaches in answers already, so that would be boring.
---
**Edit:** Skipping variables which only occur once, using octave on-the-fly indexing (don't know what it's called for real) and adding "i", input string variable:
```
i=argv(){1};a=sum(i=="ao"',2);b=find(a);disp([i,' goes m',vec(ones(sum(a),1)*{'eo','oo'}{b})',{'w',''}{b}]);
```
[Answer]
# JavaScript (ES2015), ~~78~~ 77
```
s=>s+'s go M'+(l=s.length-1,w=s[l]<'u',Array(l).join(w?'eo':'oo')+(w?'w':''))
```
Try it here: <https://jsbin.com/guqaxejiha/1/edit?js,console>
[Answer]
# [Dart](https://www.dartlang.org/), ~~114 112 110 104 102~~ 100 bytes
```
f(s)=>s+'s go M'.padRight(s[1]=='a'?s.length+4:0,'e').padRight(2*s.length+2,'o')+(s[1]=='a'?'w':'');
```
[Try it online!](https://tio.run/##Xcs/C8IwEIfh3U9x2y9natHi1JI6OLu4ikOgf0Gb0gQyiJ89YhGtue3ufa7SkwuhEZZVaSUstYZOSEddnfu2c8JedleloHGw6a0eWtfJfb5NUIN/KFt/Y5bAgOXiDx45wEW4634Q/FgRjVM/OIGjdrQpCSSpmTcwF8v8nn8yXyJm/JIYH2cTAfMhz/AC "Dart – Try It Online")
- -2 bytes : Changed the way the u offset is calculated to reduce the number of additions
- -2 bytes : Moved the check on the first pasdding to the width and not the character
- -6 bytes : Changed the Cow/Cat check
- -2 bytes : Got rid of variable assignments
- -2 bytes : Reduced then umber of parentesis on 2\*(s.length+1)
[Answer]
# [Ruby](https://www.ruby-lang.org/) `-nl`, 64 bytes
```
~/([ao]+)(.)/
x=$1.size
$_<<"s go M"+($2<?w??e*x+?o*x+?w:"oo"*x)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72kqDSpcnm0km5BjlLsgqWlJWm6Fjcd6vQ1ohPzY7U1NfQ09bkqbFUM9Yozq1K5VOJtbJSKFdLzFXyVtDVUjGzsy-3tU7UqtO3zQUS5lVJ-vpJWhSbEHKhxC7Y6J5ZwOSeCAJDOLwfi_PxyiCQA)
[Answer]
## Lua, 121 90 Bytes
**121 Bytes**
```
i=...r="M"o="o"s=i:len()-3if(i:find("w"))then r=r..o:rep(s*2)else r=r..("e"):rep(s)..o:rep(s).."w"end print(i.." go "..r)
```
**90 bytes**
```
i=....." go M"o="o"s=#i-7 print(i..(i:find"w"and o:rep(s*2)or("e"):rep(s)..o:rep(s).."w"))
```
Takes input such as 'Caats' or 'Coooows' case-sensitive. Since there are no requirements for invalid inputs, the output might be weird for, say, 'Foxes' or 'Oxen'. :P
**Ungolfed**
```
i=... .. " go M"
o="o"
s=#i-7
print(i..
         (i:find"w"and o:rep(s*2) or 
         ("e"):rep(s)..o:rep(s).."w")
      )
```
*Update to 90 Bytes:* Replaced if-control structure with logical operators, optimized string concatenation by appending more data in declaration of `i`. Removed parenthesis on `i:find("w")`. Interestingly enough, storing `"o"` to a variable saved a couple bytes when using `rep`, but would be counterproductive with `"w"` or `"e"`. The more you know.
[Answer]
# Lua: ~~115~~ ~~92~~ 89 Bytes
```
i=...l=#i-2o="o"io.write(i,"s go M",i:find"a"and("e"):rep(l)..o:rep(l).."w"or o:rep(l*2))
```
takes `C[]t` or `C[]w` as input; [] = a's or o's.
A lowecase input will translate to the result.
long version:
```
i=...   --"C[]t" or "C[]w"
l=#i-2  --length of input -2
o="o"   --shorten usage of "o"
io.write(i,"s go M",i:find"a"and("e"):rep(l)..o:rep(l).."w"or o:rep(l*2)) 
-- if it's a C"a"t concat "s go M" then repeat  --> Cats/Cows go M
-- "e" and then "o" l times and concat else     --> Cats go Meo
-- repeat "o" l*2 times and concat              --> Cows go Moo
-- concat "w" and output evrything              --> Cats go Meow
```
Example outputs:
```
Caaat --> Caaats go Meeeooow
Cat   --> Cats go Meow
Cow   --> Cows go Moo
```
Edit: changed `if` `then` `else` to `and` `or`. removed ALL the non string space's.
Also you cat try it here: [Execute Lua Online](http://goo.gl/QZDCh8) but I couldn't figure out how to use the terminal so I've put it in a function.
Edit: changed usage of "o" and removed () from `:find`. credit goes to **Cyv** for finding those optimizations. Added "s" and changed `l=#i-3` to `l=#i-2`
With input including "s" only 88 byte:
```
i=...l=#i-3o="o"io.write(i," go M",i:find"a"and("e"):rep(l)..o:rep(l).."w"or o:rep(l*2))
```
[Answer]
# PHP, ~~170~~ ~~164~~ ~~161~~ 157 bytes
```
preg_match("/(?i)c([ao]+)/",$argv[1],$e);
$n=strlen($e[1]);
$c=$e[1][0];
$a=($c=="a"?("ew"):("o"));
echo "M".str_repeat($a[0],$n).str_repeat("o",$n).$a[1]."\n";
```
Takes any capitalization whatsoever. `CaAaT`, `coOOOw`, whatever.
*v2: don't really need [wt]$. also corrected char ct*  
*v3: char ct was all wrong, condensed $a and $e assignment*  
*v4: save 3 bytes on $af->$a*  
*v5: save 4 bytes by onelining it (not shown)* 
]