14
\$\begingroup\$

The challenge is to remove vowels (a, e, i, o, u) from string from STDIN (yes, I know, simple). You can expect that your program will be not ran with any arguments in argv.

Example:

This program will remove VOWELS.
So we can now speak without them.

Is changed to:

Ths prgrm wll rmv VWLS.
S w cn nw spk wtht thm.

There is a catch. The winning entry is decided basing on number of different bytes. For example a ab has three different bytes (a, b and space). If two or more entries will have this same ammount of different bytes, then fallback is done on number of bytes for those entries.

\$\endgroup\$
7
  • 11
    \$\begingroup\$ A job for Whitespace language \$\endgroup\$
    – jfs
    May 28, 2012 at 20:24
  • 1
    \$\begingroup\$ What about input like Renée’s naïveté? Stripped of vowels, that should of course be Rn’s nvt as output. Seem like these approaches are all pretty ahem naïve if you ask me. :) \$\endgroup\$
    – tchrist
    May 28, 2012 at 20:25
  • 1
    \$\begingroup\$ If you remove é, you might want to remove y too. \$\endgroup\$ May 28, 2012 at 22:23
  • 6
    \$\begingroup\$ @tchrist, read the question. Says to remove a,e,i,o,u. You're off topic, please drop it. \$\endgroup\$
    – boothby
    May 29, 2012 at 2:40
  • 1
    \$\begingroup\$ @tchrist: Especially the challenge didn't say "all vowels" and enumerated what we should consider as removable. \$\endgroup\$ May 29, 2012 at 12:17

38 Answers 38

1
2
0
\$\begingroup\$

F# 105 121 91 characters

Console.ReadLine()|>Seq.filter(fun c->not("aeiouAEIOU".Contains(c)))|>Seq.iter(printf"%c")
\$\endgroup\$
1
  • \$\begingroup\$ Hmmm... I just noticed that this code will work in Linqpad but not in Visual Studio. And since I don't feel like down voting my own contribution, I will leave it here with this comment until I figure out what's wrong with it. \$\endgroup\$ May 29, 2012 at 6:37
0
\$\begingroup\$

Excel Formula - 19 distinct bytes (196 total)

=,S,B,T,(,),,,",a,e,i,o,u,A,E,I,O,U,1

Cell A1: <Value>
Cell B1: =SUBSTITUTE(SUBSTITUTE(A1,"a",""),"e","")
Cell C1: =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B1,"i",""),"o",""),"u",""),"A",""),"E",""),"I",""),"O",""),"U","")

*This actually is too many nested functions to work in Excel 2003, but the concept is there.

Splitting the formulas into two cells achieved the desired effect. -- Result is in C1.

\$\endgroup\$
0
\$\begingroup\$

Noether, 16 individual bytes (17 total)

I"[aeiouAEIOU]"-P

Try it online!

Uses the regex

[aeiouAEIOU]

to remove the vowels from the input string.

\$\endgroup\$
0
\$\begingroup\$

PowerShell, 26 bytes

|%{$_-replace'[aeiou]',''}

Anything before the | will be devowel'd.

\$\endgroup\$
0
\$\begingroup\$

jq, 119 bytes, 15 distinct characters

explode-[121-2-2,111,111-2-2-2,111-2-2-2-2-2,111-12-2,111-22-2-2,111-21-11,111-22-12-2-2,111-21-21,111-22-22-2]|implode

Try it online!

Here's how is works.

explode

Converts the input, which has to be a quoted string or jq can't parse it, to an array of codepoints.

-[121-2-2,111,111-2-2-2,111-2-2-2-2-2,111-12-2,111-22-2-2,111-21-11,111-22-12-2-2,111-21-21,111-22-22-2]

Remove all occurrences of upper and lower case vowels, which are representing as numeric expressions that map to the codepoints. You COULD make a program with one less unique character by limiting the expressions to 1 and -, but it would be very long...

|implode

Converts the array of codepoints left into a string and prints it.

\$\endgroup\$
0
\$\begingroup\$

Befunge-98 (PyFunge), 11 distinct characters, 263 bytes

<,_v#-''-''-'':_v#----'<'~':_v#--'-<':_v#--#'''-:'-'':_v#-:'-'':_v#---''-'-#'~':_v#--''v':_v#---,'-'-,'v':_v#--,'-'--:'~':_v#--,'-'-@':~@#
v<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Try it online!

Basically, checks each character against each of AEIOUaeiou, whose code points are constructed from the code points of the characters used elsewhere in the program, #',-:<@_v~.

The program also contains a newline. I'm pretty sure with much editing this could get down to 10 or even 9 characters by replacing v and the newline with some other method of returning to the start without the extra line, and there may be a way to also remove < in that case by leveraging a _.

For example:

The first chunk of code after the character read (right to left above, presented here left to right for clarity) is :'@-'-',--#v_. : duplicates the character, '@- subtracts the value @ (64) from the character, '-',- subtracts , (44) from - (45) to get 1, which is then subtracted (-) from the character, in total subtracting by 65, the code point for A. Then #v_ checks if this total is 0 (the character is A), and either sends the program down and to the next input or continues through the other vowels. If it passes all the checks, the character is printed.

\$\endgroup\$
0
\$\begingroup\$

Pascal, 35 distinct characters

This complete program requires a processor supporting features of Extended Pascal (as defined by ISO standard 10206), in particular the index function needs to be present. Note, to avoid the drama associated with all sorts of various end‑of‑line markers, Pascal (as defined by the ISO standard 7185 and 10206) says that for a text file (such as input) substitutes the end‑of‑line marker (whatever it may be) with a single space character (' '). Therefore the program does not reproduce the example’s two lines but one line joined by a space.

program p(input,output);var c:char;begin while not eof do begin read(c);if 0=index('AEIOUaeiou',c)then write(c)end end.

Ungolfed:

program removeVowelsWithoutUsingTooManyDifferentCharacters(input, output);
    var
        currentCharacter: char;
    begin
        while not EOF(input) do
        begin
            { This is equivalent to `currentCharacter ≔ input↑; get(input);`. }
            read(input, currentCharacter);
            
            { `index` returns zero if the pattern `currentCharacter`
              does not appear in the sample `'AEIOUaeiou'`. }
            if index('AEIOUaeiou', currentCharacter) = 0 then
            begin
                { Equivalent to `output↑ ≔ currentCharacter; put(output);`. }
                write(output, currentCharacter);
            end;
        end;
    end.
\$\endgroup\$
-1
\$\begingroup\$

Python (23)

Somebody had to do it.

print filter(lambda x:x not in'aeiou',raw_input())
\$\endgroup\$
2
  • 3
    \$\begingroup\$ That has "only" 23 distinct characters. But fails to work on uppercase vowels. \$\endgroup\$ May 28, 2012 at 16:55
  • \$\begingroup\$ By adding one new character and changing the variable from x to either c or s you can use lowercase() (or uppercase) and deal also with uppercase vowels. \$\endgroup\$
    – fabikw
    May 29, 2012 at 16:28
1
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.