Skip to content
Back to skills

Find Shortest Dictionary Key Combination Covering Target Set

ASecurity

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.

  • 17 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added May 30, 2026
developmentpythongoperformance

Security analysis

A100/100

Scanned May 30, 2026

npx -y skills add gabrielmoreira/agent-skills-mirror --skill find-shortest-dictionary-key-combination-covering-target-set --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Find Shortest Dictionary Key Combination Covering Target Set?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Find Shortest Dictionary Key Combination Covering Target Set
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrielmoreira-find-shortest-dictionary-key-combination-covering-/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-find-shortest-dictionary-key-combination-covering-)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "b85e8991-41fd-40e3-a762-5f7140239826"
name: "Find Shortest Dictionary Key Combination Covering Target Set"
description: "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."
version: "0.1.0"
tags:
  - "python"
  - "optimization"
  - "algorithm"
  - "set-cover"
  - "dictionary"
triggers:
  - "optimize dictionary combination code"
  - "shortest key combination for target"
  - "find minimum keys covering set"
  - "python set cover optimization"
  - "fix slow combination code"
---

# 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

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.