generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Code Golf: Counting Vowels

Previous Thread :: Next Thread 
j_0sh is not online. j_0sh
Joined: 05 Mar 2015
Total Posts: 512
02 Mar 2016 04:12 PM
The goal of this code golf is to code a function/method that can count the number of vowels in any string supplied as an argument.

The rules:

Code must be as small as possible.
The code must run/compile with no errors.
You can use any language you like.

Let's have a fun game, then. Begin!
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
02 Mar 2016 04:24 PM
I'm sure you can shorten it but whatever:

function a(b)return b:gsub("[aeiou]","")end
Report Abuse
LegendaryAccount is not online. LegendaryAccount
Joined: 02 Jun 2010
Total Posts: 13193
02 Mar 2016 04:27 PM
function a(b)return b:gsub("[aeiou]","")end
print(a("AaEeIIo"))
--AEII 3

@cnt




Report Abuse
ray_revenge is not online. ray_revenge
Joined: 18 Feb 2011
Total Posts: 453
02 Mar 2016 04:34 PM
time to require a module


Report Abuse
darthpyro is not online. darthpyro
Joined: 18 Aug 2009
Total Posts: 3569
02 Mar 2016 04:36 PM
None of these segments actually count the number of vowels. ;P
Report Abuse
darthpyro is not online. darthpyro
Joined: 18 Aug 2009
Total Posts: 3569
02 Mar 2016 04:38 PM
Wait I forgot about the second gsub param. P;
Report Abuse
cheesecake123456 is not online. cheesecake123456
Joined: 01 Jun 2009
Total Posts: 1529
02 Mar 2016 04:44 PM
Well if you want just the number outputted:

function vowels(word)
local n = 0
for l in word:gmatch('[%daeiou]') do
n = n + 1
end
return n
end

print(vowels('The quick brown fox jumps over the lazy dog'))

--11


Report Abuse
ray_revenge is not online. ray_revenge
Joined: 18 Feb 2011
Total Posts: 453
02 Mar 2016 04:48 PM
a=require(27817)


Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
02 Mar 2016 04:52 PM
a

a in Kingkillerscript is a command that counts the number of vowels in the supplied string, given as a program argument.

You said I can use any language I like.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
02 Mar 2016 05:13 PM
[aeiouAEIOU] lelelyhllyltylkiotjitj
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
02 Mar 2016 05:34 PM
cntkillme's in moonscript

a=(b)->b\gsub "[aeiouAEIOU]",""


Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
02 Mar 2016 05:58 PM
a==>@gsub"[aeiou]"
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
02 Mar 2016 06:00 PM
a==>@gsub "[aeiouAEIOU]",""
Report Abuse
j_0sh is not online. j_0sh
Joined: 05 Mar 2015
Total Posts: 512
02 Mar 2016 09:51 PM
Bump
Report Abuse
j_0sh is not online. j_0sh
Joined: 05 Mar 2015
Total Posts: 512
03 Mar 2016 04:50 PM
Bump.
Report Abuse
Intrance is not online. Intrance
Joined: 04 Dec 2008
Total Posts: 208
03 Mar 2016 04:59 PM
import java.util.Scanner;

public class vowels
{
public static void main (String args[])
{
Scanner stdin = new Scanner(System.in);
String string1;
string1 = stdin.nextLine();
string1 = string1.toLowerCase();

}
public static int numberVowels(String string1)
{

int count = 0;
int vowels = 0;
int consonants = 0;
for (int i = 0; i < string1.length(); i++)
{
char ch = string1.charAt(i);
if (ch == 'a' || ch == 'e' || ch == 'i' ||
ch == 'o' || ch == 'u')
{
vowels++;
}
}
return vowels;
}
}
Report Abuse
Intrance is not online. Intrance
Joined: 04 Dec 2008
Total Posts: 208
03 Mar 2016 05:00 PM
fuq
Report Abuse
eLunate is not online. eLunate
Joined: 29 Jul 2014
Total Posts: 13268
03 Mar 2016 05:22 PM
You missed the point of a code golf.
Report Abuse
j_0sh is not online. j_0sh
Joined: 05 Mar 2015
Total Posts: 512
03 Mar 2016 05:24 PM
You missed the point of a code golf.[2]
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
03 Mar 2016 07:05 PM
Whoever uses Java in code golf automatically loses
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
03 Mar 2016 07:06 PM
^ [10]
Report Abuse
j_0sh is not online. j_0sh
Joined: 05 Mar 2015
Total Posts: 512
03 Mar 2016 07:12 PM
Yes, Java's design isn't good for code golf. Most OOP languages aren't, in any case. I'm not bashing Java, though. I had fun using it to make Minecraft mods.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image