Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Некорректные условия/решение в задаче count_pair_with_difference_equal_to_k #1062

Closed
irka1804 opened this issue Nov 15, 2023 · 0 comments

Comments

@irka1804
Copy link

решение бота на Python

from typing import List, Dict
from itertools import combinations as combi
def solution(pairs: List[int], k: int) -> int:
    count = 0
    bahan = pairs
    com = list(combi(bahan,2))
    olah = list(set(com))
    for x in olah:
        seli = x[0] - x[1]
        # print(f"{x[0]}-{x[1]} = {seli}, abs {abs(seli)}")
        if abs(seli) == k:
             count += 1
    # print(com)
    # print(count)
    return count

ответ чувствителен к порядку - об этом в условиях ни слова
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant