[Python] Hash function in Python is not giving the answer I want [duplicate]

Discussão em 'Python' iniciado por Stack, Agosto 11, 2025.

  1. Stack

    Stack Membro Participativo

    I am practising Python questions on HackerRank. Here's the question.

    This is my solution:

    if __name__ == '__main__':
    n = int(input())
    i = tuple(map(int,input().split()))
    print(hash(i))



    Desired Output is

    3713081631934410656


    However, the output I get is

    -3550055125485641917


    Why is that the case?

    Someone tested my code, and it gave them the desired code. I tried copying and pasting my code again. Still didn't work.

    [​IMG]

    Edit


    It started working. I had to select Pypy3 (shoutout Bereal). Also, big ups to Chepner for pointing out Python3 Hash functionality.

    Continue reading...

Compartilhe esta Página