Gode-Colf: Wipping Flords around

2

Here is another short string related code-golf. You must write a full program that reads a string (from STDIN or as command line arguments, as long as you specify which) and wips the flords around (flips the words around). A valid flord wip must

  • Flip all of the beginning consonants. (All of the leading consonants up to the first vowel) For example, "Flipping Words" does not become "Wlipping Fords" because this only flips the first letter of each. Instead, it becomes "Wipping Flords"

  • Never flip a vowel. For example, "Eating Breakfast" becomes "Breating Eakfast"

  • Capitalize the first letter of each output word, and no more. For example 'Stack Overflow' becomes 'Ack Stoverflow', not 'ack StOverflow'.

Your input:

  • Will have the first letter of every word capitalized, and all the other letters lowercase.

  • Will consist entirely of upper and lowercase letters and spaces. There will not be any extra or leading spaces.

  • There will be no strange consonant only words. For the purposes of this challenge, "y" is a consonant.

  • Will have at least 2 words, each separated with a single space. If there are an even number of words, you must flip the first word with the second, the third with the fourth, the fifth with the sixth and so on and so forth. If there are an odd number of words, the same rules apply, and the last word is skipped.

Here are some sample inputs and outputs.

Bunny Rabbit ---> Runny Babbit

Programming Puzzles And Code Golf ---> Pogramming Pruzzles Cand Ode Golf

The Cake Is A Lie ---> Ce Thake Is A Lie ("Is" and "A" both start with a vowel, so nothing changes. "Lie" is the last odd-word-out so nothing changes)

May The Best Golfer Win ---> Thay Me Gest Bolfer Win

James

Posted 2015-05-23T17:45:24.683

Reputation: 54 537

Question was closed 2015-05-23T19:26:10.567

Answers

1

CJam, 62 53 bytes

This is too long for now. Will add explanations once I am done golfing.

qS%2/{{el__"aeiou"&0=#_2$<@@>}%(a+2/Wf%~}%{s(eu\+}%S*

Try it online here

Optimizer

Posted 2015-05-23T17:45:24.683

Reputation: 25 836