19
\$\begingroup\$

The Māori language has quite simple pronouns. It uses a single word for he/she/they/etc (ia), and the words for "you" and "me" are koe and au respectively.

There are also words for groups of exactly two people:

  • tāua - You and me (we, au and koe)
  • māua - Me and them (we, au and ia)
  • rāua - Them (third person plural - two of them, ia and ia)
  • kōrua - You two (koe and koe)

And for three or more people:

  • tātou - All of you and me (we, au and multiple koe)
  • mātou - Me and all of them (we, au and multiple ia)
  • rātou - All of them (third person plural, multiple ia)
  • koutou - All of you (multiple koe)

Your challenge is to take a list of ia, koe and au and return the correct pronoun. You may assume that there is at most one au and that ia and koe will never both be in the input.

You may take input in any reasonable format - An array of ia, koe and au or three distinct values (within reason) representing those, an array of the counts of each word, a dictionary containing the counts of each word, space-separated words etc.

When there is only one word, you should output that.

Note that some of the outputs contain Unicode (ā and ō). You may output these as they are or as double letters - aa and oo.

For example, ia ia becomes rāua as it is two ia. au ia ia ia ia becomes mātou as it is one au and more than two ia. koe koe becomes kōrua.

Testcases

ia -> ia
koe -> koe
koe au -> tāua
ia ia -> rāua
koe koe koe koe koe -> koutou
ia ia au ia -> mātou
ia ia ia ia ia ia ia -> rātou
\$\endgroup\$
8
  • 2
    \$\begingroup\$ @tsh "You may assume that there is at most one au and that ia and koe will never both be in the input." \$\endgroup\$
    – Wheat Wizard
    Feb 11 at 3:46
  • 2
    \$\begingroup\$ Suggest add 1 test cases for every possible output. \$\endgroup\$
    – tsh
    Feb 11 at 3:59
  • 1
    \$\begingroup\$ Should "groups of two or more people" be only "groups of (exactly) two people"? \$\endgroup\$
    – att
    Feb 11 at 4:46
  • 2
    \$\begingroup\$ While it's not relevant to the puzzle, since explicitly avoided, I'm still curious what the answer would have been to tsh's question if that were not the case. Are there other group pronouns, not described here? Or does (koe ia) get treated as (koe koe)? \$\endgroup\$ Feb 11 at 15:23
  • 3
    \$\begingroup\$ @DewiMorgan: Wikipedia says that there is controversy over whether the distinction between (koe ia) and (koe koe) is expressed in any natural language at all, or indeed whether the human brain is even capable of consistently making such a distinction. I think the latter sounds a bit hyperbolic to me. \$\endgroup\$
    – Kevin
    Feb 11 at 23:19

7 Answers 7

5
\$\begingroup\$

JavaScript (Node.js), 94 bytes

a=>(g=r=>!!a.match(r))` `?'krtm'[h=g`u`*2+g`i`]+(g` .* `?h?'aatou':'outou':h?'aaua':'oorua'):a

Try it online!

\$\endgroup\$
3
\$\begingroup\$

JavaScript (Node.js), 121 bytes

x=>x[1]?'koutou0tātou0rātou0mātou0kōrua0tāua0rāua0māua'.split(0)[g=y=>x.includes(y+''),g`au`+g`ia`*2+4*!x[2]]:x[0]

Try it online!

Tabling n>2, "ia" exist, and "au" exist

\$\endgroup\$
3
\$\begingroup\$

Charcoal, 53 bytes

≔№θ η¿¬ηθ«≔⁺∧№θia²№θauζ¿ζ⁺§rtmζaa¿⊖ηkou¦koor¿⊖ηtou¦ua

Try it online! Link is to verbose version of code. Output uses double vowels. Explanation:

≔№θ η

Count the number of spaces in the input. (Note that due to Charcoal's input format autodetection, you need a trailing newline in the input for this to work.)

¿¬ηθ«

If there are no spaces, then just print the input.

≔⁺∧№θia²№θauζ

Count 2 if ia is present, plus 1 if a (assumed single) au is present.

¿ζ⁺§rtmζaa

If either are present then output taa, maa or raa as appropriate, ...

¿⊖ηkou¦koor

... otherwise output kou or koor depending on the number of words.

¿⊖ηtou¦ua

Output tou or ua depending on the number of words.

\$\endgroup\$
1
\$\begingroup\$

Python 3.8 (pre-release), 124 bytes

lambda n:[n,'rmkt'[2*('k'in n)+('u'in n)]+['ou','oa'['a'in n]*2][[*n].count('k')<3]+['ua','tou'][len(n.split())>2]][' 'in n]

Try it online!

\$\endgroup\$
2
  • \$\begingroup\$ I recommend changing the online test output to print(f"[{'OK' if f(inp) == expected else 'FAIL, expected ' + expected}] {inp} -> {f(inp)}"), makes it look nicer! \$\endgroup\$
    – rebane2001
    Feb 11 at 12:23
  • \$\begingroup\$ @rebane2001 Okay, will do that in the future! \$\endgroup\$
    – ophact
    Feb 11 at 12:25
1
\$\begingroup\$

Retina 0.8.2, 110 79 bytes

^(?=(.*au)?)(?=(?<1>.*ia)?){2}\w+ \w+
$#1aaua
T`d`ktmr
ua .*
tou
kaa
kou
uu
oru

Try it online! Link includes test cases. Output uses double vowels as those accented characters aren't in Retina's default code page. Explanation:

^(?=(.*au)?)(?=(?<1>.*ia)?){2}\w+ \w+

See whether the input contains au, matching as $#1, plus add two further matches to $#1 if the input contains ia. Also delete two words from the input (this fails if the input only contains one word).

$#1aaua

Replace the first two words with the count of matches suffixed with aaua.

T`d`ktmr

Replace the count with the appropriate letter.

ua .*
tou

If there were more than two words then change the ua to tou.

kaa
kou

kaatou should be koutou.

uu
oru

But kouua should be koorua.

\$\endgroup\$
1
\$\begingroup\$

Ruby -apl, 71 bytes

k=$F[2]?:koutou: :kōrua;$_=!/a/?k:(/k/??t:/u/??m:?r)+?ā+k[3,3]if$F[1]

Try it online!

\$\endgroup\$
1
\$\begingroup\$

Jelly,  57 52 51 49  47 bytes

“mtr”;€⁾aa;“kou“koor”⁽ñỌ,ḥ;Lị““ua“tou”Ɗ
Ṣḣ3ÇḢḊ?

A monadic Link accepting a list of lists of characters that yields a list of characters, the pronoun.

Try it online! Or see the test-suite.

How?

“mtr”;€⁾aa;“kou“koor”... - Link 1: list of lists of characters, X
“mtr”                    - "mtr"
       ⁾aa               - "aa"
     ;€                  - concatenate each -> ["maa", "taa", "raa"]
           “kou“koor”    - ["kou", "koor"]
          ;              - concatenate
                         -> domain = ["maa", "taa", "raa", "kou", "koor"]

...⁽ñỌ,ḥ;Lị““ua“tou”Ɗ - Link 1 (continued)
   ⁽ñỌ                - 7932
      ,               - pair
       ḥ              - hash X with a salt of 7932 and our domain (from above)
                    Ɗ - last three links as a monad - f(X):
         L            -   length (2 or 3)
           ““ua“tou”  -   ["", "ua", "tou"]
          ị           -   index into
        ;             - concatenate

Ṣḣ3ÇḢḊ? - Main Link: list of lists of characters, I
Ṣ       - sort I
 ḣ3     - keep up to the first three
      ? - if...
     Ḋ  - ...condition: dequeue (i.e. is length > 1 ?)
   Ç    - ...then: call Link 1
    Ḣ   - ...else: head of I
\$\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.