Skip to content

Commit 6394bdf

Browse files
authored
Merge pull request #734 from sir-gon/develop
[REFACTOR] sonarcloud fixes.
2 parents becf99d + 9d69cf1 commit 6394bdf

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy