mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 09:21:13 +08:00
Add pep8-naming to pre-commit hooks and fixes incorrect naming conventions (#7062)
* ci(pre-commit): Add pep8-naming to `pre-commit` hooks (#7038) * refactor: Fix naming conventions (#7038) * Update arithmetic_analysis/lu_decomposition.py Co-authored-by: Christian Clauss <cclauss@me.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * refactor(lu_decomposition): Replace `NDArray` with `ArrayLike` (#7038) * chore: Fix naming conventions in doctests (#7038) * fix: Temporarily disable project euler problem 104 (#7069) * chore: Fix naming conventions in doctests (#7038) Co-authored-by: Christian Clauss <cclauss@me.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -28,7 +28,7 @@ class AssignmentUsingBitmask:
|
||||
# to 1
|
||||
self.final_mask = (1 << len(task_performed)) - 1
|
||||
|
||||
def CountWaysUtil(self, mask, task_no):
|
||||
def count_ways_until(self, mask, task_no):
|
||||
|
||||
# if mask == self.finalmask all persons are distributed tasks, return 1
|
||||
if mask == self.final_mask:
|
||||
@ -43,7 +43,7 @@ class AssignmentUsingBitmask:
|
||||
return self.dp[mask][task_no]
|
||||
|
||||
# Number of ways when we don't this task in the arrangement
|
||||
total_ways_util = self.CountWaysUtil(mask, task_no + 1)
|
||||
total_ways_util = self.count_ways_until(mask, task_no + 1)
|
||||
|
||||
# now assign the tasks one by one to all possible persons and recursively
|
||||
# assign for the remaining tasks.
|
||||
@ -56,14 +56,14 @@ class AssignmentUsingBitmask:
|
||||
|
||||
# assign this task to p and change the mask value. And recursively
|
||||
# assign tasks with the new mask value.
|
||||
total_ways_util += self.CountWaysUtil(mask | (1 << p), task_no + 1)
|
||||
total_ways_util += self.count_ways_until(mask | (1 << p), task_no + 1)
|
||||
|
||||
# save the value.
|
||||
self.dp[mask][task_no] = total_ways_util
|
||||
|
||||
return self.dp[mask][task_no]
|
||||
|
||||
def countNoOfWays(self, task_performed):
|
||||
def count_no_of_ways(self, task_performed):
|
||||
|
||||
# Store the list of persons for each task
|
||||
for i in range(len(task_performed)):
|
||||
@ -71,7 +71,7 @@ class AssignmentUsingBitmask:
|
||||
self.task[j].append(i)
|
||||
|
||||
# call the function to fill the DP table, final answer is stored in dp[0][1]
|
||||
return self.CountWaysUtil(0, 1)
|
||||
return self.count_ways_until(0, 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@ -81,7 +81,7 @@ if __name__ == "__main__":
|
||||
# the list of tasks that can be done by M persons.
|
||||
task_performed = [[1, 3, 4], [1, 2, 5], [3, 4]]
|
||||
print(
|
||||
AssignmentUsingBitmask(task_performed, total_tasks).countNoOfWays(
|
||||
AssignmentUsingBitmask(task_performed, total_tasks).count_no_of_ways(
|
||||
task_performed
|
||||
)
|
||||
)
|
||||
|
Reference in New Issue
Block a user