Sort by

recency

|

1821 Discussions

|

  • + 0 comments

    I had to switch the language to python 2 and use raw_input() instead of input() to get it to work. It seems that the hash function works differently in python 3 than it did in python 2, which is likely the version of python this challenge was written for. HackerRank really needs to update this challenge for python 3!

    This is my python 2 code I used:

    # read the count (not really used except to know how many)
    n = int(raw_input())
    
    # read the line of numbers as text, split on spaces, map to int, pack into a tuple
    elements = tuple(map(int, raw_input().split()))
    
    # compute and print the hash
    print hash(elements)
    

    compute and print the hash

    print hash(elements)

  • + 0 comments

    Here is - Javascript project for students

  • + 0 comments

    For some reason, Python 3 throws wrong answer. It generates correct answer with Python 2.
    if name == 'main':
    n = int(input())
    t = tuple(map(int, input().split()))
    print(hash(t))

    our Output (stdout)
    -3550055125485641917 `

  • + 1 comment

    I Didn't understand how to use the hash() please explain

  • + 0 comments

    if your using the python 2 then use this code

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

    in python 2 to take the input we need to use the raw_input()