[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

QUICK WRITE A PROGRAM IN YOUR FAVORITE LANGUAGE THAT COUNTS

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 331
Thread images: 26

File: 1467318962646.jpg (29KB, 412x430px) Image search: [Google]
1467318962646.jpg
29KB, 412x430px
QUICK

WRITE A PROGRAM IN YOUR FAVORITE LANGUAGE THAT COUNTS ALL THE VOWELS FROM THE USER INPUT

OR THIS BIRD IS GONNA STAB YOU
>>
inb4 homework

It's not homework you mongoloids.
Last thread: >>55357763

#include <stdio.h>
#include <stdlib.h>

int isvowel(char c) {
switch(c) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
return 1;
default:
return 0;
}

return 0;
}

int main(int argc, char** argv) {
char c;
int vowels = 0;

while(1) {
c = getchar();
if(c == EOF) {
break;
}
vowels += isvowel(c);
}
printf("Vowels: %d\n", vowels);

return EXIT_SUCCESS;
}
>>
#include <stdio.h>
#include <stdlib.h>

int isvowel(char c) {
switch(c) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'A':
case 'E':
case 'I':
case 'O':
case 'U':
return 1;
default:
return 0;
}

return 0;
}

int main(int argc, char** argv) {
char c;
int vowels = 0;

while(1) {
c = getchar();
if(c == EOF) {
break;
}
vowels += isvowel(c);
}
printf("Vowels: %d\n", vowels);

return EXIT_SUCCESS;
}

//ok?
>>
vowels = ["a", "e", "i", "o", "u"]

user_input = input("Enter phrase: ")

result = 0

for i in list(user_input):
if i in vowels:
result += 1

print(result)
>>
>>55375709
fuck

vowels = ["a", "e", "i", "o", "u"]

user_input = input("Enter phrase: ")

user_input = user_input.lower()

result = 0

for i in list(user_input):
if i in vowels:
result += 1

print(result)
>>
>>55375654
>homework
>>
>>55375709
>>55375736
Doesn't work with Chinese.
>>
<?php
$vowels = array('a','e','i','o','u',A','E','I','O','U');
$user_input = $_POST['input'];
$result = 0;

for ($i = 0; $i < strlen($user_input); $i++) {
for($j = 0; $j < 10; $j++){
if($user_input[i] == $vowels[j])
$result+=1;
}
}
echo $result;
?>


:^)
>>
File: 1467471847306.jpg (23KB, 408x426px) Image search: [Google]
1467471847306.jpg
23KB, 408x426px
GET TO WORK YOU FUCKING PLEBS
>>
>>55375654
gets.scan(/aeiou/i).size

you big fgt OP
>>
Use regex to filter out all the non-vowels and then get the size of the string.
>>
 file=$1
v=0
if [ $# -ne 1 ]
then
echo "$0 fileName"
exit 1
fi
if [ ! -f $file ]
then
echo "$file not a file"
exit 2
fi
# read vowels
exec 3<&0
while read -n 1 c
do
l="$(echo $c | tr '[A-Z]' '[a-z]')"
[ "$l" == "a" -o "$l" == "e" -o "$l" == "i" -o "$l" == "o" -o "$l" == "u" ] && (( v++ )) || :
done < $file
echo "Vowels : $v"
echo "Characters : $(cat $file | wc -c)"
echo "Blank lines : $(grep -c '^$' $file)"
echo "Lines : $(cat $file|wc -l )"

>>
int countVowers(std::string str)
{
int count = 0;
std::string dict = "aeiou";
std::string::iterator str_it = str.begin();
std::string::iterator dict_it;
for (std::string::iterator str_it = str.begin(); str_it != str.end(); str_it++)
for (std::string::iterator dict_it = dict.begin(); dict_it != dict.end(); dict_it++)
if (*str_it == *dict_it)
count++;
return count;
}
>>
>>55376263
fix
int countVowers(std::string str)
{
int count = 0;
std::string dict = "aeiou";
for (std::string::iterator str_it = str.begin(); str_it != str.end(); str_it++)
for (std::string::iterator dict_it = dict.begin(); dict_it != dict.end(); dict_it++)
if (*str_it == *dict_it)
count++;
return count;
}
>>
>>55376273
do you enjoy typing std:: all the time?
>>
>>55376273
I forgot some lines
int countVowers(std::string str)
{
int count = 0;
std::string dict = "aeiou";
for (std::string::iterator str_it = str.begin(); str_it != str.end(); str_it++)
*str_it = tolower(*str_it);
for (std::string::iterator str_it = str.begin(); str_it != str.end(); str_it++)
for (std::string::iterator dict_it = dict.begin(); dict_it != dict.end(); dict_it++)
if (*str_it == *dict_it)
count++;
return count;
}
>>
>>55376321
yep
>>
>>55375654
t = 0
for c in input():
if c.lower() in 'aeiou':
t += 1
print(t)
>>
>>55376322
Hmm. I fixed it again
int countVowers(std::string str)
{
int count = 0;
std::string dict = "aeiou";
for (std::string::iterator str_it = str.begin(); str_it != str.end(); str_it++)
for (std::string::iterator dict_it = dict.begin(); dict_it != dict.end(); dict_it++)
if (tolower(*str_it) == *dict_it)
count++;
return count;
}
>>
>>55375663
Why not use toLower and decrease the switch cases?
>>
File: 1447264064114.png (14KB, 1372x326px) Image search: [Google]
1447264064114.png
14KB, 1372x326px
>>55375654
Am i cool yet senpai?
>>
>>55376344
print(len([c for c in input() if c in 'aeiouAEIOU']))
>>
gets.scan(/[aeiou]/).count
>>
>>55376594
Uppercase?
>>
>>55376606
Gets.downcase.scan(/[aeiou]/).size
>>
>coding in anything lower level than ruby or python and taking 5-15x the lines
I just can't anymore, Ruby is too good
>>
IFS='AEIOUaeiou'; read fag; for dick in $fag; do echo "aids"; done | wc | awk '{print $1}'


Did I do well? Complement me, please!
>>
local text = {}
amo = 0


print("Enter phrase: ")
local input = tostring(io.read())

input:gsub(".",function(c) table.insert(text,c) end)

for i = 1, #text do

if text[i] == string.char(97, 101, 105, 111, 117, 121) then
amo = amo + 1
end

end

print(table.concat(text).." contains "..amo.." vowel(s).")


I fucked this up. How?
>>
Download some examples.

py example.py
>>
>>55375654
#include <iostream>

using namespace std;

int main() {
string input;
cout << "Type in some string:" >> endl;
cin >> input;
int vowels;

for (int i=0;i<input.length;i++)
{
if (input[i]=='B' || input[i]=='C' || input[i]=='D' || input[i]=='F' || input[i]=='G' || input[i]=='H' || input[i]=='J' || input[i]=='K' || input[i]=='L' || input[i]=='M' || input[i]=='N' || input[i]=='P' || input[i]=='Q' || input[i]=='R' || input[i]=='S' || input[i]=='T' || input[i]=='V' || input[i]=='W' || input[i]=='X' || input[i]=='Y' || input[i]=='Z' || input[i]=='b' || input[i]=='c' || input[i]=='d' || input[i]=='f' || input[i]=='g' || input[i]=='h' || input[i]=='j' || input[i]=='k' || input[i]=='l' || input[i]=='m' || input[i]=='n' || input[i]=='p' || input[i]=='q' || input[i]=='r' || input[i]=='s' || input[i]=='t' || input[i]=='v' || input[i]=='w' || input[i]=='x' || input[i]=='y' || input[i]=='z')
{
// this is not a vowel
}
else
{
vowels = vowels + 1;
}

cout << "There are " << vowels << " vowels in this sentence";
}
}
>>
>>55376816
what the fuck
>>
>>55376811
>IFS='AEIOUaeiou'; read fag; for dick in d$fag; do echo "aids"; done | wc | awk '{print $1}'

Fixed an edge case: notice the d.
>>
>>55376497
Technically a bit longer runtime, but it doesn't really matter.
>>
Haven't actually tested but this should be right.

int main(int argc, char** argv[]) {
std::set<char> vowels = {'a', 'e', 'i', 'o', 'u'};

std::string input = std::string(argv[0]);

int count = 0;
for (char& c : input) {
if (vowels.count(c) > 0)
count++;
}

std::cout << "Vowels: " << count << "\n";

return 0;
}
>>
local count = 0

for vowel in (arg[1] or io.input():read()):gmatch("[aeiouAEIOU]") do
count = count + 1
end

print(count)


It reads from the command line or prompts the user if not available BEAT THAT
>>
npm install vowel-counter


I love JavaScript
>>
This is totally unchecked, I'm on my phone. Let's see how good my mental linter is.

import functools
res = input("enter a phrase.")
vowels = set(['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'])
print(functools.filter(lambda x: x in vowels, res.split("")).len())

Can somebody test this for me?
>>
>>55376869
What?
>>
>>55377066
fuck I used len wrong, shm thbq fma
>>
>>55376497
It'd be slower and consume more memory.
>>
vowels=0
for c in list(input()):
if c in 'aeiouAEIOU':
vowels += 1
print(vowels)
# pls no stabs bird
>>
print(len([x for x in input().lower() if x in 'aeiou']))

python wins again
>>
>>55375654
input.toCharList.foldLeft(0)( (acc, c ) => if vowels.contains(c) acc + 1 else acc )
>>
Console.WriteLine(Console.ReadLine().Count(chr => "aeiou".Contains(char.ToLowerInvariant(chr))));
>>
def stabbing_bird(input)
return input.downcase.count "aiueo"
end
stabbing_bird(gets.chomp)


Am I doing this right? Don't stab me please.
>>
Damn, code took longer than expected. It is mostly generating all vovel list though

++++++++++[->++++++>++++++>>+++++++>+++++++>>
+++++++>+++++++>>++++++++>++++++++>>++++++++>
++++++++>>++++++++++>++++++++++>>++++++++++>+
+++++++++>>++++++++++>++++++++++>>+++++++++++
>+++++++++++>>++++++++++++>++++++++++++<<<<<<
<<<<<<<<<<<<<<<<<<<<<<<]+>+++++>+++++>+>->->+
>+++>+++>+>->->+>+++++>+++++>+>--->--->+>+>+>
+>+++++>+++++>+>+>+>+>--->--->>,[[->+>+<<]+++
+++++++>>>>-<<<<[->[-<<[<<<]<->>>>[>>>]<<<<]>
[-<+>>+<]>[-<+>]<<<<[<<<]+<<<->>>[>>>]<<<<<]<
[<[[-]->+[->+]->+<<+[-<+]]<<]+>[[->+>+<<]>>-[
-<<+>>]+>]<->>[-]>[-]>>+>---------[[+]>+<]>>+
<<<<<<<,]>>>>>>[->-<]>>++++++++++<[->-[>+>>]>
[+[-<+>]>+>>]<<<<<]>>>[>++++++++[-<++++++>]<.
[-]]++++++++[-<++++++>]<.
>>
>>55377058
You forgot to --save. Now I cannot run your code.
>>
>>55376538
C# w/o LINQ is shit, you should learn it. >>55377519
>>
>>55377566
what the fuck is this?
>>
>>55377617
brainfuck
>>
>>55377566
holy shit it actually works
>>
>>55377659
of course it does
>>
>>55377566
Further optimized the code size

>->++++++++++[->++++++>>>+++++++>>>+++++++>>>
++++++++>>>++++++++>>>++++++++++>>>++++++++++
>>>++++++++++>>>+++++++++++>>>+++++++++++++[-
<+]->]<+>>+++++>>>->>>+++>>>->>>+++++>>>--->>
>+>>>+++++>>>+>>>---[[-<+<+>>]+<<<]+[>>>]<<<-
>,[[->+>+<<]++++++++++>>>>-<<<<[->[-<<[<<<]<-
>>>>[>>>]<<<<]>[-<+>>+<]>[-<+>]<<<<[<<<]+<<<-
>>>[>>>]<<<<<]<[<[[-]->+[->+]->+<<+[-<+]]<<]+
>[[->+>+<<]>>-[-<<+>>]+>]<->>[-]>[-]>>+>-----
----[[+]>+<]>>+<<<<<<<,]>>>>>>[->-<]>>+++++++
+++<[->-[>+>>]>[+[-<+>]>+>>]<<<<<]>>>[>++++++
++[-<++++++>]<.[-]]++++++++[-<++++++>]<.
>>
>>55375654
(defun vowel-p (char)
(memberp (char-downcase char) '(#\a #\e #\i #\o #\u)))
(defun count-vowels (string)
(length (remove-if-not #'vowel-p string)))
>>
>>55377782
>brainfuck is shorter than some examples itt
Good job /g/
>>
Yeah yeah, I know, it's PHP. Whatever. Also not positive if the regex is correct.

echo(strlen(preg_replace('/[^AEIOU]/gi', '', $input)));
>>
>>55375654
import java.util.Scanner;

public class oopIsAFaggot {
public static void main(String[] args) {
System.out.println("Enter 3 numbaz for I cap yo ass cuzz");
Scanner s = new Scanner(System.in);
Integer one = s.nextInt(), two = s.nextInt(), three = s.nextInt();
s.close();
System.out.println(one >= two && one >= three ? one : two >= one && two >= three ? two : three);
>>
>>55378721
Wrong thread bro.
>>
>>55378721
>oopIsAFaggot
>oop
>clarely not enough OOP project
>no faggot object
>no interface faggot
you fucked up
>>
>>55375654
opSucksCocks = function(inString){
vowels = c("a","e","i","o","u")
stringLength = nchar(inString)
vowelCount = 0
for (i in 1:stringLength){
testChar = substr(inString,i,i)
vowelCount = vowelCount + is.element(testChar,vowels)
}
return(vowelCount)
}
>>
>>55375654
alert(prompt("Enter some text").replace(/[^aeiou]/gi, "").length)
>>
>>55375654
Java (still a shit language):
import java.util.*;

class Shit {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("Enter word: ");
String input = s.nextLine().toLowerCase();
int count = 0;
for (int i=0; i<input.length(); i++) {
if ("aeiou".indexOf(input.charAt(i))>=0) {
count++;
}
}

System.out.println("Number of Vowels: "+count);
}
}
>>
>>55375709
vowels = list("aeiou")

user_input = raw_input("Enter phrase: ")

result = 0

for i in list(user_input):
if i in vowels:
result += 1

print(result)


>>55376344
> if c.lower() in 'aeiou':
Wouldn't "ae", "aei", etc. count as vowels?
>>
>>55379042
no
it reads every character, one by one
>>
>>55375654
not a single example with regex, this is why curry niggers are taking our jobs...
>>
Looking at some of the posts, I seriously hope you guys don't work on real software projects.
>>
var vowels = ['a','e','i','o','u'];
var phrase = "suck my diiiiick!";

var vowelcounter = function(phrase) {
if(phrase === "") {
return 0;
}
if(vowels.includes(phrase[0])) {
return 1 + vowelcounter(phrase.substring(1, phrase.length));
} else {
return 0 + vowelcounter(phrase.substring(1, phrase.length));
}
}

var benis = vowelcounter(phrase)
console.log(benis)


man, I miss haskell ;_;
>>
>>55379143
but bro i wrote my solution in c

that means i'm just like kernel developers and not a smelly pajeet who uses dumb languages like java
>>
Oh boy this thread again.
>>
>>55379244
read the op nerd
>>
DIM s$, vowels$, i%, c%

vowels$ = "AEIOUaeiou"

INPUT "Enter string: ", s$

FOR i% = 1 TO LEN(s$)
IF INSTR(vowels$, MID$(s$, i%, 1)) > 0 THEN
c% = c% + 1
END IF
NEXT i%

PRINT "vowel count: "; c%
>>
>>55379143
Just for you.
using System;
using System.Text.RegularExpressions;
using static System.Console;

public class Test
{
public static void Main()
{
WriteLine(Regex.Replace(ReadLine(),@"[^aeiou]","").Length);
}
}
>>
>>55375654
One liner
class Shit
{
public static void Main()
{
Console.WriteLine(Console.ReadLine().ToLower().Count(x=>x=='a'||x=='e'||x=='i'||x=='o'||x=='u'));
}
}
>>
>>55379352
Lil fix.
using System;
using System.Text.RegularExpressions;
using static System.Console;

public class Test
{
public static void Main()
{
WriteLine(Regex.Replace(ReadLine(),@"[^aeiou]","",RegexOptions.IgnoreCase).Length);
}
}
>>
>>55379143
>regex for simple count
This is why your program takes 20 seconds, when mine takes 20 nanoseconds.
>>
>>55376025
$_POST should be $_GET since you don't have the front end here.
>>
print(sum(1 for c in input() if c in ['a','e','i','o','u']))
>>
File: Stoppostingthesethreadsanytime.png (66KB, 1378x281px) Image search: [Google]
Stoppostingthesethreadsanytime.png
66KB, 1378x281px
>>55379244
>>55379257
Sorry I could care less.
>>
>>55379143
Regular expression doesn't make a difference:
import re#eeeeeeeeeeeeeeee
opIsShit = re.compile('[aeiou]')
shit_taste = input("Enter word: ").lower()
print("Number of Vowels:",len(opIsShit.findall(shit_taste)))
>>
>>55379490
>capital vowels aren't vowels
>>
kek, nice job getting /g/ to finish your highschool homework
>>
>>55379578
doh you got me! it can only count up to five vowels too!
>>
>>55376339
You may have one
>>
>>55376863
>vowels = vowels + 1

You're the worst type of person.
>>
>>55377782
I was wondering if someone would do it. Good job!
>>
>>55379427
mong
>>
>>55379490
dude u r so mad
>>
File: 1463537117616.png (952KB, 601x888px)
1463537117616.png
952KB, 601x888px
Nigga PLEASE
main = getLine >>= putStrLn . show . length . filter (`elem` "aeiouAEIOU")
>>
File: 1466195817796-fit.jpg (23KB, 429x375px) Image search: [Google]
1466195817796-fit.jpg
23KB, 429x375px
>Mfw reading these as I can only understand python
>>
var countVowels = function(str) {
return ( str.match(/[aeiou]/gi) || [] ).length;
}
>>
Really niggers ??
<file grep -io "[aeiou]"|wc -l
>>
>>55379490
m8 this is so slow
>>
>>55379885
Doesn't return value
>>55379873
Breaks if uppercase
>>55379795
Just deletes the values, doesnt return shit
>>55379490
A retard that can't inti his mother tounge's grammar
>>
>>55379885
>>55379932
>I can't run a bash screen

topkek m8
>>
>>55379490
>Cuck CUck CUCk KEKKKK CUkk XDD XDD KEK

>>>/pol/
>>
>>55379932
> I don't now what the "i" does in a regexp
>>
>>55379932
>>>55379885 (You)
>Doesn't return value
I'm sorry dear but you are stupid
>>
>>55376863
Dat if statement. I hope no one has to read your code.
>>
>>55379932
>Just deletes the values, doesnt return shit
Nigga it counts the vowels from user input and prints it back out.
countVowels :: String -> Int
countVowels = length . filter (`elem` "aeiouAEIOU") -- "returns shit"

main = getLine >>= putStrLn . countVowels
>>
This thread scares me.
You guys are terrible at coding
>>
File: obfu.png (17KB, 842x575px) Image search: [Google]
obfu.png
17KB, 842x575px
No Perl solution, I mean come on :
eval unpack u=>q{_=VAI;&4H/#XI>R1);$DQ;S`],#MF;W)E86-H*'-P;&ET+R\I>R1);$DQ;S`K*VEF*"];865I;W5=+VDI?7!R/:6YT(B1);$DQ;S!<;B)]}
>>
using System;

public class a {
static void Main() {
var inp = Console.ReadLine().ToCharArray();
char[] vo = { 'a', 'e', 'i', 'o', 'u' };
int c = 0;
for (int x = 0;x < inp.Length;x++) {
if (Array.Exists(vo, t => t == inp[x]))
c++;
}
Console.WriteLine(c);
}
}
>>
File: 1448142344323-0-b.jpg (13KB, 214x236px) Image search: [Google]
1448142344323-0-b.jpg
13KB, 214x236px
>>55379932
>Mfw I dont know how to code, I just replied to some posters saying random shit to get some (you)s

Im from /v/ :^)
>>
>>55380006
Then show us your solution, smartass.
>>
>>55380026
>I'm going to pretend that I did it on purpose so they won't laugh at me.
>>
>>55379932
https://jsfiddle.net/p6ev92ct/
>>
>>55380016
using System;

public class a {
static void Main() {
var inp = Console.ReadLine().ToLower().ToCharArray();
char[] vo = { 'a', 'e', 'i', 'o', 'u' };
int c = 0;
for (int x = 0;x < inp.Length;x++) {
if (Array.Exists(vo, t => t == inp[x]))
c++;
}
Console.WriteLine(c);
}
}
>>
>>55380026
Now that im chilled down, this was probably his intent, seeing how bad he failed three times. No way he was srs.

Ya'll niggas got memed
>>
>>55380006
It's satire.
>>
>>55380012

is this perl6 yet?
>>
>>55380041
mine is there : >>55379885

but nice 20 buggy lines of Java
>>
>>55375654
C++14:

#include <algorithm>
#include <cstring>
#include <string>

int count(const std::string &s)
{
return std::accumulate(begin(s), end(s), 0, [](auto i, auto c) { return i + (strchr("aeiouAEIOU", c) != nullptr); });
}

int main()
{
return count("This is a test");
}
>>
>>55380081
What did you expect? Java is a verbose shit language
>>
>>55380061
I want to believe in this but I doubt this is the case
>>
>>55375654
C++11
#include <iostream>
#include <algorithm>

int main(void)
{
std::string vowels = "aeiouAEIOU";

std::cout << "Enter text to count vowels: ";
std::string s;
std::getline(std::cin, s);

size_t vowel_count = 0;
std::for_each(s.begin(), s.end(), [&](char c) {
if(std::any_of(vowels.begin(), vowels.end(), [&](char z) {
return z == c;
})) {
vowel_count++;
}
});

std::cout << "There are " << vowel_count << " vowels." << std::endl;
}
>>
>>55380078
>is this perl6 yet?
Nope, this is Perl5. Perl6 doesn't have eval
>>
>>55380101
See:>>55379932

Does this look anything else but satire to you?
>>
tr '\n' ' ' | sed 's/[^aeoiu]\|\n//g' | wc -m
>>
File: fingerryanlt3.jpg (5KB, 159x240px) Image search: [Google]
fingerryanlt3.jpg
5KB, 159x240px
>>55380061
>>55380101
My solution wasn't satire.
>>
>>55380012
Clean version :
while (<>) {
$v=0;
foreach (split //) {
$v++ if (/[aeiou]/i);
}
print "$v\n";
}
>>
>>55380101
My guess is that there are lots of beginners who want to show off their skills, and a good part of them are satire or trolls
>>
>>55380060
Who are these semen demons?
>>
>>55380060
delete this
>>
>>55380081
Nice, now invert a binary tree with bash.
>>
def vowels(input):
count = 0
vowels = ['a', 'e', 'i', 'o', 'u']
for c in input.lower():
if c in vowels:
count++
return count
>>
File: 1450536304620-b.jpg (65KB, 651x807px) Image search: [Google]
1450536304620-b.jpg
65KB, 651x807px
>>55380187
Why senpai -_-
>>
>>55380198
But that wasn't the question
>>
writing C# one liners is my favorite programming thing to do

Console.WriteLine(Console.ReadLine().Where(ch => new[] { 'a', 'e', 'i', 'o', 'u' }.Contains(char.ToLower(ch))).Count());
>>
>>55380276
those girls look 15 my dude
>>
>>55380131
as far as I know, you can't ignore case with sed.
so you should go something like that :
A=$(cat input |tr -d '\n'| sed 's/[^aeiouAEIOU\n]//g'); echo ${#A}
>>
>>55380306
They are 13 and 14 :^]
>>
>>55380198
Doing it in Java is still a very bad idea.
Actually doing anything in java is a bad idea.
>>
>>55380060
Get b& for canned peans bitch
>>
behold

public class vowels {
public static void main (String args[]) {
if (args.length==0) {
System.out.println("no input, exiting");
return;
}
int num=0;
for (int i=0;i<args.length;i++) {
for (int k=0;k<args[i].length();k++) {
switch (args[i].charAt(k)) {
case 'a': num++;break;
case 'e': num++;break;
case 'i': num++;break;
case 'o': num++;break;
case 'u': num++;break;
default: break;
}}}
System.out.println(num);
}}
>>
>>55380310
I just forgot about case
this is enough, but the solution with grep up above is better imo
tr -d '\n'| sed 's/[^aeiouAEIOU]//g' | wc -m
>>
>>55380281

Then what the hell was your point? You need to write the solution in Bash in order to be a good coder?
>>
>>55380447
I had no point.
I just don't like java
>>
>>55380395
>not following java convention to upper case class names
>space between method name and (
>array brackets after variable name instead of type name
>repetitive num++ without fallthrough
>no upper case
>default: break what the FLYING FUCK MAN
>multiple closing curly braces
>operating on args and not stdin

what the fuck are you doing
no, WHAT THE FUCK ARE YOU DOING
>>
>>55380540
it's just java
it's not suppose to be good :^)
>>
File: LaurieF.jpg (225KB, 479x373px)
LaurieF.jpg
225KB, 479x373px
def count_vowels(word):
word = str(word)
vowels = ['a','e','i','o','u']
count = 0
for i in word:
if i in vowels:
count += 1
print("There are {} vowels in your fucking word".format(count))
print("bird pls no stab :^O")

foo = raw_input("What's your word, senpai?\n")
count_vowels(foo)


Fuck your minimalism
>>
>>55380604
>it wordfiltered senpai in my code

Kek
>>
>everyone forgetting sometimes y
>>
>>55380634
>>>/lit/
>>
>>55380634
>sometimes
nigga please, we're not building AI here, and we're not adding in every dictionary word to know when the sometimes will happen.

I know there are rules, but since when does English follow rules?
>>
>>55376263
C++ is pure unmitigated cancer, and this just proves it.
>>
>>55380783
if I remember correctly, it does 40% of the time. Only 40%…
>>
How do I get my code to appear in the fancy white box
>>
>>55380838
use
/*your code*/
>>
>>55380875
/*your code*/
>>
select regexp_count('number of vowels in a string','[aeiou]',1,'i') as cnt from dual;
>>
>>55380838
you can also go with :
"[" code "]"
your code
"[" /code "]"
>>
>>55376025
>using the smiley with a carat nose
>>
>>55380838
take a look at the end of the pinned post on this board, seems like the ones who tried to answer have some difficulties to make it clear~
>>
>>55377378
Nice, shorter than my suggestion :)

inputVal = input("Text: ").lower()
print("Number of vowels: {}".format(sum(inputVal.count(c) for c in 'aeiouy')))
>>
File: 1459711959579.jpg (31KB, 332x493px)
1459711959579.jpg
31KB, 332x493px
>>55380123
>iostream
why do people continue to do this for just outputting to console.
>>
>>55375654
Vowels = list('aeiouAEIOU')
text = input()
sucsessful_iterations = 0
for counter in list(text):
if counter in Vowels:
sucsessful_iterations+=1

print (str(sucsessful_iterations))
>>
File: amiralbum.jpg (193KB, 1200x1080px) Image search: [Google]
amiralbum.jpg
193KB, 1200x1080px
>>55380123
>})) {
>>
>>55380569
>using the smiley with a carat nose
>>
>>55380604
>using the smiley with a carat nose
>>
    class String
def vowel_count
i = 0
for x in self.split('') do
i += %w{a e i o u}.include?(x) ? 1 : 0
end
return i
end
end

puts (gets.chomp).vowel_count

>>
>>55381224
>>55381234

>HIVEMIND
>I
>V
>E
>M
>I
>N
>D

Install gentoo
>>
int vowelCount(String string) {
int vowels = 0;
for(int i = 0; i < string.length(); i++) {
if(string.charAt(i) == 'a') {
vowels = vowels + 1;
} else if(string.charAt(i) == 'e') {
vowels = vowels + 1;
} else if(string.charAt(i) == 'i') {
vowels = vowels + 1;;
} else if(string.charAt(i) == 'o') {
vowels = vowels + 1;
} else if(string.charAt(i) == 'u') {
vowels = vowels + 1;
} else if(string.charAt(i) == 'y') {
vowels = vowels + 1;
} else if(string.charAt(i) == 'A') {
vowels = vowels + 1;
} else if(string.charAt(i) == 'E') {
vowels = vowels + 1;
} else if(string.charAt(i) == 'I') {
vowels = vowels + 1;
} else if(string.charAt(i) == 'O') {
vowels = vowels + 1;
} else if(string.charAt(i) == 'U') {
vowels = vowels + 1;
} else if(string.charAt(i) == 'Y') {
vowels = vowels + 1;
}
}
return vowels;
}
>>
File: 1456686717945.jpg (233KB, 560x560px) Image search: [Google]
1456686717945.jpg
233KB, 560x560px
>>55381284
dog bless
>>
>>55381284
Code quality through the roof.
Can't you think of a way to remove code duplication?
>>
>>55376344
noice
>>
>>55381157
Because they haven't learned anything other than copy and pasting. The same goes for people who throw "String args[]" in java mains when they're not sending anything to the program.
>>
>>55381316
>The same goes for people who throw "String args[]" in java mains when they're not sending anything to the program
The Java specification requires public static void main(String[] args) as the entry point, even if you don't send anything to the program.

It won't run without it.
>>
>>55381157
>>55381316

std::out is defined in iostream m9
>>
vowels="aeiou"
x = input()
print(sum([1 if el in vowels else 0 for el in x]))
>>
len([x for x in raw_input('enter your fucking word: ') if x in 'AEIOUaeiou'])
>>
>>55381430
>>55381493
damn forgot for upperclas... guess i'm dead
>>
int vowels(String string) {
return string.length() - string.replace("a", "").replace("a", "").replace("e", "").replace("i", "").replace("o", "").replace("u", "").replace("y", "").replace("A", "").replace("E", "").replace("I", "").replace("O", "").replace("U", "").replace("Y", "").length();
}
>>
>>55380131
>>55380310
>>55380397
Step aside, niggers:
tr -cd 'aeiouAEIOU' | wc -c
>>
#include <stdio.h>

int cnt[128];
char *c, buff[60];

int main(void){
fgets(buff, sizeof(buff), stdin);
c = buff;
while (*c) cnt[*c++]++;
printf("%d\n", cnt['a']+cnt['e']+cnt['i']+cnt['o']+cnt['u']+cnt['A']+cnt['E']+cnt['I']+cnt['O']+cnt['U']);
}
>>
>>55381547
this is the best answer of the whole thread, alongside with >>55379902
>>
>>55381550
Have fun with UTF-8.
>>
>>55381199
I couldn't make it less ugly.
>>
>>55381550
>ghetto hashing
>>
tr -cd '[aeiou]' | wc -c
>>
import scala.io.StdIn.readLine

def isVowel(c : Char) {
c match {
case 'a' => true
case 'e' => true
case 'i' => true
case 'o' => true
case 'u' => true
}
}

readLine().toLowerCase.toArray.filter(isVowel(_)).length
>>
>>55381284
Y is not a vowel
>>
>>55379490
absolutely terrible
>>
#include <amxmodx>

public plugin_init()
{
register_plugin("Vowel Counter", "1.0", "Anonymous");
register_clcmd("say", "clcmd_say");
}

public clcmd_say(id)
{
new szText[256], iVowels;
read_args(szText, charsmax(szText));
for (new i; i < sizeof(szText); ++i) {
switch(szText[i]) {
case 'a','A','e','E','i','I','o','O','u','U':
++iVowels;
case 0:
break;
}
}
client_print(id, print_chat, "Your message contained %d vowels.", iVowels);
return PLUGIN_CONTINUE;
}
>>
Here, found this on StackExchange seems to work fine: https://play.golang.org/p/MFboCiikYW

Obviously not coding this shit myself and do what I do best: copying ideas from the stacks.
>>
>>55381547
Bash only, no external tools

read text
text="${text//[^aeiouAEIOU]/}"
echo "${#text}"
>>
user_input = input()
vowels = ['a','e','i','o','u']
counted_vowels = 0
for x in user_input:
counter = vowels.count(x)
counted_vowels += counter

please rate my code I spent like an hour on it
>>
>>55379244
Comic sans?
>>
"[" code "]"
testing....
hello world;
"[" /code "]"
>>

this better work;

>>
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class VowelCounter {

private static String vowelRegex = "[aeiouAEIOU]";
private static Pattern vowelPattern = Pattern.compile(vowelRegex);

public static int countVowels(String string) {
int counter = 0;
Matcher vowelMatcher = vowelPattern.matcher(string);
while(vowelMatcher.find()) {
counter++;
}
return counter;
}
}
>>
>>55384433
Should have made the data members final.
>>
>>55375663
#include <stdio.h>

int isvowel(char c)
{
// assume it's lowercase
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u')
return 1;
else
return 0;
}

main()
{
int vowels = 0;

char c;
while((c = getchar()) != EOF)
vowels += isvowel(c >= 'A' && c <= 'Z' ? c - 'A' + 'a' : c);

printf("# of vowels = %d\n", vowels);
}
>>
>>
I haven't written code in literally over a year, but this seems to work:

user_input = input("Enter your text: ")
lower_input = user_input.lower()
a_count = lower_input.count('a')
e_count = lower_input.count('e')
i_count = lower_input.count('i')
o_count = lower_input.count('o')
u_count = lower_input.count('u')
vowel_count = (a_count + e_count + i_count + o_count + u_count)
print (vowel_count)


I know that there's probably a much easier way to do this but IDK it works.
>>
>>55383881
0/10 you never printed anything.
>>
>>55382436
Bash seems pretty dope I should learn more of it.
>>
>>55381157
what to use then u faggt
>>
input <- readline("type something you asshat")
input <- tolower(strsplit(input,""))
print(sum(input %in% c("a","e","i","o","u"))
>>
>>55384816
The bird didn't say anything about printing
>>
>>55384963
woop, I fucked up. should be

input <- readline("type something you asshat")
input <- tolower(strsplit(input,"")[[1]])
print(sum(input %in% c("a","e","i","o","u"))


i forgot strsplit() returns a list
>>
>>55384993
and a trailing parenthesis on the last line. fuck me.
>>
>>55376863
Noice
>>
<!DOCTYPE html>
<script>
var a = 'input';
for (var i = 0; i < a.length; i++) {
if ((/^[aeiou]$/i).test(a.split('')[0])) {
document.getElementsByTagName('ul')[0].innerHTML += '<li>' + a.split('')[i] + '</li>'
}
}
</script>
<style>
ul li{
list-style-type: decimal;
}
ul li:not(ul li:last-child){
display: none;
}
</style>
<ul>

</ul>

fuck probably won't even work
>>
>>55375654
Easy shit
import java.util.Scanner;

public class Vowels {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("Enter a string of text.");
String userInput = scanner.nextLine();
scanner.close();

String newString = userInput.replaceAll("[AEIOUaeiou]", "");
int nbVowels = userInput.length() - newString.length();
System.out.println("Your string contains " + nbVowels + " vowels.");
}
}
>>
>>55385270
>languages every computer comes with an interpreter for
>can't be bothered to test it to see if it actually works
>>
>>55385379
forgot to add 'Sent from my iPad'
>>
perl as usual has a cool way to do it:
#!/usr/bin/perl

print <> =~ tr/[a|e|i|o|u]//;
>>
>>55385400
explanation
<> reads from some handle, this gets user input because the default is stdin
=~ runs a regex on that
tr/// is a transliteration, or replacement, regex
this whole expression returns the number of replacements made, which is printed
>>
>>55375663
what is the point of a thread if the most reasonable answer is at the top?
>>
>>55385400
very nice!
>>
>>55379795
The only correct answer
>>
>>55380810
#include <string>

using std::string;

int countVowels(string input) {
int count = 0;
string dict = "aeiouAEIOU";

for (auto itr = input.begin(); itr != input.end(); itr++)
for (auto dict_itr = dict.begin(); dict_itr != dict.end(); dict_itr++)
if (*itr == *dict_itr)
count++;
return count;
}


Defaggoted it.
>>
>>55385674
although this really isn't the way I'd do it.

>>55376249
fucking hell bash is awful.
>>
>>55375654
import sys
print sum (sum (letter.lower () in "aeiou" for letter in line) for line in sys.stdin)
>>
>>55375654
function countVowels(in) {
const vowels = "aeiouAEIOU";
let count = 0;
for(let i = 0; i < in.length; ++i) {
if (vowels.includes(in[i]))
count++;
}
return count;
}
>>
>>55379490
>doesn't count multiple instances of the same vowel
>>
>>55385704
Bash isn't that bad. Here's the right way to do it:
#! /bin/bash
tr -cd 'aeiouAEIOU' | wc -m

That poster was just a retard.
>>
>>55375654
#include <stdio.h>
int to_lower(int a) {
if (a >= 65 && a <= 90) a+= 32;
return a;
}
int main() {
char c=0;
int vowels=0;
printf("Type a line of text, hit enter: ");
while (c != '\n' && c != EOF) {
c = getchar();
c = to_lower(c);
if (c == 'a' || c == 'i' || c == 'u' || c== 'e' || c == 'o') {
vowels++;
}
}
printf("There were %d vowels in that line.\n", vowels);
}


gonna stab you if you fucking keep this shit up, bird
>>
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main (int argc, const char *argv[])
{
int i = 0, c;

while ((c = tolower (getchar ())) != EOF)
i += strchr ("aeio", c) != NULL;

printf ("%d\n", i);

return 0;
}
>>
>>55377543
Nice name. This looks like Python, except I don't know what end does
>>
>>55375663
If you clear the fifth bit on the char, you can reduce the cases needed.
>>
>>55375654
There's a site called Rosetta code or something which shows a single algorithm in a ton of languages
>>
>>55385903
Fantastic, I'm going to remember that one.
>>
>>55385746
this is absurdly inefficient.
>>
>>55375654
package main

import "fmt"

func main() {
vowels := map[rune]struct{}{
'a': struct{}{},
'e': struct{}{},
'i': struct{}{},
'o': struct{}{},
'u': struct{}{},
'A': struct{}{},
'E': struct{}{},
'I': struct{}{},
'O': struct{}{},
'U': struct{}{},
}
cnt := 0
var s string
fmt.Println("ENTER SOME TEXT:")
for {
_, err := fmt.Scanf("%s", &s)
if err != nil {
if err.Error() != "unexpected newline" {
fmt.Println("ERROR:", err)
}
break
} else {
for _, r := range s {
if _, isVowel := vowels[r]; isVowel {
cnt++
}
}
}
}
fmt.Println("NUMBER OF VOWELS:", cnt)
}
>>
did this in c64 basic for shits and giggles
10 rem you might want to do a poke 53272,23
25 print "Type a line of text."
27 print "I'll count the vowels."
30 input i$
35 n=0
40 v=0
100 if n >= len(i$) then goto 200
110 k$=mid$(i$,n+1,1)
115 if k$="A" then v=v+1
120 if k$="E" then v=v+1
125 if k$="I" then v=v+1
130 if k$="O" then v=v+1
135 if k$="U" then v=v+1
140 if k$="a" then v=v+1
145 if k$="e" then v=v+1
150 if k$="i" then v=v+1
155 if k$="o" then v=v+1
160 if k$="u" then v=v+1
162 n=n+1
165 goto 100
200 print "There are ";
205 print v;
210 print " vowels."
>>
Wow, I didn't realise that /g/ only wrote bloated, shit code.

Here's a solution in Pyth.

FNrz0I}N"aeiou"=Z+Z1;Z
>>
import System.IO

main = do
line <- getLine
let numVowels = countVowels line
print numVowels

countVowels :: String -> Int
countVowels "" = 0
countVowels (x:xs)
| any (== x) vowel = 1 + countVowels xs
| otherwise = countVowels xs
where vowel = ['a','e','i','o','u','A','E','I','O','U']
>>
File: as a developer.png (8KB, 563x76px)
as a developer.png
8KB, 563x76px
>everyone in this thread just checking for aeiou
>never heard of gypsy or cwm
You'll have to use linguistic libraries to detect vowels, not regexes. Sorry. Stabbings all around.
>>
>>55387403
Who fucking said my favorite language is english? Normal [human] languages do not have this problem.
>>
>>55379458
doesn't work on upper case
>>
>>55387437
Sure, but how many people itt hold a favorite language for which checking aeiou does work? Probably very few.
>>
Cool it guys, VBA's got this:

function countChars(userString as string)

dim noChars as integer

for x = 1 to len(userString)
select case asc(mid(userString, x, 1)
case 65, 69, 73, 79, 85
noChars = noChars + 1
case 89
if rnd > .5 then noChars = noChars + 1
end select
next x

countChars = noChars
end function
>>
i can write in french, spanish, english, turkish, etc...
>>
>>55387867
so? all of them use latin
you could've named some pooinloo language
>>
my brain stopped
>>
>>55387800
Oops, forgot to change the case of the string!
>>
>>55385809
>only one lib
nice
>>
File: isabelle.png (213KB, 581x784px)
isabelle.png
213KB, 581x784px
>>55385746
function countVowels(str) {
return str.match(/[aeiou]/gi).length;
}

you can do better.
>>
>>55385903
What?
>>
>>55379795
nigga that's some long code

main = interact (show . length . filter ( `elem` "aouieAOUIE"))
>>
>>55385839
u is not a vowel?
>>
>>55375654
>it's another "quick /g/, do my homework" thread
>people actually replying
jesus fuck, why are you so retarded?
>>
var input = prompt();
var i = input.length, c = 0;
var vowels = ['a', 'e', 'i', 'o', 'u'];
while (i--) {
if (vowels.indexOf(input[i]) > -1)
c++;
}
console.log(c);
>>
>>55375654
function vowels = vowels(s)
vowels = 0;
v = 'aeiou';
s = lower(s);
for n = 1:length(v)
vowels = vowels + length(strfind(s,v(n)));
end
>>
>>55381284
>Y

JOSE
>>
>>55384993
Still doesn't work, even when trailing parenthesis is added.

Detects 0 vowels.

Stabbing time, data plebber
>>
File: okperl.png (3KB, 468x42px) Image search: [Google]
okperl.png
3KB, 468x42px
>>55380012
This solution gave me cancer, beautiful cancer.
Mind explaining it?
>>
>search unicode / utf
>1 result
And you guys wonder why 90% of all software is shit.
>>
>>55375654
Input is left as an exercise for the reader (because JS is not normally used for CLI tools):

let input = "farters";
let num_vowels = input.split("").filter(c => "aeiou".indexOf(c.toLowerCase()) != -1).length;
>>
>>55388403
Uppercase A is 01000001. Lowercase a is 01100001. Uppercase and lowercase letters in ASCII only differ on the fifth bit. So you could clear the fifth bit before the switch and only use five cases instead of 10.
>>
>>55390400
so
vowels += isvowel(c | 0x20);
>>
>>55379425
This
>>
The only readable and understandable languages used in this thread are C and Java
>>
>>55390659
How's your first year of CS going?
>>
should have used jquery, it has a plugin called jmath that can count a number of vowels.
>>
/*
+/ (str←⍞) ∊ 'aeiouAEIOU'
*/
i think this works?
>>
>>55390773
        +/ (str←⍞) ∊ 'aeiouAEIOU'

fixed tags
>>
>>55375654

str = input("")
i = 0
for char in str :
if char in 'aeiouyAEIOUY' :
i = i+1
print(i)
input()

>>
(input) => (input.match(/[aeiou]/ig) || []).length


Ezpz
>>
>>55375654
sed 's/[^aeiouAEIOU]//g' | wc -c
>>
>>55375654
main = print . length . filter (`elem` "aeiouAEIOU") =<< getContents


haslel
>>
len(filter(lambda x: x in 'aeiouAEIOU',raw_input()))
>>
>>55391509
sed 's/[^aeiou]//ig' | wc -c
>>
>People are unironically using toLower instead of checking for A, E, I, O and U
>>
>>55390236
It's a simple Perl code like in >>55380150 encoded in UUencode.Then, it's unpacking it as a string, then you call eval on it.
>>
>>55380012
I up you with this

$(echo "I<RA('1E<W3t`p&r()(pwND&r{,3Rl7Ig}&r{,T31wo});r`26<F]F;==" | uudecode)
>>
>>55375654
main = do
input <- getLine
print . length . filter (\x -> toLower x `elem` "aeiou") $ input
>>
>>55376025
<?php
$userinput=str_split("kek a b c d e f g");
$vowels=array("a","e","i","o","u");
foreach ($userinput as $letter){if (in_array($letter,$vowels)){$vowelcount++;}}
echo $vowelcount;
?>
>>
>>55391734
well input should be handled with $_GET and strtolower() around it, to make it easier.
>>
>>55377566
/thread

I didn't know anybody actually knew how to brainfuck.
>>
class Character
{
constructor(char, vowels)
{
this._char = char;
this._vowels = vowels;
}

get char()
{
return this._char;
}

set char(value)
{
this._char = value;
}

get vowel_count()
{
return this._vowels.length;
}

get vowels()
{
return this._vowels;
}

set vowels(value)
{
this._vowels = value;
}

get is_vowel()
{
for (var i = 0; i < this.vowels.length; i++)
{
if (this.char == this.vowels[i])
{
return true;
}
}

return false;
}
}

class String
{
constructor(str)
{
this._str = str;
}

get str()
{
return this._str;
}

set str(value)
{
this._str = value;
}

vowel_count(vowels)
{
var count = 0;

for (var i = 0; i < this.str.length; i++)
{
var char = new Character(this.str[i], vowels);

if (char.is_vowel)
{
count++;
}
}

return count;
}
}

function update_count()
{
var str = new String(document.getElementById("text_input").value);
document.getElementById("output").innerHTML = str.vowel_count(_VOWELS);
}

function main()
{
_VOWELS = "aeiou";
document.body.innerHTML = "<input type='text' style='padding: 0.2em;' placeholder='input' id='text_input'> <input type='button' style='padding: 0.2em;' value='submit' onclick='update_count()'> vowels: <span id='output' style='color: #ff0000;'>0</span>";
}

main();
>>
(defn vowel? [ch]
(if (contains? #{\a \e \i \o \u} ch) true false))

(println "Vowels:" (count (filter vowel? (read-line))))


Haven't worked with characters much in Clojure.
>>
>>55392479
Shorter version:

(println "Vowels:" (count (filter #(contains? #{\a \e \i \o \u} %) (read-line))))
>>
>>55375654

answer = len(input())
print(";^)" + str(answer))
>>
>>55376594
Which language is that?
>>
>>55392386
You forgot all the factories and visitors and abstract classes.
>>
>>55392479
>>55392492
Forgot to lowercase.

(println "Vowels:" (count (filter #(contains? #{\a \e \i \o \u} %) (clojure.string/lower-case (read-line)))))
>>
>>55392616
You think JavaScript has those?
>>
>>55386868
Calling myself as having the most succinct solution so far at 22 characters.
>>
>>55375654
let vowels = "aeiou";
function countVowels(str) {
return str.toLowerCase()
.split("")
.filter(l => vowels.indexOf(l) != -1)
.length;
}


How'd I do?
>>
I only did this on my phone so I'm not even sure if it runs, but here is my version in Java lol

Scanner sc = new Scanner(System.in);
System.out.println("Enter a string:");
String input = sc.nextLine();

System.out.println("Number of vowels in your inputted string: " + countVowel(input));

public int countVowel(String input) {
int vowelCount = 0;
String[] vowels = {"a", "e", "i", "o", "u"};

for(int i = 0; i < vowels.length; i++) {
if(input.contains(vowels[i])){
vowelCount++;
}

return vowelCount++;
}
>>
>>55392841
Oops I forgot to take out the "++" in the return
>>
>>55375736
You can do

for i in user_input:

As long as it's a string
>>
>>55390400
Huh, never realized you could easily do toLower like that without actually using toLower.
>>
Private Function CountVowels(Byval input String) as Integer

initialLength = Len(input)
for each vowel in Split("a,e,y,u,i,o", ",")
input = Replace(input, vowel, "")
next vowel

CountVowels = intialLength - Len(input)

End Sub


25 seconds
>>
D:

import std.stdio,
std.algorithm,
std.array,
std.string;

void main() {
auto numVowels = stdin.readln()
.toLower()
.filter!(c => ['a', 'e', 'i', 'o', 'u'].canFind(c))
.array()
.length;
writeln("Vowels: ", numVowels);
}
>>
#!/usr/bin/env python

def fn(usr_str):
VOWELS = ["a", "e", "i", "o", "u"]
count = 0
for letter in usr_str:
if letter in VOWELS:
count += 1
return count

while True:
print(fn(input("Enter a string: ")))
>>
File: 1464783841467.png (584KB, 836x678px) Image search: [Google]
1464783841467.png
584KB, 836x678px
>>55375654
const countVowels = (str) =>
str.split('')
.filter((c) => /[aeiou]/i.test(c))
.length



What are you retards actually doing
>>
>>55375654
Some shitty code in Emacs lisp
(let ((counter 0))
(dolist (letter (string-to-list (downcase (read-string "text: "))))
(when (or (= ?o letter)
(= ?a letter)
(= ?e letter)
(= ?i letter)
(= ?u letter))
(setq counter (1+ counter))))
counter)
>>
Complete pleb here. What do wrong?
var button = document.getElementById("button");
var vowels = ['a', 'e', 'i', 'o', 'u'];

button.addEventListener("click", filterVowels);

function checkVowels(vowel){
return vowel === vowels;
}

function filterVowels(){
var sentence = prompt("Please enter your sentence");
var newSentence = sentence.split();
document.getElementById("v").innerHTML = newSentence.filter(checkVowels);
}
>>
File: boss.jpg (5KB, 211x239px) Image search: [Google]
boss.jpg
5KB, 211x239px
None of you niggers took into account the exception where 'Y' can be a vowel.
Fired
>>
>>55385894
Nope, that's Ruby. gets.chomp = user console input.
>>
>>55393901
That's why we define the vowels we are checking for as a variable/array/whatever. We can change it to match the wanted locale.
>>
>>55393965
>input
The yellow fly sang a rhythm.
>>
>>55393670
Your omitted separator parameter of String.split makes the function return an array of only the string it was given. You are comparing user input to your vowels array, which always returns false.
>>
File: e4bb99247ce16dc6e9ae15b5.png (554KB, 636x634px) Image search: [Google]
e4bb99247ce16dc6e9ae15b5.png
554KB, 636x634px
>>55375654

import sys

try:
count = len(''.join(i for i in sys.argv[1] if i in 'aeiou'))
except IndexError:
print 'The OP is a faggot'
else:
print 'Your input contains %i vowel%s' % (count, ('' if count == 1 else 's'))
>>
>>55393999
How would I split it into individual letters?
>>
>>55394016
https://developer.mozilla.org/en->US/docs/Web/JavaScript/Reference/Global_Objects/String/split
String.split("");

But
"a" === ["a", "b"]
returns false, so your program will still not work. You need to do the comparison differently. For loop and indexes would work.
>>
>>55375654
using System;
using System.Linq;
using static System.Console;

public class Test
{
public static void Main()
{
WriteLine(ReadLine().ToLower().Count(i=>"aeiou".Contains(i)));
}
}
>>
>>55394016
>>55394053 (me)

I would do this:
function filterVowels()
{
var amount = 0;
var vowels = "aeiou";
var input = prompt("Enter a sentence:");

for (var i = 0; i < input.length; i++)
{
for (var j = 0; j < vowels.length; j++)
{
if (input[i].toLowerCase() == vowels[j].toLowerCase())
{
amount++;
}
}
}

alert("Input contained " + amount + " vowels.");
}
>>
needs unnecessary use of pointers for completeness
>>
>>55394201
And a neural network
>>
>>55392841
this doesn't count duplicate vowels - i.e. 'alan' will only return 1
>>
string = input("Input: ") 
vowels = ["a", "i", "e", "o", "u"]
count = 0
for letter in string:
if letter in vowels:
count += 1
print (count)


kind of easy even though I self-identify as a programming babby
going to try one that gives separate counts for each vowel
>>
>>55394053
>>55394194
That's an interesting approach.. thanks anon. Much appreciated.
>>
>>55375663
Ignoring the fact that getchar(3) returns int, it's ok
>>
Everything but Python is such unelegant shit.
>>
>>55394370
f o r c e d i n d e n t a t i o n i s r a p e
>>
>>55394432
>not indenting your code
die
>>
(comp
count
(partial filter #{\a \e \i \o \u})
clojure.string/lower-case)
>>
>>55394341
>going to try one that gives separate counts for each vowel
Seemed like fun, so heres a haskell:
import Data.Char (toLower)

numberOfElems :: Char -> String -> Int
numberOfElems c = length . filter (c ==)

countVowels :: String -> String
countVowels str = show $ zip (vowels) (map elemcounter vowels)
where
vowels = "aouie"
elemcounter = flip numberOfElems lowerStr
lowerStr = map toLower str

main = interact countVowels


Type declarations should be unnecessary, as usual.
>>
>>55394486
>not having sex
>die
>>
>>55390331
Cleaner one using .includes()

var input = "some input, I dunno";
input.toLowerCase().split("").filter(c => "aeiou".includes(c)).length;
>>
print(len([x for x in input() if x in 'aeiouAEIOU']))
>>
>>55376863
You have some serious errors:
This will fail to compile, you want i < input.length(), as length() and size() are methods. Also, you need to initialize vowels to 0 (not sure if this will give compilation failure, runtime failure, or just wrong output). I think you may also need to #include <string>.

These aren't errors, but you should use a switch statement instead of that huge if-else, and it's prettier to use the ++ operator instead of vowels = vowels + 1.
>>
>>55376162
this doesn't work for me
>> gets.scan(/aeiou/i).size
hello world
=> 0
>> gets.count('AEIOUaeiou')
hello world
=> 3
>>
>>55376971
You want either 'char ** argv' or 'char * argv[] ', and you want input to be based off argv[1], as argv[0] is (usually) the program name.
>>
>>55380395
>}}}
>that epic fuckup of a switch statement
Hello Pajeet my old friend
>>
>>55380569
Yeah but it should at least not be shit
>>
>>55380810
There are languages people complain about and there are languages no one uses
>>
>>55381284
>what's a switch statement
>>
>>55394194
This doesn't work
>>
>>55384716
>no return type for main
>"assume it's lowercase"
>no switch statement
>dat input read and pointless ternary

2/10
>>
>>55392841
>>55394317
This tbqhfam
>>
Currynigger code coming thru
>public int numberOfVowels(String input){
> int numOfVowels = 0;
> String vowels = "aeiou";
> for (char letter: input.toCharArray()){
> if (vowels.contains(String.valueOf(Character.toLowerCase(letter)))) {
> numOfVowels += 1;
> }
> }
> return numOfVowels;
>}
>>
readLine.count("AEIOUaeiou".contains(_))
>>
>>55395091
I'm dumb
public int numberOfVowels(String input){
int numOfVowels = 0;
String vowels = "aeiou";
for (char letter: input.toCharArray()){
if (vowels.contains(String.valueOf(Character.toLowerCase(letter)))) {
numOfVowels += 1;
}
}
return numOfVowels;
}
>>
Pipeline Clojure version:

(->> (read-line)
(clojure.string/lower-case)
(filter #(contains? #{\a \e \i \o \u} %))
(count)
(println "Vowels:"))
>>
File: fuckyou.png (6KB, 456x185px) Image search: [Google]
fuckyou.png
6KB, 456x185px
>>55390006
>Stabbing time, data plebber
bullshit.
>>
len([x for x in input('') if re.match(x, '[aeiouAEIOU]'])
Thread posts: 331
Thread images: 26


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.