Skip to content

Conversation

@AliAlimohammadi
Copy link
Contributor

Description

Adds implementation of the Task Assignment Problem using bitmasking and dynamic programming.

Problem Statement

Given:

  • N tasks to be performed
  • M people who can perform tasks
  • Each person can perform only certain tasks
  • Each person can perform at most one task
  • Each task can be performed by at most one person

Find the total number of valid task assignments where all people are assigned tasks.

Algorithm

  • Uses bitmasking to represent which people have been assigned tasks
  • Uses dynamic programming to cache subproblem results
  • Recursively tries assigning each task to capable people

Complexity

  • Time: O(2^M * N) where M is number of people, N is number of tasks
  • Space: O(2^M * N) for the DP table

Example

let task_performed = vec![vec![1, 3, 4], vec![1, 2, 5], vec![3, 4]];
let total_tasks = 5;
let ways = count_task_assignments(task_performed, total_tasks);
// Returns: 10 valid assignments

Checklist

  • Code follows Rust style guidelines (rustfmt)
  • No clippy warnings
  • All tests pass
  • Added comprehensive test cases
  • Documentation is complete
  • Updated DIRECTORY.md
  • Updated mod.rs

@codecov-commenter
Copy link

codecov-commenter commented Nov 26, 2025

Codecov Report

❌ Patch coverage is 98.07692% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.45%. Comparing base (1ce9f3a) to head (98ca061).

Files with missing lines Patch % Lines
src/dynamic_programming/task_assignment.rs 98.07% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #958   +/-   ##
=======================================
  Coverage   95.44%   95.45%           
=======================================
  Files         333      334    +1     
  Lines       21524    21576   +52     
=======================================
+ Hits        20544    20595   +51     
- Misses        980      981    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AliAlimohammadi
Copy link
Contributor Author

@siriak, This is ready to merge.

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@siriak siriak merged commit eaf895d into TheAlgorithms:master Nov 30, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants