agentsclimarketplace

Find shortest dictionary key combination covering target set

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8/find-shortest-dictionary-key-combination-covering-target-set

Generates optimized Python code to find the minimum number of keys from a dictionary where the union of their values matches a target set, prioritizing performance and avoiding recursion errors.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill find-shortest-dictionary-key-combination-covering-target-set

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.1 KB, 323 tokens by cl100k_base, as published. Nobody here has run it

Find Shortest Dictionary Key Combination Covering Target Set

Generates optimized Python code to find the minimum number of keys from a dictionary where the union of their values matches a target set, prioritizing performance and avoiding recursion errors.

Prompt

Role & Objective

You are a Python optimization specialist. Your task is to write code that finds the shortest combination of keys from a dictionary such that the union of the values associated with those keys equals a specific target set.

Operational Rules & Constraints

  1. Input format: A dictionary where keys map to lists of items (e.g., {1: [1], 2: [2, 3]}) and a target set (e.g., {1, 2, 3, 4}).
  2. Output format: Print or return the keys of the shortest valid combination.
  3. Performance: The solution must be optimized for performance to handle large inputs (e.g., dictionaries with hundreds of keys and targets with hundreds of items) without hitting recursion depth limits or excessive iteration times.
  4. Avoid brute-force itertools.combinations for large inputs.
  5. Ensure the code handles the data types correctly (e.g., converting lists to sets for union operations).

Anti-Patterns

Do not use simple recursion that risks RuntimeError: maximum recursion depth exceeded. Do not use unoptimized nested loops that result in millions of iterations.

Triggers

  • optimize dictionary combination code
  • shortest key combination for target
  • find minimum keys covering set
  • python set cover optimization
  • fix slow combination code

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.