Tuples-HackerRank Solution
Task
Given an integer,n ,n and space-separated integers as input, create a tuple,t , of those integers. Then compute and print the result of hash(t).
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, n, denoting the number of elements in the tuple.
The second line contains n space-separated integers describing the elements in tuple t.
Output Format
Print the result of hash(t).
Sample Input 0
2
1 2
Sample Output 0
3713081631934410656
Tuples solution
if __name__ == '__main__':
n = int(input())
integer_list = map(int, input().split())
t=tuple(integer_list) #convert the input into tuple
print(hash(t)) #print the hash value of the object
To read on hash follow this link-https://www.programiz.com/python-programming/methods/built-in/hash

0 comments:
Post a Comment
Feel free to share your thoughts and suggestion...