Skip to content

Commit a5b56bb

Browse files
committed
changed casing
1 parent 246f527 commit a5b56bb

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

algorithms/dynamic_programming/partition_sum.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33

44
# Returns true if arr[] can be partitioned
55
# in two subsets of equal sum, otherwise false
6-
def findPartiion(arr, n) :
7-
Sum = 0
6+
def find_partiion(arr, n) :
7+
sum = 0
88

99
# Calculate sum of all elements
1010
for i in range(n) :
11-
Sum += arr[i]
12-
if (Sum % 2 != 0) :
11+
sum += arr[i]
12+
if (sum % 2 != 0) :
1313
return 0
14-
part = [0] * ((Sum // 2) + 1)
14+
part = [0] * ((sum // 2) + 1)
1515

1616
# Initialize the part array as 0
17-
for i in range((Sum // 2) + 1) :
17+
for i in range((sum // 2) + 1) :
1818
part[i] = 0
1919

2020
# Fill the partition table in bottom up manner
@@ -23,7 +23,7 @@ def findPartiion(arr, n) :
2323
# the element to be included
2424
# in the sum cannot be
2525
# greater than the sum
26-
for j in range(Sum // 2, arr[i] - 1, -1) :
26+
for j in range(sum // 2, arr[i] - 1, -1) :
2727

2828
# check if sum - arr[i]
2929
# could be formed
@@ -33,14 +33,14 @@ def findPartiion(arr, n) :
3333
if (part[j - arr[i]] == 1 or j == arr[i]) :
3434
part[j] = 1
3535

36-
return part[Sum // 2]
36+
return part[sum // 2]
3737

3838
# Drive code
3939
arr = [ 1, 3, 3, 2, 3, 2 ]
4040
n = len(arr)
4141

4242
# Function call
43-
if (findPartiion(arr, n) == 1) :
43+
if (find_partiion(arr, n) == 1) :
4444
print("Can be divided into two subsets of equal sum")
4545
else :
4646
print("Can not be divided into two subsets of equal sum")

0 commit comments

Comments
 (0)