Skip to content

Commit 9d69cf1

Browse files
author
Gonzalo Diaz
committed
[REFACTOR] sonarcloud fixes.
1 parent becf99d commit 9d69cf1

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/hackerrank/interview_preparation_kit/dictionaries_and_hashmaps/sherlock_and_anagrams.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ def sherlockAndAnagrams(s_word: str) -> int:
3434
total: int = 0
3535
q_candidates = 0
3636
# Final Anagram list
37-
for word in list(candidates):
38-
quantity_of_anagrams = len(candidates[word])
37+
38+
for word, candidates_of in candidates.items():
39+
quantity_of_anagrams = len(candidates_of)
3940
k = 2
4041

41-
if quantity_of_anagrams <= 1:
42-
del candidates[word]
43-
else:
42+
if quantity_of_anagrams > 1:
4443
# Binomial coefficient: https://en.wikipedia.org/wiki/Binomial_coefficient
4544
q_candidates += quantity_of_anagrams
4645

src/hackerrank/interview_preparation_kit/search/swap_nodes_algo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def buildTree(indexes: List[List[int]]) -> Node:
7979
__INITIAL_LEVEL__,
8080
callbackCollectNodes)
8181

82-
last_level: int = sorted(list(node_collector))[-1]
82+
last_level: int = sorted(node_collector)[-1]
8383

8484
for i in range(0, min(len(indexes_copy), len(node_collector[last_level]))):
8585
current_node: Node = node_collector[last_level][i]

src/projecteuler/helpers/word_score.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
def wordScore(word: str) -> int:
3232
result = 0
3333

34-
for letter in list(word):
34+
for letter in word:
3535
if letter in _scoreLetter:
3636
result += _scoreLetter[letter]
3737

0 commit comments

Comments
 (0)