Skip to content

Commit d7b52a0

Browse files
author
aaditya
committed
convert camelCase fucntion defination into function defination seperated by underscore
1 parent 0e726f4 commit d7b52a0

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

algorithms/dynamic_programming/bit_masking1.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def __init__(self):
2525
self.caps = defaultdict(list)
2626

2727
# Mask is the set of persons, i is the current cap number.
28-
def countWaysUtil(self, dp, mask, cap_no):
28+
def count_ways_util(self, dp, mask, cap_no):
2929

3030
# If all persons are wearing a cap so we
3131
# are done and this is one way so return 1
@@ -43,7 +43,7 @@ def countWaysUtil(self, dp, mask, cap_no):
4343

4444
# Ways, when we don't include this cap in our arrangement
4545
# or solution set
46-
ways = self.countWaysUtil(dp, mask, cap_no + 1)
46+
ways = self.count_ways_util(dp, mask, cap_no + 1)
4747

4848
# assign ith cap one by one to all the possible persons
4949
# and recur for remaining caps.
@@ -57,7 +57,7 @@ def countWaysUtil(self, dp, mask, cap_no):
5757

5858
# Else assign him this cap and recur for remaining caps with
5959
# new updated mask vector
60-
ways += self.countWaysUtil(dp, mask | (1 << ppl), cap_no + 1)
60+
ways += self.count_ways_util(dp, mask | (1 << ppl), cap_no + 1)
6161

6262
ways = ways % (10**9 + 7)
6363

@@ -66,7 +66,7 @@ def countWaysUtil(self, dp, mask, cap_no):
6666

6767
return dp[mask][cap_no]
6868

69-
def countWays(self, N):
69+
def count_ways(self, N):
7070

7171
# Reads n lines from standard input for current test case
7272
# create dictionary for cap. cap[i] = list of person having
@@ -88,12 +88,12 @@ def countWays(self, N):
8888

8989
# Call recursive function countWaysUtil
9090
# result will be in dp[0][1]
91-
print(self.countWaysUtil(dp, 0, 1,))
91+
print(self.count_ways_util(dp, 0, 1,))
9292

9393
# Driver Program
9494

9595

9696
def main():
9797
No_of_people = int(input()) # number of persons in every test case
9898

99-
AssignCap().countWays(No_of_people)
99+
AssignCap().count_ways(No_of_people)

algorithms/dynamic_programming/k_palindrome1.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
# is K-Palindrome or not
2020

2121

22-
def isKPalRec(str1, str2, m, n):
22+
def is_kpalrec(str1, str2, m, n):
2323

2424
# If first string is empty,
2525
# the only option is to remove
@@ -43,23 +43,23 @@ def isKPalRec(str1, str2, m, n):
4343
# 1. Remove last char from str1 and recur for m-1 and n
4444
# 2. Remove last char from str2 and recur for m and n-1
4545
# Take minimum of above two operations
46-
res = 1 + min(isKPalRec(str1, str2, m - 1, n), # Remove from str1
47-
(isKPalRec(str1, str2, m, n - 1))) # Remove from str2
46+
res = 1 + min(is_kpalrec(str1, str2, m - 1, n), # Remove from str1
47+
(is_kpalrec(str1, str2, m, n - 1))) # Remove from str2
4848

4949
return res
5050

5151
# Returns true if str is k palindrome.
5252

5353

54-
def isKPal(string, k):
54+
def is_kPal(string, k):
5555
revStr = string[::-1]
5656
l = len(string)
5757

58-
return (isKPalRec(string, revStr, l, l) <= k * 2)
58+
return (is_kpalrec(string, revStr, l, l) <= k * 2)
5959

6060

6161
# Driver program
6262
string = "acdcb"
6363
k = 2
6464

65-
print("Yes" if isKPal(string, k) else "No")
65+
print("Yes" if is_kPal(string, k) else "No")

0 commit comments

Comments
 (0)