Programming Contest by EggHeadCafe ... just Regex?

Published Thursday, December 09, 2004 1:05 AM

Rafael Munoz pointed me towards a Programming Contest By EggHeadCafe in his latest MVP Update Newsletter.  Reading through their criteria ...

<snip>
2. All occurrences of an in a sentence must be replaced by un.
3. Replace all occurrences of au in a sentence with oo
4. Inside any word (ie., after the first character):
replace all a's not followed by whitespace with the letter e. Thus, the word a by itself would not be translated to e
replace all o's in a word by u. Example: Doh becomes Duh.
</snip>

It sounds like a simple console application using a few Regular Expressions would do it ... (and obviously an adhoc test method to drive the results TDD style) ... am I missing something?

Filed under: ,

Comments

# Mischa Kroon said on Thursday, December 09, 2004 6:43 AM

Don't think so.

I guess they wanted to keep it simple :)

# Larry Wanzer said on Thursday, December 09, 2004 9:33 AM

That's the route I was taking, but there are a couple issues I ran into.

One of the criteria says to replace au with oo

A later criteria says to replace any o's with u's

But looking at their example you don't want to change caught to cooght to cuught; so you kind of have to mark your changes to not apply a second rule.

The other one was replacing the regex expression to put in a regex.replace for that.

# Wes Haggard said on Thursday, December 09, 2004 5:10 PM

So I'm trying to figure out their second example why do they replace "the" with "zee" instead of "the" with "the-a"?

Doesn't rule 5 make rule 7 never occur? or am I missunderstanding something? I figured the rules needed to be applied in order.

I think this can be done with some carefully crafted regular expressions but it will take some character translations so that you don't replace already replaced characters.

This Blog

Syndication