Python solution. Uses helper function that counts the matching elements in a list. I use that to compare the string to itself converted to upper- and lowercase.
defmatching(l1,l2):# Returns the number of matching corresponding elements of l1 and l2
returnsum(e1==e2fore1,e2inzip(l1,l2))defsolve(s):returns.lower()ifmatching(s,s.upper())<=matching(s,s.lower())elses.upper()cases=["coDe","CODe","coDE","code","CODe","COde","Code"]forcaseincases:print(f'{case} -> {solve(case)}')
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Python solution. Uses helper function that counts the matching elements in a list. I use that to compare the string to itself converted to upper- and lowercase.
TIO link