Home > .NET, Fun > Programming Contest by EggHeadCafe … just Regex?

Programming Contest by EggHeadCafe … just Regex?

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


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.

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?

Categories: .NET, Fun
  1. Mischa Kroon
    December 9, 2004 at 11:43 am

    Don’t think so.

    I guess they wanted to keep it simple 🙂

  2. Larry Wanzer
    December 9, 2004 at 2:33 pm

    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.

  3. Wes Haggard
    December 9, 2004 at 10: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.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: