Javascript/JScript 147(152-5), 158(163-5) or 184(189-5) bytes:
Here is my Javascript and JScript horribly "ungolfyfied" version (164 152 152-5=147 bytes):
function(s,k,z,x,i,c,r){c='aeiouy'.split('');r=[];for(k in s=(s+'').split(/\b/)){i=0;for(z in c)i+=s[k].indexOf(c[z])>=0;i==6&&(r[r.length]=s[k]);}return r;}
function(s,k,z,x,i,c,r){c='aeiouy'.split('');r=[];for(k in s=(s+'').split(/\b/)){i=6;for(z in c)i-=!!s[k].search(c[z]);i&&(r[r.length]=s[k]);}return r;}
Thank you @GaurangTandon for the search()
function, which saved me a byte!
RegExp based with HORRIBLE performance, but support both upper and lowercase (163-5=158 bytes):
function(s,k,z,x,i,c,r){c='aeiouy'.split('');r=[];for(k in s=(s+'').split(/\b/)){i=0;for(z in c)i+=RegExp(c[z],'i').test(s[k]);i==6&&(r[r.length]=s[k]);}return r;}
RegExp based with BETTER performance, BUT takes a lot more bytes (189-5=184 bytes):
function(s,k,z,x,i,c,r,l){l=[];r=[];for(z in c='aeiouy'.split(''))l[z]=RegExp(c[z],'i');for(k in s=(s+'').split(/\b/)){i=0;for(z in c)i+=l[z].test(s[k]);i==6&&(r[r.length]=s[k]);}return r;}
This one if just for the fun (175-5 bytes) and won't count as an answer:
function(s,k,z,x,i,c,r){c='aeiouy'.split('');r=[];for(k in s=(s+'').split(/\b/)){i=0;for(z in c)i+=s[k].indexOf(c[z])>=0;i==6&&(r[r[r.length]=s[k]]=1+(r[s[k]]||0));}return r;}
It's based on the 1st answer, but has a 'twist': You can know how many times a word has been found.
You simply do like this:
var b=(function(s,k,z,x,i,c,r){c='aeiouy'.split('');r=[];for(k in s=(s+'').split(/\b/)){i=0;for(z in c)i+=s[k].indexOf(c[z])>=0;i==6&&(r[r[r.length]=s[k]]=1+(r[s[k]]||0));}return r;})('youaie youaie youaie youaie a word');
b.youaie //should be 4
Since that length
doesn't have all vowels, it wont be deleted and still would be an answer for the bonus.
How do you call it?
"Simple": You wrap the function inside ()
and then add ('string goes here');
to the end.
Like this:
(function(s,k,z,x,i,c,r){c='aeiouy'.split('');r=[];for(k in s=(s+'').split(/\b/)){i=0;for(z in c)i+=s[k].indexOf(c[z])>=0;i==6&&(r[r.length]=s[k]);}return r;})('a sentence youyoy iyiuyoui yoiuae oiue oiuea');
This example will return an array only with 1 string: yoiuae
I know that this is the worst solution, but works!
Why am i counting -5?
Well, Javascript/JScript arrays have a property (length
) in arrays which tells the number of elements that it have.
After being confirmed in the question, the bonus of -5 is for telling the number of words.
Since the number of words is in that property, automatically I have the score of -5.