Fix indentation contains tabs (flake8 E101,W191) (#1573)

This commit is contained in:
Christian Clauss
2019-11-16 08:05:00 +01:00
committed by John Law
parent dbaedd4ed7
commit b838f1042c
15 changed files with 217 additions and 217 deletions

View File

@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
"""
In this problem, we want to determine all possible combinations of k
numbers out of 1 ... n. We use backtracking to solve this problem.
Time complexity: O(C(n,k)) which is O(n choose k) = O((n!/(k! * (n - k)!)))
In this problem, we want to determine all possible combinations of k
numbers out of 1 ... n. We use backtracking to solve this problem.
Time complexity: O(C(n,k)) which is O(n choose k) = O((n!/(k! * (n - k)!)))
"""

View File

@@ -1,9 +1,9 @@
"""
In this problem, we want to determine all possible permutations
of the given sequence. We use backtracking to solve this problem.
In this problem, we want to determine all possible permutations
of the given sequence. We use backtracking to solve this problem.
Time complexity: O(n! * n),
where n denotes the length of the given sequence.
Time complexity: O(n! * n),
where n denotes the length of the given sequence.
"""
@@ -13,10 +13,10 @@ def generate_all_permutations(sequence):
def create_state_space_tree(sequence, current_sequence, index, index_used):
"""
Creates a state space tree to iterate through each branch using DFS.
We know that each state has exactly len(sequence) - index children.
It terminates when it reaches the end of the given sequence.
"""
Creates a state space tree to iterate through each branch using DFS.
We know that each state has exactly len(sequence) - index children.
It terminates when it reaches the end of the given sequence.
"""
if index == len(sequence):
print(current_sequence)
@@ -32,7 +32,7 @@ def create_state_space_tree(sequence, current_sequence, index, index_used):
"""
remove the comment to take an input from the user
remove the comment to take an input from the user
print("Enter the elements")
sequence = list(map(int, input().split()))

View File

@@ -1,9 +1,9 @@
"""
In this problem, we want to determine all possible subsequences
of the given sequence. We use backtracking to solve this problem.
In this problem, we want to determine all possible subsequences
of the given sequence. We use backtracking to solve this problem.
Time complexity: O(2^n),
where n denotes the length of the given sequence.
Time complexity: O(2^n),
where n denotes the length of the given sequence.
"""
@@ -13,10 +13,10 @@ def generate_all_subsequences(sequence):
def create_state_space_tree(sequence, current_subsequence, index):
"""
Creates a state space tree to iterate through each branch using DFS.
We know that each state has exactly two children.
It terminates when it reaches the end of the given sequence.
"""
Creates a state space tree to iterate through each branch using DFS.
We know that each state has exactly two children.
It terminates when it reaches the end of the given sequence.
"""
if index == len(sequence):
print(current_subsequence)
@@ -29,7 +29,7 @@ def create_state_space_tree(sequence, current_subsequence, index):
"""
remove the comment to take an input from the user
remove the comment to take an input from the user
print("Enter the elements")
sequence = list(map(int, input().split()))

View File

@@ -1,9 +1,9 @@
"""
The sum-of-subsetsproblem states that a set of non-negative integers, and a value M,
determine all possible subsets of the given set whose summation sum equal to given M.
The sum-of-subsetsproblem states that a set of non-negative integers, and a value M,
determine all possible subsets of the given set whose summation sum equal to given M.
Summation of the chosen numbers must be equal to given number M and one number can
be used only once.
Summation of the chosen numbers must be equal to given number M and one number can
be used only once.
"""
@@ -18,12 +18,12 @@ def generate_sum_of_subsets_soln(nums, max_sum):
def create_state_space_tree(nums, max_sum, num_index, path, result, remaining_nums_sum):
"""
Creates a state space tree to iterate through each branch using DFS.
It terminates the branching of a node when any of the two conditions
given below satisfy.
This algorithm follows depth-fist-search and backtracks when the node is not branchable.
Creates a state space tree to iterate through each branch using DFS.
It terminates the branching of a node when any of the two conditions
given below satisfy.
This algorithm follows depth-fist-search and backtracks when the node is not branchable.
"""
"""
if sum(path) > max_sum or (remaining_nums_sum + sum(path)) < max_sum:
return
if sum(path) == max_sum:
@@ -41,7 +41,7 @@ def create_state_space_tree(nums, max_sum, num_index, path, result, remaining_nu
"""
remove the comment to take an input from the user
remove the comment to take an input from the user
print("Enter the elements")
nums = list(map(int, input().split()))