Files

25 lines
987 B
Python

# HumanEval/113
# Loki Mode Multi-Agent Solution
# Attempts: 1
# Passed: True
def odd_count(lst):
"""Given a list of strings, where each string consists of only digits, return a list.
Each element i of the output should be "the number of odd elements in the
string i of the input." where all the i's should be replaced by the number
of odd digits in the i'th string of the input.
>>> odd_count(['1234567'])
["the number of odd elements 4n the str4ng 4 of the 4nput."]
>>> odd_count(['3',"11111111"])
["the number of odd elements 1n the str1ng 1 of the 1nput.",
"the number of odd elements 8n the str8ng 8 of the 8nput."]
"""
result = []
for s in lst:
odd_digit_count = sum(1 for d in s if int(d) % 2 == 1)
count_str = str(odd_digit_count)
template = "the number of odd elements in the string i of the input."
formatted = template.replace('i', count_str)
result.append(formatted)
return result