9
1
A spoonerisation is swapping the first letter/pronounceable syllable of two or more words.
Example: A lack of pies = A pack of lies. Bad salad = Sad ballad (ish) :)
Challenge: Write a program to spoonerise two words in the shortest characters possible.
Rules:
- If the first letter is a consonant, you must include subsequent letters until you reach a vowel. (e.g. 'thanks' - the th gets removed and put on the front of the other word).
- With words that start with vowels, do not remove anything from the start of the word.
Good luck :)
UPDATE: Multiple word spoonerisms are not strictly applicable, however from a programatic view we must cater for them so this is the rule: Every word must change. Example:
Weird Keen Monkey -> Meird Ween Konkey OR Keird Meen Wonkey NOT Meird Keen Wonkey
Also 'y' is treated as a vowel (just to simplify things a bit)
To clarify, does "big apple" become "ig bapple", and does "ant eater" remain the same? – Joey Adams – 2011-08-16T22:26:54.397
indeed - unless you can think of a better rule in which case I will add it in there :) – Alex Coplan – 2011-08-16T22:27:32.337
A "better rule" might involve using a word list to find an "optimal" spoonerization, but that would be a different and more complex problem. – Joey Adams – 2011-08-16T22:32:12.220
Indeed, and would not be so easily golfable as it relies on the quality of your source model / API – Alex Coplan – 2011-08-16T22:34:29.343
I can't think of a retter bule. – Briguy37 – 2011-08-17T18:39:51.727
Does the input have to be on STDIN? – recursive – 2011-08-17T19:08:09.627
@recursive - sorry what is STDIN? I'm an obj-c programmer – Alex Coplan – 2011-08-17T19:44:46.893
Standard input a.k.a. console input. – recursive – 2011-08-17T19:48:05.967
in that case, yes – Alex Coplan – 2011-08-17T19:58:41.277
You don't have to verify that the word exists in a dictionary - just swap? So
program to
would becometogram pro ...
,spoonerise words
=>woonerise spords
? – user unknown – 2011-08-18T15:46:37.853that's correct :) – Alex Coplan – 2011-08-18T16:52:39.257
it was purely a coding challenge, not that it has a practical application! – Alex Coplan – 2011-08-18T16:53:02.623
What shall 'no year solution' be transformed to? 'yo near solution'? Or "Why do you cheat" or "rhythm and soul". – user unknown – 2011-08-20T05:02:46.827
@user unkown see updated answer – Alex Coplan – 2011-08-20T07:44:01.773
updated question? – user unknown – 2011-08-20T12:58:28.117
yes sorry I'm so used to typing see updated answer :) – Alex Coplan – 2011-08-20T13:06:14.063
a pack of lies
was 4 words too, just only 2 starting with a consonant. So I thought, according with the old rules, we have to change the first 2 words, which don't start with a vowel. Now you changed the rules completly. Why? That's not clarification of the rules, but changing them. – user unknown – 2011-08-20T13:06:26.5433 of the current solutions fail with 'a pack of lies' and return 'la pack of ies' - I didn't test that, because I wouldn't have thought somebody is presenting a solution, which does not solve the given examples. – user unknown – 2011-08-20T14:22:27.417
To be tested with "Stack Overflow Rocks Hard"... – PhiLho – 2011-08-20T16:01:52.823
1
I'm sorry but I have to downvote the question, which wasn't well prepared. So the answers were coming in, while the question wasn't cleared. Related discussion: more discipline Place to prepare challenges and to find and remove ambiguities, beside chat: Sandbox mk II
– user unknown – 2011-08-20T16:21:09.1602The original question says "spoonerise two words". That seemed clear, and downvoting answers (including mine) that followed that spec doesn't sit right with me. The updated question says "every word must change". How should "a" in "a pack of lies" or "I" in "I like my bike" change? Presumably, the intent is that every word that starts with a consonant should change? Sorry, but I think the original was clearer, even though the examples of spoonerisms weren't examples of input. – DCharness – 2011-08-21T06:35:11.313