MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / __init__

Method __init__

dynamic_programming/bitmask.py:16–29  ·  view source on GitHub ↗
(self, task_performed, total)

Source from the content-addressed store, hash-verified

14
15class AssignmentUsingBitmask:
16 def __init__(self, task_performed, total):
17 self.total_tasks = total # total no of tasks (N)
18
19 # DP table will have a dimension of (2^M)*N
20 # initially all values are set to -1
21 self.dp = [
22 [-1 for i in range(total + 1)] for j in range(2 ** len(task_performed))
23 ]
24
25 self.task = defaultdict(list) # stores the list of persons for each task
26
27 # final_mask is used to check if all persons are included by setting all bits
28 # to 1
29 self.final_mask = (1 << len(task_performed)) - 1
30
31 def count_ways_until(self, mask, task_no):
32 # if mask == self.finalmask all persons are distributed tasks, return 1

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected