T09 · Insecure Skill Coding Practices
- Location
scripts/optimizer.py:62- Finding
Unbounded Combinatorial Search Enables Resource Exhaustion
- Content
View full analysis
best_val: best_val = total best_plan = [(tier, list(team))] + rest_plan memo[avail_fs] = (best_val, best_plan) return (best_val, best_plan) return solve(frozenset(range(n))) ``` ```python def optimize(players, tiers=None, max_stars=MAX_STARS): if tiers is None: tiers = DEFAULT_TIERS[:] tiers_desc = sorted(set(tiers), reverse=True) stars = [p["stars"] for p in players] n = len(players) # Optimal plan if n <= 35: best_val, best_plan = _solve_optimal(stars, tiers_desc, n) else: best_val, best_plan = _solve_greedy(stars, tiers_desc, n) ``` ```python def main(): if len(sys.argv) > 1: with open(sys.argv[1], "r", encoding="utf-8") as f: data = json.load(f) else: data = json.load(sys.stdin) players = data.get("players", data if isinstance(data, list) else []) tiers = data.get("tiers", DEFAULT_TIERS) max_stars = data.get ...[truncated 3030 chars]- Remediation
View remediation
