22
\$\begingroup\$

Here is a list of 30 English nouns in their singular and plural form. Your job is simply to write the shortest regular expression that matches all the nouns in one form and none in the other (easy, all English nouns end in s in plural form right?).

SINGULAR     PLURAL
---------    --------
car          cars
boat         boats
man          men
woman        women
omen         omens
bus          buses
cactus       cacti
spy          spies
pie          pies
louse        lice
mouse        mice
amice        amices
goose        geese
creese       creeses
person       people
child        children
siren        sirens
ox           oxen
foot         feet
tooth        teeth
formula      formulae
minx         minxes
sphinx       sphinges
wife         wives
knife        knives
ion          ions
criterion    criteria
jinni        jinn
zero         zeros
hero         heroes        

Yes, some of the words have alternative forms, but these are the ones we're going to use.

Here is a script that can help you with the testing; just put your regex between the two slashes (/) on the first line.

\$\endgroup\$
6
  • 7
    \$\begingroup\$ Hmm, interesting challenge! I never knew the sphinx one; I always thought it was sphynxes :-P +1 \$\endgroup\$
    – Doorknob
    Jan 16, 2014 at 23:48
  • 5
    \$\begingroup\$ glad you didn't add fish and sheep to the list :) \$\endgroup\$
    – mniip
    Jan 16, 2014 at 23:53
  • 1
    \$\begingroup\$ I'm probably missing something (this is not my first language, and most of us have scarce relationships with them anyways) but shouldn't the 4th entry be "women"? \$\endgroup\$
    – Tobia
    Jan 16, 2014 at 23:54
  • 1
    \$\begingroup\$ @daniero well, 28 is a nice round number too (base 7 or base 28 or ...) (relevant spikedmath comic) \$\endgroup\$
    – Justin
    Jan 17, 2014 at 0:02
  • 2
    \$\begingroup\$ Typical English esoteric rules - for example, if plural for goose is geese, then how come the plural for moose is not meese? (Its actually moose - a gotcha there) \$\endgroup\$
    – t0mm13b
    Jan 17, 2014 at 0:48

3 Answers 3

11
\$\begingroup\$

44, or 46 if delimiting // count:

dr|wome|[aglx]e|et|ti|ia|[^u]s$|nn$|^.ic|^me
\$\endgroup\$
4
\$\begingroup\$

42 (or 44 with delimiters)

^.(e[^r]|ic)|x.|..me|ia|ti|.l..|nn$|[^u]s$ - Try it online!
^.(e[^r]|ic)|x.|..me|ia|[adjlu]...$|[^u]s$ - Try it online!

\$\endgroup\$
2
\$\begingroup\$

65 or 67

^[lm]i[^n]|^ge|ti|ia|[l|a]e$|ox.|^(wo)?men$|dren|nn$|et|[netro]s$
\$\endgroup\$

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.