diff options
| author | Lubos Kolouch <lubos@kolouch.net> | 2020-11-15 09:16:45 +0100 |
|---|---|---|
| committer | Lubos Kolouch <lubos@kolouch.net> | 2020-11-15 09:16:45 +0100 |
| commit | c832f51587b689fc12ee0a5943d581b095a6dabf (patch) | |
| tree | 0d246b1e450b2cdd88f526f9d3ea29df6acf5224 /challenge-086/lubos-kolouch/python | |
| parent | 4c31310c2fcdcc28b67276d0d5a90fdf820d8b48 (diff) | |
| download | perlweeklychallenge-club-c832f51587b689fc12ee0a5943d581b095a6dabf.tar.gz perlweeklychallenge-club-c832f51587b689fc12ee0a5943d581b095a6dabf.tar.bz2 perlweeklychallenge-club-c832f51587b689fc12ee0a5943d581b095a6dabf.zip | |
Task 1 Challenge 086 LK refactor
Diffstat (limited to 'challenge-086/lubos-kolouch/python')
| -rw-r--r-- | challenge-086/lubos-kolouch/python/ch-1.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/challenge-086/lubos-kolouch/python/ch-1.py b/challenge-086/lubos-kolouch/python/ch-1.py index 0f284bf4c6..ffeda9b648 100644 --- a/challenge-086/lubos-kolouch/python/ch-1.py +++ b/challenge-086/lubos-kolouch/python/ch-1.py @@ -20,16 +20,14 @@ def is_pair_difference(n: list, a: int): """ # to avoid sorting and/or scanning through all pairs in the array # or double nested loop, - # I will convert the array to a hash, then check if the - # corresponding key exists + # I will convert the array to a hash and check it on the fly """ hash_keys = {} for number in n: hash_keys[number] = 1 - for x in hash_keys: - if hash_keys.get(x+a, 0): + if hash_keys.get(number+a, 0) or hash_keys.get(number-a, 0): return 1 return 0 |
