diff options
| author | Mohammad S Anwar <Mohammad.Anwar@yahoo.com> | 2020-11-16 03:26:47 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-16 03:26:47 +0000 |
| commit | 9dfcdcf810ef634ee2a420daaa7c2b7c55d34120 (patch) | |
| tree | cc212831c7b3eaf40594b5e5bc64058ab9ae420b /challenge-086/lubos-kolouch/python/ch-1.py | |
| parent | 2f3baa0b9579f9ff1724721173eff8139c9016ee (diff) | |
| parent | 511eb99576ca0a476fb3a06aad049929ba04f601 (diff) | |
| download | perlweeklychallenge-club-9dfcdcf810ef634ee2a420daaa7c2b7c55d34120.tar.gz perlweeklychallenge-club-9dfcdcf810ef634ee2a420daaa7c2b7c55d34120.tar.bz2 perlweeklychallenge-club-9dfcdcf810ef634ee2a420daaa7c2b7c55d34120.zip | |
Merge pull request #2767 from LubosKolouch/master
Solutions task 1 Perl Python LK - refactor
Diffstat (limited to 'challenge-086/lubos-kolouch/python/ch-1.py')
| -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 |
