• + 0 comments

    The issue in the problem arises because Python 3.3 and above introduced hash randomization for security, which means the hash() of the same tuple can vary between runs and machines, whereas in Python 2 the hash() output for the same tuple is fixed and predictable. The HackerRank problem expects a specific deterministic hash value (3713081631934410656) for the tuple (1, 2), which aligns with Python 2 behavior. Therefore, running the code in Python 3 on your machine gives a different result because of the randomization, but switching to Python 2, where hash() is consistent, produces the expected output and passes the judge. This is why using Python 2 helps solve the problem correctly.

    This is my code and if you are using it too change the python 3 to python2 first from the menu above the shell

    if __name__ == '__main__':
        n = int(raw_input())
        integer_list = map(int, raw_input().split())
        t = tuple(integer_list)
        print hash(t)