Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Construct the Irish possessive

+2
−0

In this challenge you will take an Irish word and a personal pronoun and create the possessive pronoun construction combining the two.

For example , madra becomes a mhadra. Translated to English he, dog becomes his dog.

Rather than exhaustively describing how valid Irish words are formed, the input word will be taken from a representative list of Irish words. This means that a valid answer needs only to pass a finite number of test cases. These test cases are listed at the bottom. If you'd like to just look at the test cases and ignore the rest of the description you may do this.

This will be code-golf so the goal is to minimize the size of your program as measured in bytes.

Possesive pronouns

There are seven Irish possessive pronouns that we are going to care about here:

Type conjunctive form possessive pronoun sound change
1st sing. mo lenition
2nd sing. do lenition
3rd sing. fem. a h-prothesis
3rd sing. masc. a lenition
1st plur. muid ár eclipsis
2nd plur. sibh bhur eclipsis
3rd plur. siad a eclipsis

Each possessive pronoun triggers one of three mutations (sound changes) on the following word (i.e. the noun it modifies).

h-prothesis

h-prothesis is very simple. If the word begins with a vowel (e, é, i, í, a, á, o, ó, u, or ú) an h is added to the front. The h is always lowercase regardless of the case of the word.

Lenition

Lenition is, at least in terms of othography, very simple. The following rules can be applied with priority given to earlier rules:

  1. If the word begins with sc, sf, sm, sp or st no change is applied.
  2. If the word begins with b, c, d, f, g, m, p,s, or t a h is inserted after the initial consonant so f becomes fh.
  3. No change otherwise.

The inserted h matches the case of the second character in the noun.

Eclipsis

Eclispsis is the most complicated of the mutations we will discuss. It changes the initial sound of the following word, by adding additional letters. If the word starts with one of the following consonants then the following clusters are added:

  • b adds m
  • c adds g
  • d adds n
  • f adds bh
  • g adds n
  • p adds b
  • t adds d

This may look a bit random, but the actual underlying sound change is systematic; an unvoiced consonant adds the voiced version and a voiced consonant is replaced with the corresponding nasal consonant.

The added portion is always lower case and the initial letter retains its case. So FOCAL becomes bhFOCAL, and focal becomes bhfocal.

If the word starts with a vowel (e, é, i, í, a, á, o, ó, u, or ú), then an n is added to the front to make the eclipsed form. If the first letter is capitalized then a lower case n is simply added, if the first letter is not capitalized then a - is also added between the n and the root. So UBH becomes nUBH, and ubh becomes n-ubh.

Elision

Although not a mutation there is one last rule that has to be considered. mo and do have unstressed vowels and so they are not pronounced when the following word starts with a vowel. As a result the o is replaced with an apostrophe ' and the space is removed. So m'ól instead of *mo ól.

Tests

mé, arán -> m'arán
tú, arán -> d'arán
sí, arán -> a harán
sé, arán -> a arán
muid, arán -> ár n-arán
sibh, arán -> bhur n-arán
siad, arán -> a n-arán
mé, bád -> mo bhád
tú, bád -> do bhád
sí, bád -> a bád
sé, bád -> a bhád
muid, bád -> ár mbád
sibh, bád -> bhur mbád
siad, bád -> a mbád
mé, bróga -> mo bhróga
tú, bróga -> do bhróga
sí, bróga -> a bróga
sé, bróga -> a bhróga
muid, bróga -> ár mbróga
sibh, bróga -> bhur mbróga
siad, bróga -> a mbróga
mé, cóta -> mo chóta
tú, cóta -> do chóta
sí, cóta -> a cóta
sé, cóta -> a chóta
muid, cóta -> ár gcóta
sibh, cóta -> bhur gcóta
siad, cóta -> a gcóta
mé, cú -> mo chú
tú, cú -> do chú
sí, cú -> a cú
sé, cú -> a chú
muid, cú -> ár gcú
sibh, cú -> bhur gcú
siad, cú -> a gcú
mé, dinnéar -> mo dhinnéar
tú, dinnéar -> do dhinnéar
sí, dinnéar -> a dinnéar
sé, dinnéar -> a dhinnéar
muid, dinnéar -> ár ndinnéar
sibh, dinnéar -> bhur ndinnéar
siad, dinnéar -> a ndinnéar
mé, earr -> m'earr
tú, earr -> d'earr
sí, earr -> a hearr
sé, earr -> a earr
muid, earr -> ár n-earr
sibh, earr -> bhur n-earr
siad, earr -> a n-earr
mé, éan -> m'éan
tú, éan -> d'éan
sí, éan -> a héan
sé, éan -> a éan
muid, éan -> ár n-éan
sibh, éan -> bhur n-éan
siad, éan -> a n-éan
mé, fia -> mo fhia
tú, fia -> do fhia
sí, fia -> a fia
sé, fia -> a fhia
muid, fia -> ár bhfia
sibh, fia -> bhur bhfia
siad, fia -> a bhfia
mé, focal -> mo fhocal
tú, focal -> do fhocal
sí, focal -> a focal
sé, focal -> a fhocal
muid, focal -> ár bhfocal
sibh, focal -> bhur bhfocal
siad, focal -> a bhfocal
mé, gúna -> mo ghúna
tú, gúna -> do ghúna
sí, gúna -> a gúna
sé, gúna -> a ghúna
muid, gúna -> ár ngúna
sibh, gúna -> bhur ngúna
siad, gúna -> a ngúna
mé, iasc -> m'iasc
tú, iasc -> d'iasc
sí, iasc -> a hiasc
sé, iasc -> a iasc
muid, iasc -> ár n-iasc
sibh, iasc -> bhur n-iasc
siad, iasc -> a n-iasc
mé, íomhá -> m'íomhá
tú, íomhá -> d'íomhá
sí, íomhá -> a híomhá
sé, íomhá -> a íomhá
muid, íomhá -> ár n-íomhá
sibh, íomhá -> bhur n-íomhá
siad, íomhá -> a n-íomhá
mé, lámh -> mo lámh
tú, lámh -> do lámh
sí, lámh -> a lámh
sé, lámh -> a lámh
muid, lámh -> ár lámh
sibh, lámh -> bhur lámh
siad, lámh -> a lámh
mé, mac -> mo mhac
tú, mac -> do mhac
sí, mac -> a mac
sé, mac -> a mhac
muid, mac -> ár mac
sibh, mac -> bhur mac
siad, mac -> a mac
mé, madra -> mo mhadra
tú, madra -> do mhadra
sí, madra -> a madra
sé, madra -> a mhadra
muid, madra -> ár madra
sibh, madra -> bhur madra
siad, madra -> a madra
mé, naíon -> mo naíon
tú, naíon -> do naíon
sí, naíon -> a naíon
sé, naíon -> a naíon
muid, naíon -> ár naíon
sibh, naíon -> bhur naíon
siad, naíon -> a naíon
mé, oifig -> m'oifig
tú, oifig -> d'oifig
sí, oifig -> a hoifig
sé, oifig -> a oifig
muid, oifig -> ár n-oifig
sibh, oifig -> bhur n-oifig
siad, oifig -> a n-oifig
mé, ól -> m'ól
tú, ól -> d'ól
sí, ól -> a hól
sé, ól -> a ól
muid, ól -> ár n-ól
sibh, ól -> bhur n-ól
siad, ól -> a n-ól
mé, portán -> mo phortán
tú, portán -> do phortán
sí, portán -> a portán
sé, portán -> a phortán
muid, portán -> ár bportán
sibh, portán -> bhur bportán
siad, portán -> a bportán
mé, rón -> mo rón
tú, rón -> do rón
sí, rón -> a rón
sé, rón -> a rón
muid, rón -> ár rón
sibh, rón -> bhur rón
siad, rón -> a rón
mé, scáth -> mo scáth
tú, scáth -> do scáth
sí, scáth -> a scáth
sé, scáth -> a scáth
muid, scáth -> ár scáth
sibh, scáth -> bhur scáth
siad, scáth -> a scáth
mé, sféar -> mo sféar
tú, sféar -> do sféar
sí, sféar -> a sféar
sé, sféar -> a sféar
muid, sféar -> ár sféar
sibh, sféar -> bhur sféar
siad, sféar -> a sféar
mé, slí -> mo shlí
tú, slí -> do shlí
sí, slí -> a slí
sé, slí -> a shlí
muid, slí -> ár slí
sibh, slí -> bhur slí
siad, slí -> a slí
mé, sméara -> mo sméara
tú, sméara -> do sméara
sí, sméara -> a sméara
sé, sméara -> a sméara
muid, sméara -> ár sméara
sibh, sméara -> bhur sméara
siad, sméara -> a sméara
mé, spíon -> mo spíon
tú, spíon -> do spíon
sí, spíon -> a spíon
sé, spíon -> a spíon
muid, spíon -> ár spíon
sibh, spíon -> bhur spíon
siad, spíon -> a spíon
mé, srón -> mo shrón
tú, srón -> do shrón
sí, srón -> a srón
sé, srón -> a shrón
muid, srón -> ár srón
sibh, srón -> bhur srón
siad, srón -> a srón
mé, stiúideo -> mo stiúideo
tú, stiúideo -> do stiúideo
sí, stiúideo -> a stiúideo
sé, stiúideo -> a stiúideo
muid, stiúideo -> ár stiúideo
sibh, stiúideo -> bhur stiúideo
siad, stiúideo -> a stiúideo
mé, sú -> mo shú
tú, sú -> do shú
sí, sú -> a sú
sé, sú -> a shú
muid, sú -> ár sú
sibh, sú -> bhur sú
siad, sú -> a sú
mé, teaghlach -> mo theaghlach
tú, teaghlach -> do theaghlach
sí, teaghlach -> a teaghlach
sé, teaghlach -> a theaghlach
muid, teaghlach -> ár dteaghlach
sibh, teaghlach -> bhur dteaghlach
siad, teaghlach -> a dteaghlach
mé, ubh -> m'ubh
tú, ubh -> d'ubh
sí, ubh -> a hubh
sé, ubh -> a ubh
muid, ubh -> ár n-ubh
sibh, ubh -> bhur n-ubh
siad, ubh -> a n-ubh
mé, úll -> m'úll
tú, úll -> d'úll
sí, úll -> a húll
sé, úll -> a úll
muid, úll -> ár n-úll
sibh, úll -> bhur n-úll
siad, úll -> a n-úll
mé, ARÁN -> M'ARÁN
tú, ARÁN -> D'ARÁN
sí, ARÁN -> A hARÁN
sé, ARÁN -> A ARÁN
muid, ARÁN -> ÁR nARÁN
sibh, ARÁN -> BHUR nARÁN
siad, ARÁN -> A nARÁN
mé, BÁD -> MO BHÁD
tú, BÁD -> DO BHÁD
sí, BÁD -> A BÁD
sé, BÁD -> A BHÁD
muid, BÁD -> ÁR mBÁD
sibh, BÁD -> BHUR mBÁD
siad, BÁD -> A mBÁD
mé, BRÓGA -> MO BHRÓGA
tú, BRÓGA -> DO BHRÓGA
sí, BRÓGA -> A BRÓGA
sé, BRÓGA -> A BHRÓGA
muid, BRÓGA -> ÁR mBRÓGA
sibh, BRÓGA -> BHUR mBRÓGA
siad, BRÓGA -> A mBRÓGA
mé, CÓTA -> MO CHÓTA
tú, CÓTA -> DO CHÓTA
sí, CÓTA -> A CÓTA
sé, CÓTA -> A CHÓTA
muid, CÓTA -> ÁR gCÓTA
sibh, CÓTA -> BHUR gCÓTA
siad, CÓTA -> A gCÓTA
mé, CÚ -> MO CHÚ
tú, CÚ -> DO CHÚ
sí, CÚ -> A CÚ
sé, CÚ -> A CHÚ
muid, CÚ -> ÁR gCÚ
sibh, CÚ -> BHUR gCÚ
siad, CÚ -> A gCÚ
mé, DINNÉAR -> MO DHINNÉAR
tú, DINNÉAR -> DO DHINNÉAR
sí, DINNÉAR -> A DINNÉAR
sé, DINNÉAR -> A DHINNÉAR
muid, DINNÉAR -> ÁR nDINNÉAR
sibh, DINNÉAR -> BHUR nDINNÉAR
siad, DINNÉAR -> A nDINNÉAR
mé, EARR -> M'EARR
tú, EARR -> D'EARR
sí, EARR -> A hEARR
sé, EARR -> A EARR
muid, EARR -> ÁR nEARR
sibh, EARR -> BHUR nEARR
siad, EARR -> A nEARR
mé, ÉAN -> M'ÉAN
tú, ÉAN -> D'ÉAN
sí, ÉAN -> A hÉAN
sé, ÉAN -> A ÉAN
muid, ÉAN -> ÁR nÉAN
sibh, ÉAN -> BHUR nÉAN
siad, ÉAN -> A nÉAN
mé, FIA -> MO FHIA
tú, FIA -> DO FHIA
sí, FIA -> A FIA
sé, FIA -> A FHIA
muid, FIA -> ÁR bhFIA
sibh, FIA -> BHUR bhFIA
siad, FIA -> A bhFIA
mé, FOCAL -> MO FHOCAL
tú, FOCAL -> DO FHOCAL
sí, FOCAL -> A FOCAL
sé, FOCAL -> A FHOCAL
muid, FOCAL -> ÁR bhFOCAL
sibh, FOCAL -> BHUR bhFOCAL
siad, FOCAL -> A bhFOCAL
mé, GÚNA -> MO GHÚNA
tú, GÚNA -> DO GHÚNA
sí, GÚNA -> A GÚNA
sé, GÚNA -> A GHÚNA
muid, GÚNA -> ÁR nGÚNA
sibh, GÚNA -> BHUR nGÚNA
siad, GÚNA -> A nGÚNA
mé, IASC -> M'IASC
tú, IASC -> D'IASC
sí, IASC -> A hIASC
sé, IASC -> A IASC
muid, IASC -> ÁR nIASC
sibh, IASC -> BHUR nIASC
siad, IASC -> A nIASC
mé, ÍOMHÁ -> M'ÍOMHÁ
tú, ÍOMHÁ -> D'ÍOMHÁ
sí, ÍOMHÁ -> A hÍOMHÁ
sé, ÍOMHÁ -> A ÍOMHÁ
muid, ÍOMHÁ -> ÁR nÍOMHÁ
sibh, ÍOMHÁ -> BHUR nÍOMHÁ
siad, ÍOMHÁ -> A nÍOMHÁ
mé, LÁMH -> MO LÁMH
tú, LÁMH -> DO LÁMH
sí, LÁMH -> A LÁMH
sé, LÁMH -> A LÁMH
muid, LÁMH -> ÁR LÁMH
sibh, LÁMH -> BHUR LÁMH
siad, LÁMH -> A LÁMH
mé, MAC -> MO MHAC
tú, MAC -> DO MHAC
sí, MAC -> A MAC
sé, MAC -> A MHAC
muid, MAC -> ÁR MAC
sibh, MAC -> BHUR MAC
siad, MAC -> A MAC
mé, MADRA -> MO MHADRA
tú, MADRA -> DO MHADRA
sí, MADRA -> A MADRA
sé, MADRA -> A MHADRA
muid, MADRA -> ÁR MADRA
sibh, MADRA -> BHUR MADRA
siad, MADRA -> A MADRA
mé, NAÍON -> MO NAÍON
tú, NAÍON -> DO NAÍON
sí, NAÍON -> A NAÍON
sé, NAÍON -> A NAÍON
muid, NAÍON -> ÁR NAÍON
sibh, NAÍON -> BHUR NAÍON
siad, NAÍON -> A NAÍON
mé, OIFIG -> M'OIFIG
tú, OIFIG -> D'OIFIG
sí, OIFIG -> A hOIFIG
sé, OIFIG -> A OIFIG
muid, OIFIG -> ÁR nOIFIG
sibh, OIFIG -> BHUR nOIFIG
siad, OIFIG -> A nOIFIG
mé, ÓL -> M'ÓL
tú, ÓL -> D'ÓL
sí, ÓL -> A hÓL
sé, ÓL -> A ÓL
muid, ÓL -> ÁR nÓL
sibh, ÓL -> BHUR nÓL
siad, ÓL -> A nÓL
mé, PORTÁN -> MO PHORTÁN
tú, PORTÁN -> DO PHORTÁN
sí, PORTÁN -> A PORTÁN
sé, PORTÁN -> A PHORTÁN
muid, PORTÁN -> ÁR bPORTÁN
sibh, PORTÁN -> BHUR bPORTÁN
siad, PORTÁN -> A bPORTÁN
mé, RÓN -> MO RÓN
tú, RÓN -> DO RÓN
sí, RÓN -> A RÓN
sé, RÓN -> A RÓN
muid, RÓN -> ÁR RÓN
sibh, RÓN -> BHUR RÓN
siad, RÓN -> A RÓN
mé, SCÁTH -> MO SCÁTH
tú, SCÁTH -> DO SCÁTH
sí, SCÁTH -> A SCÁTH
sé, SCÁTH -> A SCÁTH
muid, SCÁTH -> ÁR SCÁTH
sibh, SCÁTH -> BHUR SCÁTH
siad, SCÁTH -> A SCÁTH
mé, SFÉAR -> MO SFÉAR
tú, SFÉAR -> DO SFÉAR
sí, SFÉAR -> A SFÉAR
sé, SFÉAR -> A SFÉAR
muid, SFÉAR -> ÁR SFÉAR
sibh, SFÉAR -> BHUR SFÉAR
siad, SFÉAR -> A SFÉAR
mé, SLÍ -> MO SHLÍ
tú, SLÍ -> DO SHLÍ
sí, SLÍ -> A SLÍ
sé, SLÍ -> A SHLÍ
muid, SLÍ -> ÁR SLÍ
sibh, SLÍ -> BHUR SLÍ
siad, SLÍ -> A SLÍ
mé, SMÉARA -> MO SMÉARA
tú, SMÉARA -> DO SMÉARA
sí, SMÉARA -> A SMÉARA
sé, SMÉARA -> A SMÉARA
muid, SMÉARA -> ÁR SMÉARA
sibh, SMÉARA -> BHUR SMÉARA
siad, SMÉARA -> A SMÉARA
mé, SPÍON -> MO SPÍON
tú, SPÍON -> DO SPÍON
sí, SPÍON -> A SPÍON
sé, SPÍON -> A SPÍON
muid, SPÍON -> ÁR SPÍON
sibh, SPÍON -> BHUR SPÍON
siad, SPÍON -> A SPÍON
mé, SRÓN -> MO SHRÓN
tú, SRÓN -> DO SHRÓN
sí, SRÓN -> A SRÓN
sé, SRÓN -> A SHRÓN
muid, SRÓN -> ÁR SRÓN
sibh, SRÓN -> BHUR SRÓN
siad, SRÓN -> A SRÓN
mé, STIÚIDEO -> MO STIÚIDEO
tú, STIÚIDEO -> DO STIÚIDEO
sí, STIÚIDEO -> A STIÚIDEO
sé, STIÚIDEO -> A STIÚIDEO
muid, STIÚIDEO -> ÁR STIÚIDEO
sibh, STIÚIDEO -> BHUR STIÚIDEO
siad, STIÚIDEO -> A STIÚIDEO
mé, SÚ -> MO SHÚ
tú, SÚ -> DO SHÚ
sí, SÚ -> A SÚ
sé, SÚ -> A SHÚ
muid, SÚ -> ÁR SÚ
sibh, SÚ -> BHUR SÚ
siad, SÚ -> A SÚ
mé, TEAGHLACH -> MO THEAGHLACH
tú, TEAGHLACH -> DO THEAGHLACH
sí, TEAGHLACH -> A TEAGHLACH
sé, TEAGHLACH -> A THEAGHLACH
muid, TEAGHLACH -> ÁR dTEAGHLACH
sibh, TEAGHLACH -> BHUR dTEAGHLACH
siad, TEAGHLACH -> A dTEAGHLACH
mé, UBH -> M'UBH
tú, UBH -> D'UBH
sí, UBH -> A hUBH
sé, UBH -> A UBH
muid, UBH -> ÁR nUBH
sibh, UBH -> BHUR nUBH
siad, UBH -> A nUBH
mé, ÚLL -> M'ÚLL
tú, ÚLL -> D'ÚLL
sí, ÚLL -> A hÚLL
sé, ÚLL -> A ÚLL
muid, ÚLL -> ÁR nÚLL
sibh, ÚLL -> BHUR nÚLL
siad, ÚLL -> A nÚLL

These cases were generated by this program. If you'd like to see a valid implementation of this challenge there is one there. If you'd like to have the test cases in a different format you can adjust the code there to output it in a different format.

About the tests

For your convienence the following are true about all the test cases:

  • The noun is always either all caps or all lower, there is no mixed casing in any of the input nouns.
  • The input is all combinations of 32 distinct words with the 6 pronouns listed, in both upper case and lower case.
  • The following letters appear in the input:
    ABCDEFGHILMNOPRSTUabcdefghilmnoprstuÁÉÍÓÚáéíóú
    
    This means that of the ISO Latin alphabet, J, K, Q, V, W, X, Y, and Z (plus their lower case variants) never appear in the input. The output contains this same character set, plus ', and -.
  • No input ever begins with h or H.
History
Why does this post require moderator attention?
You might want to add some details to your flag.
Why should this post be closed?

0 comment threads

1 answer

+2
−0

Python 3.8+, 577 bytes

(was 634 than 591 bytes before)

V="eéiíaáoóuúEÉIÍAÁOÓUÚ"
r={"mé":("mo",0),"tú":("do",0),"sí":("a",1),"sé":("a",0),"muid":("ár",2),"sibh":("bhur",2),"siad":("a",2)}
s=lambda a,b:a.upper()if b[0].isupper()else a
def f(x,y):w,R=r[x];w=s(w[0]+"'"if w in{"mo","do"}and y[0]in V else w+" ",y);return w+[lambda w:[w,w[0]+s("h",w)+w[1:]][1-(w[:2].lower()in"sc sf sm sp st".split())&(w[0].lower()in"bcdfgmpst")],lambda v:"h"+v if v[0]in V else v,e][R](y)
def e(w):
 for r in"bm cg dn fbh gn pb td".split():
  if w[0].lower()==r[0]:return r[1:]+w
 return[w,"n-"+w,"n"+w][(c:=w[0]in V)*(c+w[0].isupper())]

Try it online!

A reference implementation, to understand the details.

vowels = set("eéiíaáoóuúEÉIÍAÁOÓUÚ")
rule_dict = {
    "mé":   ("mo", "lenition"),
    "tú":   ("do", "lenition"),
    "sí":   ("a", "h-prothesis"),
    "sé":   ("a", "lenition"),
    "muid":	("ár", "eclipsis"),
    "sibh":	("bhur", "eclipsis"),
    "siad":	("a", "eclipsis"),
}

def f(x, y):
    possessive_pronoun, rule = rule_dict[x]
    if possessive_pronoun in {"mo", "do"} and y[0] in vowels:
        possessive_pronoun =  same_case(possessive_pronoun[0], y) + "'"
    else:
        possessive_pronoun = possessive_pronoun + " "
    if y[0].isupper():
        possessive_pronoun = possessive_pronoun.upper()

    if rule == "lenition":
        y = lenition(y)
    if rule == "h-prothesis":
        y = h_prothesis(y)
    if rule == "eclipsis":
        y = eclipsis(y)
    return possessive_pronoun + y

def h_prothesis(word: str) -> str:
    if word[0] in vowels:
        return "h" + word
    return word

def lenition(word: str) -> str:
    l1 = "sc sf sm sp st".split()
    if word[:2].lower() in l1:
        return word
    if word[0].lower() in set("bcdfgmpst"):
        return word[0] + same_case("h", word) + word[1:]
    return word

def eclipsis(word: str) -> str:
    rules = ["bm", "cg", "dn", "fbh", "gn", "pb", "td"]
    for r in rules:
        if word[0].lower() == r[0]:
            word = r[1:] + word
            return word
    if word[0] in vowels:
        if word[0] != word[0].lower():
            return "n" + word
        else:
            return "n-" + word
    return word

def same_case(a, b) -> str:
    if b[0].isupper():
        return a.upper()
    return a.lower()
History
Why does this post require moderator attention?
You might want to add some details to your flag.

1 comment thread

Possibly shorter than `range` (2 comments)

Sign up to answer this question »