YOU HAVE TEN SECONDS TO WRITE A FUNCTION IN YOUR FAVORITE PROGRAMMING LANGUAGE THAT COUNTS THE NUMBER OF WORDS IN A GIVEN STRING WITH TWO OR MORE EQUAL VOWELS
"TOO" => two 'O' => count++ "TO" => one 'O' => doesn't count "BIRDIE" => two 'I' => count++
int main() { char* str = "YOU HAVE TEN SECONDS TO WRITE A FUNCTION IN YOUR FAVORITE PROGRAMMING LANGUAGE THAT COUNTS THE NUMBER OF WORDS IN A GIVEN STRING WITH TWO OR MORE EQUAL VOWELS"; int vowels[] = {0, 0, 0, 0, 0}; int count = 0;
for(int n = 0; n = 2) { count++; break; } }
memset(vowels, 0, sizeof vowels); } }
printf("%d\n", count);
return EXIT_SUCCESS; }
Adam Johnson
you stupid retard, we aren't going to do your cs homework.
for (int i = 0; i < 100; i++) { if (i % 3 && i % 5) { printf("%d\n", i); continue; } if (!(i % 3)) printf("Fizz"); if (!(i % 5)) printf("Buzz"); putchar('\n'); }
Brayden King
BIRDMIN NO
Angel Flores
var vStr = "QUICK YOU HAVE TEN SECONDS TO WRITE A FUNCTION IN YOUR FAVORITE PROGRAMMING LANGUAGE THAT COUNTS THE NUMBER OF WORDS IN A GIVEN STRING WITH TWO OR MORE EQUAL VOWELS";
def g(s): wordCount = 0 words = [] vowels = "aeiouy" list_s = s.lower().split() for el in list_s: for v in vowels: if el.count(v) >= 2: wordCount += 1 words.append(el) break return (wordCount, words)
Lucas Green
would be silly to have a random chance of counting 'y' as a vowel
Sebastian Flores
He's probably a Turk.
Josiah Jenkins
>aeiou are the only vowels kys angloturd
Camden Carter
mr birb,
prepare to be fucked fucked and eaten in gloroius functional javascript on 60.
$Sentence = @("too to birdie four chan aaaa") -split ' ' foreach ($Word in $Sentence) { if ($Word -match '.*([aeiou]).*\1.*') { $Count++ } } Write-Output "Total: $Count out of $($Sentence.Count) words match the criteria."
Jack Allen
Are you fucking stupid he is just counting the number of regex matches
Julian Butler
if you are seriously unable to do this simple assignment you should just drop out already
>no unicode support as always, the C code found at Jow Forums is fucking shit
John Gray
why should you care about the chingdongs using your code
Oliver Campbell
>YOU HAVE TEN SECONDS TO WRITE A FUNCTION IN YOUR FAVORITE PROGRAMMING LANGUAGE Does bash count? I don't know anything else.
#!/bin/bash
counter=0
echo "Enter a sentence" read -a sentence
for word in "${sentence[@]}" do case "${word,,}" in *a*a* | *e*e* | *i*i* | *o*o* | *u*u* ) (( counter += 1 ));; esac done
echo "$counter word(s) match the criteria!"
Thomas Diaz
>unicode is only needed for asian languages i hope that's merely ignorance
Jaxon Jenkins
don't know the language, but this unicorn appears to be counting the number of regex matches. a regex is a like a general pattern for strings. this pattern is defined as \b\S*([aeiou])\S*\1\S*\b
\b is word boundary, so whenever you see a space next to a character, like " word" or "word ".
\S means any non-space character, the qualifier * means 0 or more. so \S* matches 0 or more non-space characters. it will try to match as many as possible
[aeiou] is a character range, it matches any character in the square brackets.
(...) tells it to remember what's in the parentheses, so it can be reused later.
\1 matches exactly what (...) matched in the specific string earlier. this is what makes sure to find two equal vowels.
so, \b...\b (with only non-space character ranges between them) matches a word, (...)...\1 matches equal vowels, \S* makes sure those vowels can be anywhere within that word.
Mason Hall
unicode's only needed for languages that dont matter like nintendo and vodka
Brayden Kelly
You know I usually love Erlang but what the hell is going on.
user, try to remember the basics of implicit typecasting.
Easton Jenkins
delicious python with no regex, emphasis on readability
from collections import Counter
def contains_multiple_equal_vowels(word): cnt = Counter() for letter in word: cnt[letter] +=1 counts = [cnt[a] for a in cnt.keys() if a in 'aeiou'] return any(value >= 2 for value in counts)
>implicit typecasting I generally consider that a curse word (especially when I mostly write TypeScript these days), though yeah, it does certainly come in handy for golfing purpose. Though you can work around it completely by just using a better regex.
Connor Gonzalez
Anata no sukina puroguramingu gengo no kinō de, 2tsu ijō no dōgigo o tsukatte atae rareta mojiretsu no naka ni kazuōku no tango o ireru
Noah Collins
def foo(thing): return len([x for x in thing.split(' ') if any([y for y in x if x.count(y) > 1])])
You faggots realize it can be any string i.e. a sentence, not just a single word, right?
Angel Turner
I will comment on your corrected function.
1. poorly named- what does foo do? it should be given a name that makes it obvious what it is doing
2. Bird says that the function takes in a word. What is x.split(' ') trying to accomplish?
3. why are you using x and y? again poor naming.
4. A rewrite of your function in a clean way:
def has_multiple_equal_vowels(word): return any(word.count(letter) > 1 for letter in 'aeiou')
and it ends up being a lot cleaner and more readable even than my previous function ()
Dylan Miller
It's supposed to take a string of multiple words dumbo
Tyler Sullivan
you are right, just re-read the OP ):
Jordan Bell
>YOU HAVE TEN SECONDS
uve been stabbered friendo
Kayden Cooper
final clean code python version:
def has_multiple_equal_vowels(word): word = word.lower() return any(word.count(letter) > 1 for letter in 'aeiou')
def count_words_with_multiple_equal_vowels(text): words = text.split(' ') return sum(has_multiple_equal_vowels(word) for word in words)
Thomas Ortiz
Set re = New RegExp With re .Pattern = "[^\s](a.*a)|(e.*e)|(i.*i)|(o.*o)|(u.*u)[^\s]" .IgnoreCase = True .Global = True End With WScript.Echo re.Execute(WScript.Arguments.Item(0)).Count
Robert Gray
case-insensitive: val s = "Oto to birdie four chan aaaa"
@ s split ' ' count {_ map {_.toLower} filter vs groupBy {v=>v} exists {_._2.size>=2}} res1: Int = 3
Aiden Parker
I dont know how to do the Jow Forums code text thing like OP
Noah Rivera
Better yet: @ s.toLowerCase split ' ' count {_ filter vs groupBy {v=>v} exists {_._2.size>=2}} res2: Int = 3
Xavier Walker
[ code ] [ / code ] without the spaces
Mason Anderson
thanks but gave up as if would have been a mess since I wanted to do all the checks concurrently
Justin Wood
>tfw 99% of people would have been stabbed already by this fucking bird
Adam Wilson
I can't tell the complexity of these hacker one line solutions
what I'm thinking: filter all the consonants, leaving only vowels O(n), operate over new string of size k sort the vowels O(k logk) check for consecutive repetitive vowels O(k)
Logan Ramirez
Stabby Bird is usually just to show you can do it, I was focusing on terseness rather than readability. Yours is better if it needs to be used by others though.
>extra line for print (why not just wrap that sum in a print) >not a function
You get stabbed by birb
Mason James
func(word): count=0 vowels=[a,i,o,u,e] for i in word: for j in vowles: if i==j: count+=1
if count >= 2: print(len(word))
Jordan Parker
fuck how do i white background thingy
Isaiah Bennett
Well the performance of these one liners is always horrible, especially the ones with ToLower() and similar.
Christian Murphy
benis
Ryan Gonzalez
"" and "[/code" without comments
Levi Allen
Lel shit
[ code ]
[ / code ]
Cooper Davis
print "hello world!"
Nathaniel Harris
sdfdsf
Joseph Cook
"fddsf"
Nolan Sullivan
lmfao
Elijah Gomez
func(word): count=0 vowels=[a,i,o,u,e] for i in word: for j in vowles: if i==j: count+=1
if count >= 2: print(len(word))
thjank
Logan Roberts
but tolower() is linear and you should only have to do it once at the start of the program.
Brody Hernandez
public class Poo {
public static void main(String[] args) { // TODO Auto-generated method stub System.out.println(pooInLoo("Hola a todos")); }
public static int pooInLoo(String s){ String[] a=s.split("\\s"); int cont=0; for(int i=0;i1) cont++; } return cont; }
}
the power of POO
Jayden Ortiz
oh shit it's suppsoed to count words func(string): wordcount=0 count=0 vowels=[a,i,o,u,e] for i in string: for j in vowles: if i==j: count+=1 if i == " ": if count >=2: wordcount +=1 count=0
print(wordcount)
Blake Murphy
func(string): wordcount=0 count=0 vowels=[a,i,o,u,e] for i in string: for j in vowles: if i==j: count+=1 if i == " ": if count >=2: wordcount +=1 count=0
print(wordcount) damn
Zachary Howard
i refuse to give up func(string): wordcount=0 count=0 vowels=[a,i,o,u,e] for i in string: for j in vowles: if i==j: count+=1 if i == " ": if count >=2: wordcount +=1 count=0