type
stringclasses
1 value
task
stringlengths
137
560
plan
listlengths
2
4
code
stringlengths
98
383
task_code
Write a Python function that takes two equal-length lists of integers, compares each pair using a margin of 87, and returns a dictionary with counts for 'first_ahead' (first minus second > 87), 'second_ahead' (second minus first > 87), and 'within_margin' (otherwise). The input lists must not be mutated.
[ "Initialize counts dictionary with three keys set to 0.", "Iterate over pairs using zip: compute difference.", "If first - second > 87, increment first_ahead; else if second - first > 87, increment second_ahead; else increment within_margin.", "Return the counts dictionary." ]
def compare_pairs_with_margin_87(first, second): counts = {"first_ahead": 0, "second_ahead": 0, "within_margin": 0} for left, right in zip(first, second): if left - right > 87: counts["first_ahead"] += 1 elif right - left > 87: counts["second_ahead"] += 1 else: ...
task_code
Write a Python function that takes a nested list of integers, retains only integers >= 1 within each inner list, multiplies each retained integer by 12, and returns a new nested list preserving the original row order. The input must not be mutated.
[ "Create a new empty list for the result.", "For each inner list, create a new list with values >= 1 multiplied by 12.", "Append the transformed inner list to the result.", "Return the result list." ]
def transform_rows_0_12_1(rows): return [[value * 12 for value in row if value >= 1] for row in rows]
task_code
Write a Python function that takes a list of dictionaries each containing 'group' and a list of integer 'values', and returns a list of 'group' values for which the sum of 'values' exceeds 60, preserving original order. The input list must not be mutated.
[ "Initialize an empty result list.", "Iterate over each record: compute sum of its 'values' list.", "If the sum > 60, append the 'group' to the result.", "Return the result list." ]
def groups_over_total_60(records): return [row["group"] for row in records if sum(row["values"]) > 60]
task_code
Write a Python function that takes two dictionaries mapping keys to integer counts, sums the counts over the union of keys (treating missing keys as 0), and returns a new dictionary containing only those keys where the total is at least 10. The input dictionaries must not be mutated.
[ "Create a set of all keys from both dictionaries.", "For each key, compute total = first.get(key, 0) + second.get(key, 0).", "If total >= 10, add key and total to result.", "Return the result dictionary." ]
def combine_group_counts_min_10(first, second): result = {} for key in set(first) | set(second): total = first.get(key, 0) + second.get(key, 0) if total >= 10: result[key] = total return result
task_code
Write a Python function that takes a list of tag strings, strips whitespace and converts each to uppercase, keeps only those with length at least 6, and returns a dictionary counting occurrences of each normalized string. The input list must not be mutated.
[ "Initialize an empty dictionary for counts.", "Iterate over each tag: strip whitespace and convert to uppercase.", "If the cleaned string length is at least 6, increment its count in the dictionary.", "Return the dictionary." ]
def count_clean_tags_upper_6(tags): counts = {} for tag in tags: cleaned = tag.strip().upper() if len(cleaned) >= 6: counts[cleaned] = counts.get(cleaned, 0) + 1 return counts
task_code
Write a Python function that takes a list of dictionaries, filters to keep those where 'rank' is <= 23, sorts the kept records by 'rank' in ascending order, and returns a list of the 'title' values in that sorted order. The input list must not be mutated.
[ "Filter the list to keep only records with rank <= 23.", "Sort the filtered list by the 'rank' key in ascending order.", "Extract the 'title' values from the sorted records.", "Return the list of titles." ]
def select_titles_by_rank_23_ascending(records): kept = [row for row in records if row["rank"] <= 23] kept = sorted(kept, key=lambda row: row["rank"], reverse=False) return [row["title"] for row in kept]
task_code
Write a Python function that takes a list of dictionaries each containing 'tag' and 'items', keeps only entries where items is at least 1, and returns a new dictionary mapping each tag to the total items for that tag. The input list must not be mutated.
[ "Initialize an empty dictionary for totals.", "Iterate over each record: if items >= 1, add items to the total for its tag.", "Return the totals dictionary." ]
def total_items_by_tag_min_1(records): totals = {} for row in records: if row["items"] >= 1: group = row["tag"] totals[group] = totals.get(group, 0) + row["items"] return totals
task_code
Write a Python function that takes a list of dictionaries each containing 'tag' and 'items', computes the average items per tag, and returns a dictionary mapping each tag to its average only if the average is at least 11. The input list must not be mutated.
[ "Initialize two dictionaries: one for total items per tag, one for count per tag.", "Iterate over each record: add items to the total and increment count for its tag.", "Compute average for each tag as total divided by count.", "Return a dictionary of tags with average >= 11." ]
def qualifying_items_averages_by_tag(records): totals = {} counts = {} for row in records: group = row["tag"] totals[group] = totals.get(group, 0) + row["items"] counts[group] = counts.get(group, 0) + 1 return {g: totals[g] / counts[g] for g in totals if totals[g] / counts[g] >= ...
task_code
Write a Python function that takes two equal-length lists of integers, compares each pair using a margin of 88, and returns a dictionary with counts for 'first_ahead' (first minus second > 88), 'second_ahead' (second minus first > 88), and 'within_margin' (otherwise). The input lists must not be mutated.
[ "Initialize counts dictionary with three keys set to 0.", "Iterate over pairs using zip: compute difference.", "If first - second > 88, increment first_ahead; else if second - first > 88, increment second_ahead; else increment within_margin.", "Return the counts dictionary." ]
def compare_pairs_with_margin_88(first, second): counts = {"first_ahead": 0, "second_ahead": 0, "within_margin": 0} for left, right in zip(first, second): if left - right > 88: counts["first_ahead"] += 1 elif right - left > 88: counts["second_ahead"] += 1 else: ...
task_code
Write a Python function that takes a nested list of integers, retains only integers greater than 1 within each inner list, and returns a new nested list preserving the original row order. The input must not be mutated.
[ "Create a new empty list for the result.", "For each inner list, create a new list with values > 1.", "Append the filtered inner list to the result.", "Return the result list." ]
def transform_rows_1_12_1(rows): return [[value for value in row if value > 1] for row in rows]
task_code
Write a Python function that takes a list of dictionaries each containing 'tag' and a list of integer 'values', and returns a list of 'tag' values for which the sum of 'values' exceeds 61, preserving original order. The input list must not be mutated.
[ "Initialize an empty result list.", "Iterate over each record: compute sum of its 'values' list.", "If the sum > 61, append the 'tag' to the result.", "Return the result list." ]
def tags_over_total_61(records): return [row["tag"] for row in records if sum(row["values"]) > 61]
task_code
Write a Python function that takes two dictionaries mapping keys to integer counts, sums the counts over the union of keys (treating missing keys as 0), and returns a new dictionary containing only those keys where the total is at least 11. The input dictionaries must not be mutated.
[ "Create a set of all keys from both dictionaries.", "For each key, compute total = first.get(key, 0) + second.get(key, 0).", "If total >= 11, add key and total to result.", "Return the result dictionary." ]
def combine_tag_counts_min_11(first, second): result = {} for key in set(first) | set(second): total = first.get(key, 0) + second.get(key, 0) if total >= 11: result[key] = total return result
task_code
Write a Python function that takes a list of label strings, strips whitespace and converts each to uppercase, keeps only those with length at least 6, and returns a dictionary counting occurrences of each normalized string. The input list must not be mutated.
[ "Initialize an empty dictionary for counts.", "Iterate over each label: strip whitespace and convert to uppercase.", "If the cleaned string length is at least 6, increment its count in the dictionary.", "Return the dictionary." ]
def count_clean_labels_upper_6(labels): counts = {} for label in labels: cleaned = label.strip().upper() if len(cleaned) >= 6: counts[cleaned] = counts.get(cleaned, 0) + 1 return counts
task_code
Write a Python function that takes a list of dictionaries, filters to keep those where 'rank' is <= 23, sorts the kept records by 'rank' in ascending order, and returns a list of the 'name' values in that sorted order. The input list must not be mutated.
[ "Filter the list to keep only records with rank <= 23.", "Sort the filtered list by the 'rank' key in ascending order.", "Extract the 'name' values from the sorted records.", "Return the list of names." ]
def select_names_by_rank_23_ascending(records): kept = [row for row in records if row["rank"] <= 23] kept = sorted(kept, key=lambda row: row["rank"], reverse=False) return [row["name"] for row in kept]
task_code
Write a Python function that takes a list of dictionaries each containing 'label' and 'items', keeps only entries where items is at least 1, and returns a new dictionary mapping each label to the total items for that label. The input list must not be mutated.
[ "Initialize an empty dictionary for totals.", "Iterate over each record: if items >= 1, add items to the total for its label.", "Return the totals dictionary." ]
def total_items_by_label_min_1(records): totals = {} for row in records: if row["items"] >= 1: group = row["label"] totals[group] = totals.get(group, 0) + row["items"] return totals
task_code
Write a Python function that takes a list of dictionaries each containing 'label' and 'items', computes the average items per label, and returns a dictionary mapping each label to its average only if the average is at least 11. The input list must not be mutated.
[ "Initialize two dictionaries: one for total items per label, one for count per label.", "Iterate over each record: add items to the total and increment count for its label.", "Compute average for each label as total divided by count.", "Return a dictionary of labels with average >= 11." ]
def qualifying_items_averages_by_label(records): totals = {} counts = {} for row in records: group = row["label"] totals[group] = totals.get(group, 0) + row["items"] counts[group] = counts.get(group, 0) + 1 return {g: totals[g] / counts[g] for g in totals if totals[g] / counts[g]...
task_code
Write a Python function that takes two equal-length lists of integers, compares each pair using a margin of 89, and returns a dictionary with counts for 'first_ahead' (first minus second > 89), 'second_ahead' (second minus first > 89), and 'within_margin' (otherwise). The input lists must not be mutated.
[ "Initialize counts dictionary with three keys set to 0.", "Iterate over pairs using zip: compute difference.", "If first - second > 89, increment first_ahead; else if second - first > 89, increment second_ahead; else increment within_margin.", "Return the counts dictionary." ]
def compare_pairs_with_margin_89(first, second): counts = {"first_ahead": 0, "second_ahead": 0, "within_margin": 0} for left, right in zip(first, second): if left - right > 89: counts["first_ahead"] += 1 elif right - left > 89: counts["second_ahead"] += 1 else: ...
task_code
Write a Python function that takes a nested list of integers, retains only integers >= 1 within each inner list, adds 12 to each retained integer, and returns a new nested list preserving the original row order. The input must not be mutated.
[ "Create a new empty list for the result.", "For each inner list, create a new list with values >= 1 plus 12.", "Append the transformed inner list to the result.", "Return the result list." ]
def transform_rows_2_12_1(rows): return [[value + 12 for value in row if value >= 1] for row in rows]
task_code
Write a Python function that takes a list of dictionaries each containing 'label' and a list of integer 'values', and returns a list of 'label' values for which the sum of 'values' exceeds 61, preserving original order. The input list must not be mutated.
[ "Initialize an empty result list.", "Iterate over each record: compute sum of its 'values' list.", "If the sum > 61, append the 'label' to the result.", "Return the result list." ]
def labels_over_total_61(records): return [row["label"] for row in records if sum(row["values"]) > 61]
task_code
Write a Python function that takes two dictionaries mapping keys to integer counts, sums the counts over the union of keys (treating missing keys as 0), and returns a new dictionary containing only those keys where the total is at least 11. The input dictionaries must not be mutated.
[ "Create a set of all keys from both dictionaries.", "For each key, compute total = first.get(key, 0) + second.get(key, 0).", "If total >= 11, add key and total to result.", "Return the result dictionary." ]
def combine_label_counts_min_11(first, second): result = {} for key in set(first) | set(second): total = first.get(key, 0) + second.get(key, 0) if total >= 11: result[key] = total return result
task_code
Write a Python function that takes a list of status strings, strips leading/trailing whitespace and converts each complete string to uppercase, then counts how many times each normalized string appears, but only includes those with length at least 6. Return a dictionary mapping each such normalized string to its count....
[ "Initialize an empty dictionary for counts.", "Iterate over each status string: strip whitespace and convert to uppercase.", "If the cleaned string length is >= 6, increment its count in the dictionary.", "Return the dictionary." ]
def count_clean_statuss_upper_6(statuss): counts = {} for status in statuss: cleaned = status.strip().upper() if len(cleaned) >= 6: counts[cleaned] = counts.get(cleaned, 0) + 1 return counts
task_code
Write a Python function that takes a list of dictionaries, each with keys 'rank' and 'identifier'. Keep only records where 'rank' is <= 23, sort the kept records by 'rank' in ascending order, and return a list of the 'identifier' values in that sorted order. Do not mutate the input list.
[ "Filter the list to keep records with rank <= 23.", "Sort the filtered list by rank in ascending order.", "Extract the 'identifier' values from the sorted records.", "Return the list of identifiers." ]
def select_identifiers_by_rank_23_ascending(records): kept = [row for row in records if row["rank"] <= 23] kept = sorted(kept, key=lambda row: row["rank"], reverse=False) return [row["identifier"] for row in kept]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'status' and 'items'. Keep only entries where 'items' is at least 1, then sum the 'items' values grouped by 'status'. Return a dictionary mapping each status to its total items. Do not mutate the input list.
[ "Initialize an empty dictionary for totals.", "Iterate over each record: if items >= 1, add items to the total for its status.", "Return the totals dictionary." ]
def total_items_by_status_min_1(records): totals = {} for row in records: if row["items"] >= 1: group = row["status"] totals[group] = totals.get(group, 0) + row["items"] return totals
task_code
Write a Python function that takes a list of dictionaries, each with keys 'status' and 'items'. Compute the average items per status across all records, then keep only those averages that are at least 11. Return a dictionary mapping each qualifying status to its average. Do not mutate the input list.
[ "Initialize two dictionaries: one for total items per status, one for count per status.", "Iterate over each record: add items to total and increment count for its status.", "Compute average for each status as total / count.", "Return a dictionary of status-average pairs where average >= 11." ]
def qualifying_items_averages_by_status(records): totals = {} counts = {} for row in records: group = row["status"] totals[group] = totals.get(group, 0) + row["items"] counts[group] = counts.get(group, 0) + 1 return {g: totals[g] / counts[g] for g in totals if totals[g] / counts[...
task_code
Write a Python function that takes two equal-length integer lists. Compare each pair of values (one from each list at the same index) using a margin of 90. Count how many pairs have the first value ahead by more than 90, how many have the second value ahead by more than 90, and how many are within the margin (differenc...
[ "Initialize a dictionary with three counters set to 0.", "Iterate over paired elements using zip.", "For each pair, compare left - right: if > 90 increment first_ahead; elif right - left > 90 increment second_ahead; else increment within_margin.", "Return the dictionary." ]
def compare_pairs_with_margin_90(first, second): counts = {"first_ahead": 0, "second_ahead": 0, "within_margin": 0} for left, right in zip(first, second): if left - right > 90: counts["first_ahead"] += 1 elif right - left > 90: counts["second_ahead"] += 1 else: ...
task_code
Write a Python function that takes a nested list of integers. For each inner list, keep only integers that are at least 1 and multiply each retained integer by 13, preserving the order of rows and elements. Return a new nested list. Do not mutate the input.
[ "Initialize an empty result list.", "For each inner list, create a new list: filter values >= 1, then multiply each by 13.", "Append the transformed inner list to the result.", "Return the result." ]
def transform_rows_0_13_1(rows): return [[value * 13 for value in row if value >= 1] for row in rows]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'status' and 'values' (a list of integers). Return a list of 'status' values for which the sum of the integers in 'values' exceeds 61, preserving the original order. Do not mutate the input list.
[ "Initialize an empty result list.", "Iterate over each record: compute sum of its 'values' list.", "If sum > 61, append the 'status' to the result.", "Return the result list." ]
def statuss_over_total_61(records): return [row["status"] for row in records if sum(row["values"]) > 61]
task_code
Write a Python function that takes two dictionaries mapping statuses to integer counts. Sum the counts for each key that appears in either dictionary (using 0 for missing keys), keep only those sums that are at least 11, and return a new dictionary with those key-total pairs. Do not mutate the input dictionaries.
[ "Initialize an empty result dictionary.", "Get the union of keys from both dictionaries.", "For each key, compute total = first.get(key, 0) + second.get(key, 0).", "If total >= 11, add key-total pair to result; return result." ]
def combine_status_counts_min_11(first, second): result = {} for key in set(first) | set(second): total = first.get(key, 0) + second.get(key, 0) if total >= 11: result[key] = total return result
task_code
Write a Python function that takes a list of category strings, strips leading/trailing whitespace and converts each complete string to uppercase, then counts how many times each normalized string appears, but only includes those with length at least 6. Return a dictionary mapping each such normalized string to its coun...
[ "Initialize an empty dictionary for counts.", "Iterate over each category string: strip whitespace and convert to uppercase.", "If the cleaned string length is >= 6, increment its count in the dictionary.", "Return the dictionary." ]
def count_clean_categorys_upper_6(categorys): counts = {} for category in categorys: cleaned = category.strip().upper() if len(cleaned) >= 6: counts[cleaned] = counts.get(cleaned, 0) + 1 return counts
task_code
Write a Python function that takes a list of dictionaries, each with keys 'rank' and 'label'. Keep only records where 'rank' is <= 23, sort the kept records by 'rank' in ascending order, and return a list of the 'label' values in that sorted order. Do not mutate the input list.
[ "Filter the list to keep records with rank <= 23.", "Sort the filtered list by rank in ascending order.", "Extract the 'label' values from the sorted records.", "Return the list of labels." ]
def select_labels_by_rank_23_ascending(records): kept = [row for row in records if row["rank"] <= 23] kept = sorted(kept, key=lambda row: row["rank"], reverse=False) return [row["label"] for row in kept]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'category' and 'items'. Keep only entries where 'items' is at least 1, then sum the 'items' values grouped by 'category'. Return a dictionary mapping each category to its total items. Do not mutate the input list.
[ "Initialize an empty dictionary for totals.", "Iterate over each record: if items >= 1, add items to the total for its category.", "Return the totals dictionary." ]
def total_items_by_category_min_1(records): totals = {} for row in records: if row["items"] >= 1: group = row["category"] totals[group] = totals.get(group, 0) + row["items"] return totals
task_code
Write a Python function that takes a list of dictionaries, each with keys 'category' and 'items'. Compute the average items per category across all records, then keep only those averages that are at least 11. Return a dictionary mapping each qualifying category to its average. Do not mutate the input list.
[ "Initialize two dictionaries: one for total items per category, one for count per category.", "Iterate over each record: add items to total and increment count for its category.", "Compute average for each category as total / count.", "Return a dictionary of category-average pairs where average >= 11." ]
def qualifying_items_averages_by_category(records): totals = {} counts = {} for row in records: group = row["category"] totals[group] = totals.get(group, 0) + row["items"] counts[group] = counts.get(group, 0) + 1 return {g: totals[g] / counts[g] for g in totals if totals[g] / cou...
task_code
Write a Python function that takes two equal-length integer lists. Compare each pair of values (one from each list at the same index) using a margin of 91. Count how many pairs have the first value ahead by more than 91, how many have the second value ahead by more than 91, and how many are within the margin (differenc...
[ "Initialize a dictionary with three counters set to 0.", "Iterate over paired elements using zip.", "For each pair, compare left - right: if > 91 increment first_ahead; elif right - left > 91 increment second_ahead; else increment within_margin.", "Return the dictionary." ]
def compare_pairs_with_margin_91(first, second): counts = {"first_ahead": 0, "second_ahead": 0, "within_margin": 0} for left, right in zip(first, second): if left - right > 91: counts["first_ahead"] += 1 elif right - left > 91: counts["second_ahead"] += 1 else: ...
task_code
Write a Python function that takes a nested list of integers. For each inner list, keep only integers that are greater than 1, preserving the order of rows and elements. Return a new nested list. Do not mutate the input.
[ "Initialize an empty result list.", "For each inner list, create a new list: filter values > 1.", "Append the filtered inner list to the result.", "Return the result." ]
def transform_rows_1_13_1(rows): return [[value for value in row if value > 1] for row in rows]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'category' and 'values' (a list of integers). Return a list of 'category' values for which the sum of the integers in 'values' exceeds 61, preserving the original order. Do not mutate the input list.
[ "Initialize an empty result list.", "Iterate over each record: compute sum of its 'values' list.", "If sum > 61, append the 'category' to the result.", "Return the result list." ]
def categorys_over_total_61(records): return [row["category"] for row in records if sum(row["values"]) > 61]
task_code
Write a Python function that takes two dictionaries mapping categories to integer counts. Sum the counts for each key that appears in either dictionary (using 0 for missing keys), keep only those sums that are at least 11, and return a new dictionary with those key-total pairs. Do not mutate the input dictionaries.
[ "Initialize an empty result dictionary.", "Get the union of keys from both dictionaries.", "For each key, compute total = first.get(key, 0) + second.get(key, 0).", "If total >= 11, add key-total pair to result; return result." ]
def combine_category_counts_min_11(first, second): result = {} for key in set(first) | set(second): total = first.get(key, 0) + second.get(key, 0) if total >= 11: result[key] = total return result
task_code
Write a Python function that takes a list of topic strings, strips leading/trailing whitespace and converts each complete string to uppercase, then counts how many times each normalized string appears, but only includes those with length at least 6. Return a dictionary mapping each such normalized string to its count. ...
[ "Initialize an empty dictionary for counts.", "Iterate over each topic string: strip whitespace and convert to uppercase.", "If the cleaned string length is >= 6, increment its count in the dictionary.", "Return the dictionary." ]
def count_clean_topics_upper_6(topics): counts = {} for topic in topics: cleaned = topic.strip().upper() if len(cleaned) >= 6: counts[cleaned] = counts.get(cleaned, 0) + 1 return counts
task_code
Write a Python function that takes a list of dictionaries, each with keys 'weight' and 'title'. Keep only records where 'weight' is <= 23, sort the kept records by 'weight' in ascending order, and return a list of the 'title' values in that sorted order. Do not mutate the input list.
[ "Filter the list to keep records with weight <= 23.", "Sort the filtered list by weight in ascending order.", "Extract the 'title' values from the sorted records.", "Return the list of titles." ]
def select_titles_by_weight_23_ascending(records): kept = [row for row in records if row["weight"] <= 23] kept = sorted(kept, key=lambda row: row["weight"], reverse=False) return [row["title"] for row in kept]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'topic' and 'items'. Keep only entries where 'items' is at least 1, then sum the 'items' values grouped by 'topic'. Return a dictionary mapping each topic to its total items. Do not mutate the input list.
[ "Initialize an empty dictionary for totals.", "Iterate over each record: if items >= 1, add items to the total for its topic.", "Return the totals dictionary." ]
def total_items_by_topic_min_1(records): totals = {} for row in records: if row["items"] >= 1: group = row["topic"] totals[group] = totals.get(group, 0) + row["items"] return totals
task_code
Write a Python function that takes a list of dictionaries, each with keys 'topic' and 'items'. Compute the average items per topic across all records, then keep only those averages that are at least 11. Return a dictionary mapping each qualifying topic to its average. Do not mutate the input list.
[ "Initialize two dictionaries: one for total items per topic, one for count per topic.", "Iterate over each record: add items to total and increment count for its topic.", "Compute average for each topic as total / count.", "Return a dictionary of topic-average pairs where average >= 11." ]
def qualifying_items_averages_by_topic(records): totals = {} counts = {} for row in records: group = row["topic"] totals[group] = totals.get(group, 0) + row["items"] counts[group] = counts.get(group, 0) + 1 return {g: totals[g] / counts[g] for g in totals if totals[g] / counts[g]...
task_code
Write a Python function that takes two equal-length integer lists. Compare each pair of values (one from each list at the same index) using a margin of 92. Count how many pairs have the first value ahead by more than 92, how many have the second value ahead by more than 92, and how many are within the margin (differenc...
[ "Initialize a dictionary with three counters set to 0.", "Iterate over paired elements using zip.", "For each pair, compare left - right: if > 92 increment first_ahead; elif right - left > 92 increment second_ahead; else increment within_margin.", "Return the dictionary." ]
def compare_pairs_with_margin_92(first, second): counts = {"first_ahead": 0, "second_ahead": 0, "within_margin": 0} for left, right in zip(first, second): if left - right > 92: counts["first_ahead"] += 1 elif right - left > 92: counts["second_ahead"] += 1 else: ...
task_code
Write a Python function that takes a nested list of integers. For each inner list, keep only integers that are at least 1 and add 13 to each retained integer, preserving the order of rows and elements. Return a new nested list. Do not mutate the input.
[ "Initialize an empty result list.", "For each inner list, create a new list: filter values >= 1, then add 13 to each.", "Append the transformed inner list to the result.", "Return the result." ]
def transform_rows_2_13_1(rows): return [[value + 13 for value in row if value >= 1] for row in rows]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'topic' and 'values' (a list of integers). Return a list of 'topic' values for which the sum of the integers in 'values' exceeds 61, preserving the original order. Do not mutate the input list.
[ "Initialize an empty result list.", "Iterate over each record: compute sum of its 'values' list.", "If sum > 61, append the 'topic' to the result.", "Return the result list." ]
def topics_over_total_61(records): return [row["topic"] for row in records if sum(row["values"]) > 61]
task_code
Write a Python function that takes two dictionaries mapping topics to integer counts. Sum the counts for each key that appears in either dictionary (using 0 for missing keys), keep only those sums that are at least 11, and return a new dictionary with those key-total pairs. Do not mutate the input dictionaries.
[ "Initialize an empty result dictionary.", "Get the union of keys from both dictionaries.", "For each key, compute total = first.get(key, 0) + second.get(key, 0).", "If total >= 11, add key-total pair to result; return result." ]
def combine_topic_counts_min_11(first, second): result = {} for key in set(first) | set(second): total = first.get(key, 0) + second.get(key, 0) if total >= 11: result[key] = total return result
task_code
Write a Python function that takes a list of region strings, strips leading/trailing whitespace and converts each complete string to uppercase, then counts how many times each normalized string appears, but only includes those with length at least 6. Return a dictionary mapping each such normalized string to its count....
[ "Initialize an empty dictionary for counts.", "Iterate over each region string: strip whitespace and convert to uppercase.", "If the cleaned string length is >= 6, increment its count in the dictionary.", "Return the dictionary." ]
def count_clean_regions_upper_6(regions): counts = {} for region in regions: cleaned = region.strip().upper() if len(cleaned) >= 6: counts[cleaned] = counts.get(cleaned, 0) + 1 return counts
task_code
Write a Python function that takes a list of dictionaries, each with keys 'weight' and 'name'. Keep only records where 'weight' is <= 23, sort the kept records by 'weight' in ascending order, and return a list of the 'name' values in that sorted order. Do not mutate the input list.
[ "Filter the list to keep records with weight <= 23.", "Sort the filtered list by weight in ascending order.", "Extract the 'name' values from the sorted records.", "Return the list of names." ]
def select_names_by_weight_23_ascending(records): kept = [row for row in records if row["weight"] <= 23] kept = sorted(kept, key=lambda row: row["weight"], reverse=False) return [row["name"] for row in kept]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'region' and 'items'. Keep only entries where 'items' is at least 1, then sum the 'items' values grouped by 'region'. Return a dictionary mapping each region to its total items. Do not mutate the input list.
[ "Initialize an empty dictionary for totals.", "Iterate over each record: if items >= 1, add items to the total for its region.", "Return the totals dictionary." ]
def total_items_by_region_min_1(records): totals = {} for row in records: if row["items"] >= 1: group = row["region"] totals[group] = totals.get(group, 0) + row["items"] return totals
task_code
Write a Python function that takes a list of dictionaries, each with keys 'region' and 'items'. Compute the average items per region across all records, then keep only those averages that are at least 11. Return a dictionary mapping each qualifying region to its average. Do not mutate the input list.
[ "Initialize two dictionaries: one for total items per region, one for count per region.", "Iterate over each record: add items to total and increment count for its region.", "Compute average for each region as total / count.", "Return a dictionary of region-average pairs where average >= 11." ]
def qualifying_items_averages_by_region(records): totals = {} counts = {} for row in records: group = row["region"] totals[group] = totals.get(group, 0) + row["items"] counts[group] = counts.get(group, 0) + 1 return {g: totals[g] / counts[g] for g in totals if totals[g] / counts[...
task_code
Write a Python function that takes two equal-length integer lists. Compare each pair of values (one from each list at the same index) using a margin of 93. Count how many pairs have the first value ahead by more than 93, how many have the second value ahead by more than 93, and how many are within the margin (differenc...
[ "Initialize a dictionary with three counters set to 0.", "Iterate over paired elements using zip.", "For each pair, compare left - right: if > 93 increment first_ahead; elif right - left > 93 increment second_ahead; else increment within_margin.", "Return the dictionary." ]
def compare_pairs_with_margin_93(first, second): counts = {"first_ahead": 0, "second_ahead": 0, "within_margin": 0} for left, right in zip(first, second): if left - right > 93: counts["first_ahead"] += 1 elif right - left > 93: counts["second_ahead"] += 1 else: ...
task_code
Write a Python function that takes a nested list of integers. For each inner list, keep only integers that are at least 1 and multiply each retained integer by 14, preserving the order of rows and elements. Return a new nested list. Do not mutate the input.
[ "Initialize an empty result list.", "For each inner list, create a new list: filter values >= 1, then multiply each by 14.", "Append the transformed inner list to the result.", "Return the result." ]
def transform_rows_0_14_1(rows): return [[value * 14 for value in row if value >= 1] for row in rows]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'region' and 'values' (a list of integers). Return a list of 'region' values for which the sum of the integers in 'values' exceeds 61, preserving the original order. Do not mutate the input list.
[ "Initialize an empty result list.", "Iterate over each record: compute sum of its 'values' list.", "If sum > 61, append the 'region' to the result.", "Return the result list." ]
def regions_over_total_61(records): return [row["region"] for row in records if sum(row["values"]) > 61]
task_code
Write a Python function that takes two dictionaries mapping regions to integer counts. Sum the counts for each key that appears in either dictionary (using 0 for missing keys), keep only those sums that are at least 11, and return a new dictionary with those key-total pairs. Do not mutate the input dictionaries.
[ "Initialize an empty result dictionary.", "Get the union of keys from both dictionaries.", "For each key, compute total = first.get(key, 0) + second.get(key, 0).", "If total >= 11, add key-total pair to result; return result." ]
def combine_region_counts_min_11(first, second): result = {} for key in set(first) | set(second): total = first.get(key, 0) + second.get(key, 0) if total >= 11: result[key] = total return result
task_code
Write a Python function that takes a list of team strings, strips leading/trailing whitespace and converts each complete string to uppercase, then counts how many times each normalized string appears, but only includes those with length at least 6. Return a dictionary mapping each such normalized string to its count. D...
[ "Initialize an empty dictionary for counts.", "Iterate over each team string: strip whitespace and convert to uppercase.", "If the cleaned string length is >= 6, increment its count in the dictionary.", "Return the dictionary." ]
def count_clean_teams_upper_6(teams): counts = {} for team in teams: cleaned = team.strip().upper() if len(cleaned) >= 6: counts[cleaned] = counts.get(cleaned, 0) + 1 return counts
task_code
Write a Python function that takes a list of dictionaries, each with keys 'weight' and 'identifier'. Keep only records where 'weight' is <= 23, sort the kept records by 'weight' in ascending order, and return a list of the 'identifier' values in that sorted order. Do not mutate the input list.
[ "Filter the list to keep records with weight <= 23.", "Sort the filtered list by weight in ascending order.", "Extract the 'identifier' values from the sorted records.", "Return the list of identifiers." ]
def select_identifiers_by_weight_23_ascending(records): kept = [row for row in records if row["weight"] <= 23] kept = sorted(kept, key=lambda row: row["weight"], reverse=False) return [row["identifier"] for row in kept]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'team' and 'items'. Keep only entries where 'items' is at least 1, then sum the 'items' values grouped by 'team'. Return a dictionary mapping each team to its total items. Do not mutate the input list.
[ "Initialize an empty dictionary for totals.", "Iterate over each record: if items >= 1, add items to the total for its team.", "Return the totals dictionary." ]
def total_items_by_team_min_1(records): totals = {} for row in records: if row["items"] >= 1: group = row["team"] totals[group] = totals.get(group, 0) + row["items"] return totals
task_code
Write a Python function that takes a list of dictionaries, each with keys 'team' and 'items'. Compute the average items per team across all records, then keep only those averages that are at least 11. Return a dictionary mapping each qualifying team to its average. Do not mutate the input list.
[ "Initialize two dictionaries: one for total items per team, one for count per team.", "Iterate over each record: add items to total and increment count for its team.", "Compute average for each team as total / count.", "Return a dictionary of team-average pairs where average >= 11." ]
def qualifying_items_averages_by_team(records): totals = {} counts = {} for row in records: group = row["team"] totals[group] = totals.get(group, 0) + row["items"] counts[group] = counts.get(group, 0) + 1 return {g: totals[g] / counts[g] for g in totals if totals[g] / counts[g] >...
task_code
Write a Python function that takes two equal-length integer lists. Compare each pair of values (one from each list at the same index) using a margin of 94. Count how many pairs have the first value ahead by more than 94, how many have the second value ahead by more than 94, and how many are within the margin (differenc...
[ "Initialize a dictionary with three counters set to 0.", "Iterate over paired elements using zip.", "For each pair, compare left - right: if > 94 increment first_ahead; elif right - left > 94 increment second_ahead; else increment within_margin.", "Return the dictionary." ]
def compare_pairs_with_margin_94(first, second): counts = {"first_ahead": 0, "second_ahead": 0, "within_margin": 0} for left, right in zip(first, second): if left - right > 94: counts["first_ahead"] += 1 elif right - left > 94: counts["second_ahead"] += 1 else: ...
task_code
Write a Python function that takes a nested list of integers. For each inner list, keep only integers that are greater than 1, preserving the order of rows and elements. Return a new nested list. Do not mutate the input.
[ "Initialize an empty result list.", "For each inner list, create a new list: filter values > 1.", "Append the filtered inner list to the result.", "Return the result." ]
def transform_rows_1_14_1(rows): return [[value for value in row if value > 1] for row in rows]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'team' and 'values' (a list of integers). Return a list of 'team' values for which the sum of the integers in 'values' exceeds 61, preserving the original order. Do not mutate the input list.
[ "Initialize an empty result list.", "Iterate over each record: compute sum of its 'values' list.", "If sum > 61, append the 'team' to the result.", "Return the result list." ]
def teams_over_total_61(records): return [row["team"] for row in records if sum(row["values"]) > 61]
task_code
Write a Python function that takes two dictionaries mapping teams to integer counts. Sum the counts for each key that appears in either dictionary (using 0 for missing keys), keep only those sums that are at least 11, and return a new dictionary with those key-total pairs. Do not mutate the input dictionaries.
[ "Initialize an empty result dictionary.", "Get the union of keys from both dictionaries.", "For each key, compute total = first.get(key, 0) + second.get(key, 0).", "If total >= 11, add key-total pair to result; return result." ]
def combine_team_counts_min_11(first, second): result = {} for key in set(first) | set(second): total = first.get(key, 0) + second.get(key, 0) if total >= 11: result[key] = total return result
task_code
Write a Python function that takes a list of group strings, strips leading/trailing whitespace and converts each complete string to uppercase, then counts how many times each normalized string appears, but only includes those with length at least 6. Return a dictionary mapping each such normalized string to its count. ...
[ "Initialize an empty dictionary for counts.", "Iterate over each group string: strip whitespace and convert to uppercase.", "If the cleaned string length is >= 6, increment its count in the dictionary.", "Return the dictionary." ]
def count_clean_groups_upper_6(groups): counts = {} for group in groups: cleaned = group.strip().upper() if len(cleaned) >= 6: counts[cleaned] = counts.get(cleaned, 0) + 1 return counts
task_code
Write a Python function that takes a list of dictionaries, each with keys 'weight' and 'label'. Keep only records where 'weight' is <= 23, sort the kept records by 'weight' in ascending order, and return a list of the 'label' values in that sorted order. Do not mutate the input list.
[ "Filter the list to keep records with weight <= 23.", "Sort the filtered list by weight in ascending order.", "Extract the 'label' values from the sorted records.", "Return the list of labels." ]
def select_labels_by_weight_23_ascending(records): kept = [row for row in records if row["weight"] <= 23] kept = sorted(kept, key=lambda row: row["weight"], reverse=False) return [row["label"] for row in kept]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'group' and 'items'. Keep only entries where 'items' is at least 1, then sum the 'items' values grouped by 'group'. Return a dictionary mapping each group to its total items. Do not mutate the input list.
[ "Initialize an empty dictionary for totals.", "Iterate over each record: if items >= 1, add items to the total for its group.", "Return the totals dictionary." ]
def total_items_by_group_min_1(records): totals = {} for row in records: if row["items"] >= 1: group = row["group"] totals[group] = totals.get(group, 0) + row["items"] return totals
task_code
Write a Python function that takes a list of dictionaries, each with keys 'group' and 'items'. Compute the average items per group across all records, then keep only those averages that are at least 11. Return a dictionary mapping each qualifying group to its average. Do not mutate the input list.
[ "Initialize two dictionaries: one for total items per group, one for count per group.", "Iterate over each record: add items to total and increment count for its group.", "Compute average for each group as total / count.", "Return a dictionary of group-average pairs where average >= 11." ]
def qualifying_items_averages_by_group(records): totals = {} counts = {} for row in records: group = row["group"] totals[group] = totals.get(group, 0) + row["items"] counts[group] = counts.get(group, 0) + 1 return {g: totals[g] / counts[g] for g in totals if totals[g] / counts[g]...
task_code
Write a Python function that takes two equal-length integer lists. Compare each pair of values (one from each list at the same index) using a margin of 95. Count how many pairs have the first value ahead by more than 95, how many have the second value ahead by more than 95, and how many are within the margin (differenc...
[ "Initialize a dictionary with three counters set to 0.", "Iterate over paired elements using zip.", "For each pair, compare left - right: if > 95 increment first_ahead; elif right - left > 95 increment second_ahead; else increment within_margin.", "Return the dictionary." ]
def compare_pairs_with_margin_95(first, second): counts = {"first_ahead": 0, "second_ahead": 0, "within_margin": 0} for left, right in zip(first, second): if left - right > 95: counts["first_ahead"] += 1 elif right - left > 95: counts["second_ahead"] += 1 else: ...
task_code
Write a Python function that takes a nested list of integers. For each inner list, keep only integers that are at least 1 and add 14 to each retained integer, preserving the order of rows and elements. Return a new nested list. Do not mutate the input.
[ "Initialize an empty result list.", "For each inner list, create a new list: filter values >= 1, then add 14 to each.", "Append the transformed inner list to the result.", "Return the result." ]
def transform_rows_2_14_1(rows): return [[value + 14 for value in row if value >= 1] for row in rows]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'group' and 'values' (a list of integers). Return a list of 'group' values for which the sum of the integers in 'values' exceeds 61, preserving the original order. Do not mutate the input list.
[ "Initialize an empty result list.", "Iterate over each record: compute sum of its 'values' list.", "If sum > 61, append the 'group' to the result.", "Return the result list." ]
def groups_over_total_61(records): return [row["group"] for row in records if sum(row["values"]) > 61]
task_code
Write a Python function that takes two dictionaries mapping groups to integer counts. Sum the counts for each key that appears in either dictionary (using 0 for missing keys), keep only those sums that are at least 11, and return a new dictionary with those key-total pairs. Do not mutate the input dictionaries.
[ "Initialize an empty result dictionary.", "Get the union of keys from both dictionaries.", "For each key, compute total = first.get(key, 0) + second.get(key, 0).", "If total >= 11, add key-total pair to result; return result." ]
def combine_group_counts_min_11(first, second): result = {} for key in set(first) | set(second): total = first.get(key, 0) + second.get(key, 0) if total >= 11: result[key] = total return result
task_code
Write a Python function that takes a list of tag strings, strips leading/trailing whitespace and converts each to lowercase, then counts how many times each normalized string appears but only includes those whose length is at least 7. Return a dictionary mapping each qualifying normalized string to its count. Do not mu...
[ "Initialize an empty dictionary for counts.", "Iterate over each tag in the input list, strip whitespace and convert to lowercase.", "If the cleaned string has length >= 7, increment its count in the dictionary.", "Return the dictionary." ]
def count_clean_tags_lower_7(tags): counts = {} for tag in tags: cleaned = tag.strip().lower() if len(cleaned) >= 7: counts[cleaned] = counts.get(cleaned, 0) + 1 return counts
task_code
Write a Python function that takes a list of dictionaries, each with keys 'rating' and 'title', filters to keep only those with rating <= 24, sorts the kept records by rating in ascending order, and returns a list of the 'title' values in that sorted order. Do not mutate the input list.
[ "Filter the list to keep records where rating <= 24.", "Sort the filtered list by the 'rating' key in ascending order.", "Extract the 'title' values from the sorted list into a new list.", "Return the list of titles." ]
def select_titles_by_rating_24_ascending(records): kept = [row for row in records if row["rating"] <= 24] kept = sorted(kept, key=lambda row: row["rating"], reverse=False) return [row["title"] for row in kept]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'tag' and 'hours', keeps only entries where hours >= 2, then sums the hours for each distinct tag and returns a dictionary mapping each tag to its total hours. Do not mutate the input list.
[ "Initialize an empty dictionary for totals.", "Iterate over each record, check if hours >= 2.", "If so, add the hours to the total for that tag.", "Return the totals dictionary." ]
def total_hours_by_tag_min_2(records): totals = {} for row in records: if row["hours"] >= 2: group = row["tag"] totals[group] = totals.get(group, 0) + row["hours"] return totals
task_code
Write a Python function that takes a list of dictionaries, each with keys 'tag' and 'hours', computes the average hours per tag across all records, and returns a dictionary mapping each tag to its average only if that average is at least 12. Do not mutate the input list.
[ "Initialize two dictionaries: one for total hours per tag, one for count per tag.", "Iterate over each record, update totals and counts for its tag.", "Compute the average for each tag as total / count.", "Return a dictionary of tags whose average >= 12." ]
def qualifying_hours_averages_by_tag(records): totals = {} counts = {} for row in records: group = row["tag"] totals[group] = totals.get(group, 0) + row["hours"] counts[group] = counts.get(group, 0) + 1 return {g: totals[g] / counts[g] for g in totals if totals[g] / counts[g] >= ...
task_code
Write a Python function that takes two equal-length lists of integers, compares each pair of values (first list element vs second list element) using a margin of 96, and returns a dictionary with keys 'first_ahead', 'second_ahead', and 'within_margin' counting how many pairs fall into each category. Do not mutate the i...
[ "Initialize counts dictionary with three keys set to 0.", "Iterate over paired elements using zip.", "If left - right > 96, increment first_ahead; else if right - left > 96, increment second_ahead; else increment within_margin.", "Return the counts dictionary." ]
def compare_pairs_with_margin_96(first, second): counts = {"first_ahead": 0, "second_ahead": 0, "within_margin": 0} for left, right in zip(first, second): if left - right > 96: counts["first_ahead"] += 1 elif right - left > 96: counts["second_ahead"] += 1 else: ...
task_code
Write a Python function that takes a nested list of integers, and for each inner list, retains only integers that are at least 1 and multiplies each retained integer by 15, preserving the order within each row. Return a new nested list with the transformed rows. Do not mutate the input.
[ "Initialize an empty result list.", "For each inner list, create a new list by filtering values >= 1 and multiplying each by 15.", "Append the transformed inner list to the result.", "Return the result." ]
def transform_rows_0_15_1(rows): return [[value * 15 for value in row if value >= 1] for row in rows]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'tag' and 'values' (where 'values' is a list of integers), and returns a list of the 'tag' values for which the sum of the integers in 'values' exceeds 62, preserving the original order. Do not mutate the input list.
[ "Initialize an empty result list.", "Iterate over each record, compute the sum of its 'values' list.", "If the sum > 62, append the record's 'tag' to the result.", "Return the result list." ]
def tags_over_total_62(records): return [row["tag"] for row in records if sum(row["values"]) > 62]
task_code
Write a Python function that takes two dictionaries mapping keys to integer counts, computes the sum for each key that appears in either dictionary (treating missing keys as 0), and returns a new dictionary containing only those keys whose total sum is at least 12. Do not mutate the input dictionaries.
[ "Create a set of all keys from both dictionaries.", "For each key, compute total = first.get(key, 0) + second.get(key, 0).", "If total >= 12, add the key-value pair to the result dictionary.", "Return the result dictionary." ]
def combine_tag_counts_min_12(first, second): result = {} for key in set(first) | set(second): total = first.get(key, 0) + second.get(key, 0) if total >= 12: result[key] = total return result
task_code
Write a Python function that takes a list of label strings, strips leading/trailing whitespace and converts each to lowercase, then counts how many times each normalized string appears but only includes those whose length is at least 7. Return a dictionary mapping each qualifying normalized string to its count. Do not ...
[ "Initialize an empty dictionary for counts.", "Iterate over each label, strip whitespace and convert to lowercase.", "If the cleaned string has length >= 7, increment its count in the dictionary.", "Return the dictionary." ]
def count_clean_labels_lower_7(labels): counts = {} for label in labels: cleaned = label.strip().lower() if len(cleaned) >= 7: counts[cleaned] = counts.get(cleaned, 0) + 1 return counts
task_code
Write a Python function that takes a list of dictionaries, each with keys 'rating' and 'name', filters to keep only those with rating <= 24, sorts the kept records by rating in ascending order, and returns a list of the 'name' values in that sorted order. Do not mutate the input list.
[ "Filter the list to keep records where rating <= 24.", "Sort the filtered list by the 'rating' key in ascending order.", "Extract the 'name' values from the sorted list into a new list.", "Return the list of names." ]
def select_names_by_rating_24_ascending(records): kept = [row for row in records if row["rating"] <= 24] kept = sorted(kept, key=lambda row: row["rating"], reverse=False) return [row["name"] for row in kept]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'label' and 'hours', keeps only entries where hours >= 2, then sums the hours for each distinct label and returns a dictionary mapping each label to its total hours. Do not mutate the input list.
[ "Initialize an empty dictionary for totals.", "Iterate over each record, check if hours >= 2.", "If so, add the hours to the total for that label.", "Return the totals dictionary." ]
def total_hours_by_label_min_2(records): totals = {} for row in records: if row["hours"] >= 2: group = row["label"] totals[group] = totals.get(group, 0) + row["hours"] return totals
task_code
Write a Python function that takes a list of dictionaries, each with keys 'label' and 'hours', computes the average hours per label across all records, and returns a dictionary mapping each label to its average only if that average is at least 12. Do not mutate the input list.
[ "Initialize two dictionaries: one for total hours per label, one for count per label.", "Iterate over each record, update totals and counts for its label.", "Compute the average for each label as total / count.", "Return a dictionary of labels whose average >= 12." ]
def qualifying_hours_averages_by_label(records): totals = {} counts = {} for row in records: group = row["label"] totals[group] = totals.get(group, 0) + row["hours"] counts[group] = counts.get(group, 0) + 1 return {g: totals[g] / counts[g] for g in totals if totals[g] / counts[g]...
task_code
Write a Python function that takes two equal-length lists of integers, compares each pair of values using a margin of 97, and returns a dictionary with keys 'first_ahead', 'second_ahead', and 'within_margin' counting how many pairs fall into each category. Do not mutate the input lists.
[ "Initialize counts dictionary with three keys set to 0.", "Iterate over paired elements using zip.", "If left - right > 97, increment first_ahead; else if right - left > 97, increment second_ahead; else increment within_margin.", "Return the counts dictionary." ]
def compare_pairs_with_margin_97(first, second): counts = {"first_ahead": 0, "second_ahead": 0, "within_margin": 0} for left, right in zip(first, second): if left - right > 97: counts["first_ahead"] += 1 elif right - left > 97: counts["second_ahead"] += 1 else: ...
task_code
Write a Python function that takes a nested list of integers, and for each inner list, retains only integers that are greater than 1, preserving the order within each row. Return a new nested list with the filtered rows. Do not mutate the input.
[ "Initialize an empty result list.", "For each inner list, create a new list by filtering values > 1.", "Append the filtered inner list to the result.", "Return the result." ]
def transform_rows_1_15_1(rows): return [[value for value in row if value > 1] for row in rows]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'label' and 'values' (where 'values' is a list of integers), and returns a list of the 'label' values for which the sum of the integers in 'values' exceeds 62, preserving the original order. Do not mutate the input list.
[ "Initialize an empty result list.", "Iterate over each record, compute the sum of its 'values' list.", "If the sum > 62, append the record's 'label' to the result.", "Return the result list." ]
def labels_over_total_62(records): return [row["label"] for row in records if sum(row["values"]) > 62]
task_code
Write a Python function that takes two dictionaries mapping keys to integer counts, computes the sum for each key that appears in either dictionary (treating missing keys as 0), and returns a new dictionary containing only those keys whose total sum is at least 12. Do not mutate the input dictionaries.
[ "Create a set of all keys from both dictionaries.", "For each key, compute total = first.get(key, 0) + second.get(key, 0).", "If total >= 12, add the key-value pair to the result dictionary.", "Return the result dictionary." ]
def combine_label_counts_min_12(first, second): result = {} for key in set(first) | set(second): total = first.get(key, 0) + second.get(key, 0) if total >= 12: result[key] = total return result
task_code
Write a Python function that takes a list of status strings, strips leading/trailing whitespace and converts each to lowercase, then counts how many times each normalized string appears but only includes those whose length is at least 7. Return a dictionary mapping each qualifying normalized string to its count. Do not...
[ "Initialize an empty dictionary for counts.", "Iterate over each status, strip whitespace and convert to lowercase.", "If the cleaned string has length >= 7, increment its count in the dictionary.", "Return the dictionary." ]
def count_clean_statuss_lower_7(statuss): counts = {} for status in statuss: cleaned = status.strip().lower() if len(cleaned) >= 7: counts[cleaned] = counts.get(cleaned, 0) + 1 return counts
task_code
Write a Python function that takes a list of dictionaries, each with keys 'rating' and 'identifier', filters to keep only those with rating <= 24, sorts the kept records by rating in ascending order, and returns a list of the 'identifier' values in that sorted order. Do not mutate the input list.
[ "Filter the list to keep records where rating <= 24.", "Sort the filtered list by the 'rating' key in ascending order.", "Extract the 'identifier' values from the sorted list into a new list.", "Return the list of identifiers." ]
def select_identifiers_by_rating_24_ascending(records): kept = [row for row in records if row["rating"] <= 24] kept = sorted(kept, key=lambda row: row["rating"], reverse=False) return [row["identifier"] for row in kept]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'status' and 'hours', keeps only entries where hours >= 2, then sums the hours for each distinct status and returns a dictionary mapping each status to its total hours. Do not mutate the input list.
[ "Initialize an empty dictionary for totals.", "Iterate over each record, check if hours >= 2.", "If so, add the hours to the total for that status.", "Return the totals dictionary." ]
def total_hours_by_status_min_2(records): totals = {} for row in records: if row["hours"] >= 2: group = row["status"] totals[group] = totals.get(group, 0) + row["hours"] return totals
task_code
Write a Python function that takes a list of dictionaries, each with keys 'status' and 'hours', computes the average hours per status across all records, and returns a dictionary mapping each status to its average only if that average is at least 12. Do not mutate the input list.
[ "Initialize two dictionaries: one for total hours per status, one for count per status.", "Iterate over each record, update totals and counts for its status.", "Compute the average for each status as total / count.", "Return a dictionary of statuses whose average >= 12." ]
def qualifying_hours_averages_by_status(records): totals = {} counts = {} for row in records: group = row["status"] totals[group] = totals.get(group, 0) + row["hours"] counts[group] = counts.get(group, 0) + 1 return {g: totals[g] / counts[g] for g in totals if totals[g] / counts[...
task_code
Write a Python function that takes two equal-length lists of integers, compares each pair of values using a margin of 98, and returns a dictionary with keys 'first_ahead', 'second_ahead', and 'within_margin' counting how many pairs fall into each category. Do not mutate the input lists.
[ "Initialize counts dictionary with three keys set to 0.", "Iterate over paired elements using zip.", "If left - right > 98, increment first_ahead; else if right - left > 98, increment second_ahead; else increment within_margin.", "Return the counts dictionary." ]
def compare_pairs_with_margin_98(first, second): counts = {"first_ahead": 0, "second_ahead": 0, "within_margin": 0} for left, right in zip(first, second): if left - right > 98: counts["first_ahead"] += 1 elif right - left > 98: counts["second_ahead"] += 1 else: ...
task_code
Write a Python function that takes a nested list of integers, and for each inner list, retains only integers that are at least 1 and adds 15 to each retained integer, preserving the order within each row. Return a new nested list with the transformed rows. Do not mutate the input.
[ "Initialize an empty result list.", "For each inner list, create a new list by filtering values >= 1 and adding 15 to each.", "Append the transformed inner list to the result.", "Return the result." ]
def transform_rows_2_15_1(rows): return [[value + 15 for value in row if value >= 1] for row in rows]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'status' and 'values' (where 'values' is a list of integers), and returns a list of the 'status' values for which the sum of the integers in 'values' exceeds 62, preserving the original order. Do not mutate the input list.
[ "Initialize an empty result list.", "Iterate over each record, compute the sum of its 'values' list.", "If the sum > 62, append the record's 'status' to the result.", "Return the result list." ]
def statuss_over_total_62(records): return [row["status"] for row in records if sum(row["values"]) > 62]
task_code
Write a Python function that takes two dictionaries mapping keys to integer counts, computes the sum for each key that appears in either dictionary (treating missing keys as 0), and returns a new dictionary containing only those keys whose total sum is at least 12. Do not mutate the input dictionaries.
[ "Create a set of all keys from both dictionaries.", "For each key, compute total = first.get(key, 0) + second.get(key, 0).", "If total >= 12, add the key-value pair to the result dictionary.", "Return the result dictionary." ]
def combine_status_counts_min_12(first, second): result = {} for key in set(first) | set(second): total = first.get(key, 0) + second.get(key, 0) if total >= 12: result[key] = total return result
task_code
Write a Python function that takes a list of category strings, strips leading/trailing whitespace and converts each to lowercase, then counts how many times each normalized string appears but only includes those whose length is at least 7. Return a dictionary mapping each qualifying normalized string to its count. Do n...
[ "Initialize an empty dictionary for counts.", "Iterate over each category, strip whitespace and convert to lowercase.", "If the cleaned string has length >= 7, increment its count in the dictionary.", "Return the dictionary." ]
def count_clean_categorys_lower_7(categorys): counts = {} for category in categorys: cleaned = category.strip().lower() if len(cleaned) >= 7: counts[cleaned] = counts.get(cleaned, 0) + 1 return counts
task_code
Write a Python function that takes a list of dictionaries, each with keys 'rating' and 'label', filters to keep only those with rating <= 24, sorts the kept records by rating in ascending order, and returns a list of the 'label' values in that sorted order. Do not mutate the input list.
[ "Filter the list to keep records where rating <= 24.", "Sort the filtered list by the 'rating' key in ascending order.", "Extract the 'label' values from the sorted list into a new list.", "Return the list of labels." ]
def select_labels_by_rating_24_ascending(records): kept = [row for row in records if row["rating"] <= 24] kept = sorted(kept, key=lambda row: row["rating"], reverse=False) return [row["label"] for row in kept]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'category' and 'hours', keeps only entries where hours >= 2, then sums the hours for each distinct category and returns a dictionary mapping each category to its total hours. Do not mutate the input list.
[ "Initialize an empty dictionary for totals.", "Iterate over each record, check if hours >= 2.", "If so, add the hours to the total for that category.", "Return the totals dictionary." ]
def total_hours_by_category_min_2(records): totals = {} for row in records: if row["hours"] >= 2: group = row["category"] totals[group] = totals.get(group, 0) + row["hours"] return totals
task_code
Write a Python function that takes a list of dictionaries, each with keys 'category' and 'hours', computes the average hours per category across all records, and returns a dictionary mapping each category to its average only if that average is at least 12. Do not mutate the input list.
[ "Initialize two dictionaries: one for total hours per category, one for count per category.", "Iterate over each record, update totals and counts for its category.", "Compute the average for each category as total / count.", "Return a dictionary of categories whose average >= 12." ]
def qualifying_hours_averages_by_category(records): totals = {} counts = {} for row in records: group = row["category"] totals[group] = totals.get(group, 0) + row["hours"] counts[group] = counts.get(group, 0) + 1 return {g: totals[g] / counts[g] for g in totals if totals[g] / cou...
task_code
Write a Python function that takes two equal-length lists of integers, compares each pair of values using a margin of 99, and returns a dictionary with keys 'first_ahead', 'second_ahead', and 'within_margin' counting how many pairs fall into each category. Do not mutate the input lists.
[ "Initialize counts dictionary with three keys set to 0.", "Iterate over paired elements using zip.", "If left - right > 99, increment first_ahead; else if right - left > 99, increment second_ahead; else increment within_margin.", "Return the counts dictionary." ]
def compare_pairs_with_margin_99(first, second): counts = {"first_ahead": 0, "second_ahead": 0, "within_margin": 0} for left, right in zip(first, second): if left - right > 99: counts["first_ahead"] += 1 elif right - left > 99: counts["second_ahead"] += 1 else: ...
task_code
Write a Python function that takes a nested list of integers, and for each inner list, retains only integers that are at least 1 and multiplies each retained integer by 16, preserving the order within each row. Return a new nested list with the transformed rows. Do not mutate the input.
[ "Initialize an empty result list.", "For each inner list, create a new list by filtering values >= 1 and multiplying each by 16.", "Append the transformed inner list to the result.", "Return the result." ]
def transform_rows_0_16_1(rows): return [[value * 16 for value in row if value >= 1] for row in rows]
task_code
Write a Python function that takes a list of dictionaries, each with keys 'category' and 'values' (where 'values' is a list of integers), and returns a list of the 'category' values for which the sum of the integers in 'values' exceeds 62, preserving the original order. Do not mutate the input list.
[ "Initialize an empty result list.", "Iterate over each record, compute the sum of its 'values' list.", "If the sum > 62, append the record's 'category' to the result.", "Return the result list." ]
def categorys_over_total_62(records): return [row["category"] for row in records if sum(row["values"]) > 62]
task_code
Write a Python function that takes two dictionaries mapping keys to integer counts, computes the sum for each key that appears in either dictionary (treating missing keys as 0), and returns a new dictionary containing only those keys whose total sum is at least 12. Do not mutate the input dictionaries.
[ "Create a set of all keys from both dictionaries.", "For each key, compute total = first.get(key, 0) + second.get(key, 0).", "If total >= 12, add the key-value pair to the result dictionary.", "Return the result dictionary." ]
def combine_category_counts_min_12(first, second): result = {} for key in set(first) | set(second): total = first.get(key, 0) + second.get(key, 0) if total >= 12: result[key] = total return result