Sponsor

HackerRank Tuples problem solution in python | python Question Solution



 Task

Given an integer, , and  space-separated integers as input, create a tuple, , of those  integers. Then compute and print the result of .

Note: hash() is one of the functions in the __builtins__ module, so it need not be imported.

Input Format

The first line contains an integer, , denoting the number of elements in the tuple.
The second line contains  space-separated integers describing the elements in tuple .

Output Format

Print the result of .

Sample Input 0

2
1 2

Sample Output 0

3713081631934410656

Problem solution in Python 2 programming.

n=int(input())
a=tuple(map(int,raw_input().split()))
print hash(a)

Problem solution in Python 3 programming.

if __name__ == '__main__':
    n = int(input())
    integer_list = map(int, input().split())
    tup = ()
    for x in integer_list:
        tup+=(x,)
    
    print(hash(tup))


Problem solution in pypy programming.

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


Problem solution in pypy3 programming.

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



Post a Comment

0 Comments