Files
app-store-optimization/skills/loki-mode/benchmarks/results/humaneval-loki-solutions/125.py

25 lines
836 B
Python

# HumanEval/125
# Loki Mode Multi-Agent Solution
# Attempts: 1
# Passed: True
def split_words(txt):
'''
Given a string of words, return a list of words split on whitespace, if no whitespaces exists in the text you
should split on commas ',' if no commas exists you should return the number of lower-case letters with odd order in the
alphabet, ord('a') = 0, ord('b') = 1, ... ord('z') = 25
Examples
split_words("Hello world!") ➞ ["Hello", "world!"]
split_words("Hello,world!") ➞ ["Hello", "world!"]
split_words("abcdef") == 3
'''
if ' ' in txt:
return txt.split()
elif ',' in txt:
return txt.split(',')
else:
count = 0
for char in txt:
if char.islower() and (ord(char) - ord('a')) % 2 == 1:
count += 1
return count