13
\$\begingroup\$

Write a program or function that takes in a single string containing only lowercase a-z, and prints or returns a truthy value if the word is the feminine version of the thing it represents and a falsy value if it is the masculine version. For example, hen is the feminine version for chicken and rooster is the masculine version, so hen might produce 1 and rooster might produce 0.

Doing this for all English words that reflect gender would of course be way too unwieldy. Your program/function only needs to support 20 masculine/feminine pairs. Below are five sets of 10 masculine/feminine pairs, categorized by topic. Choose any two of the sets; the 20 total pairs in these two sets are the 40 words your program/function must work for.

(format is masculine_version feminine_version)

  1. General

    he she
    him her
    man woman
    boy girl
    male female
    masculine feminine
    guy gal
    lad lass
    mister miss
    sir madam
    
  2. Familial

    father mother
    dad mom
    pa ma
    son daughter
    brother sister
    husband wife
    grandfather grandmother
    grandpa grandma
    uncle aunt
    nephew niece
    
  3. Animal

    lion lioness
    rooster hen
    stallion mare
    bull cow
    drake duck
    boar sow
    buck doe
    ram ewe
    gander goose
    billy nanny
    
  4. Royal

    king queen
    prince princess
    emperor empress
    duke duchess
    marquess marchioness
    earl countess
    baron baroness
    baronet baronetess
    lord lady
    knight dame
    
  5. Fantastical

    wizard witch
    giant giantess
    incubus succubus
    nidorino nidorina
    nidoking nidoqueen
    ents entwives
    hanuvoite inimeite
    centaur centaurides
    merman mermaid
    khal khaleesi
    

So, for example, you might choose the General and Familial categories. Then any input from he to sir or father to nephew would produce a falsy value, and any input from she to madam or mother to niece would produce a truthy value.

The values don't all have to be the same truthy/falsy type, e.g. he might produce 0 but sir might produce false. You may assume only the 40 specific lowercase a-z words from your two selected categories are ever input.

The shortest answer in bytes wins. Tiebreaker is earlier post.

(This challenge is not meant to correlate with or make statements about any current gender-based social issues.)

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Related. \$\endgroup\$ May 4, 2015 at 11:06
  • \$\begingroup\$ Shouldn't count be the masculine of countess? \$\endgroup\$
    – mbomb007
    May 4, 2015 at 14:39
  • \$\begingroup\$ @mbomb007 Not necessarily. \$\endgroup\$ May 4, 2015 at 15:45
  • 3
    \$\begingroup\$ Three answers, all Retina. \$\endgroup\$
    – Alex A.
    May 4, 2015 at 23:26

3 Answers 3

9
\$\begingroup\$

Retina, 26 bytes (sets 4, 5)

[^u]es|ee|m.i|y|^...c|d.*a

Retina is @MartinBüttner's regex language. I haven't used anything specific to .NET regexes, so you can test the regex at Regex101 here. Alternatively you can use Retina's grep G mode like so:

G`[^u]es|ee|m.i|y|^...c|d.*a

and pipe in a file with one word per line for batch testing.

Retina outputs the number of matches by default, giving us our truthy/falsy value. The rule "the values don't all have to be the same truthy/falsy type" is pretty important though since marchioness matches twice, giving an output of 2.

(Using the mod-chaining method from the previous male/female question seems to be shorter in CJam, but I'll let someone else do that)

\$\endgroup\$
1
  • 2
    \$\begingroup\$ time is never wasted on a regular expression \$\endgroup\$ May 4, 2015 at 11:34
3
\$\begingroup\$

Retina, 39 32 bytes (sets 2, 4)

Accounting for marquess was annoying, since using ma was the best way to get some of the feminines.

[^u]es|ma$|mo|y|[mie]e|wi|ter|au

Try it here

Thanks to Sp3000 for his golf suggestion.

\$\endgroup\$
2
  • \$\begingroup\$ With a little rearranging \$\endgroup\$
    – Sp3000
    May 4, 2015 at 16:37
  • \$\begingroup\$ @Sp3000 Ah, thanks. I hadn't noticed I could use $ for that. \$\endgroup\$
    – mbomb007
    May 4, 2015 at 16:40
2
\$\begingroup\$

Retina, 28 bytes (sets 3,4)

w|[mhorse]e|[^u]es|duc|[dn]y

Retina uses .NET regex, but any flavor should work. Test it at Regex101.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.