Write a programming algorithmic task in the following format: "Title":…
- User
Assistant: User: Write a programming algorithmic task in the following format:
"Title": "[Task title]", "Task Description": "[Brief description of the task, what needs to be done]", "Function Signature": "def function_name -> [return type]:"
Please make sure the task is more complex, unique, and does not resemble common problems from LeetCode. Focus on originality and complexity.
Also, provide a solution for the task in Python code in the following format:
"Solve": "[Solution to the task in Python]"
Please follow this format exactly, without any additional explanations or comments.
Assistant:
- Assistant
"Title": "Ancestral Sibling String Relations",
"Task Description": "Given a list of strings representing names in a fictional family tree, determine a metric of 'ancestral sibling closeness' for each string which is defined as the number of shared prefix characters between all possible pairs in the list. A prefix is defined as the starting sequence of characters. Return the sum of all the prefixes for all unique pairs of names in the list. If a prefix is the entire string of one of the strings in the pair, it is not counted. Consider only prefixes from length 1 to min(len(name1), len(name2)) - 1.",
"Function Signature": "def ancestral_sibling_closeness(names: List[str]) -> int:"
"Solve": """ def ancestral_sibling_closeness(names): def common_prefix_length(s1, s2): i = 0 while i < min(len(s1), len(s2)) and s1[i] == s2[i]: i += 1 return i
codetotal_closeness = 0 n = len(names) for i in range(n): for j in range(i + 1, n): common_length = common_prefix_length(names[i], names[j]) if common_length > 0: total_closeness += common_length return total_closeness
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.