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 .
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
Tuples - Hacker Rank Solution
hash()
is one of the functions in __builtins__
module, so we just need to create a tuple of the elements and then pass it to the function.
Problem Tester's code:
n = raw_input()
print hash(tuple([int(i) for i in raw_input().split()]))
if __name__ == '__main__':
ReplyDeleten = int(raw_input())
integer_list = map(int, raw_input().split())
t=tuple(integer_list)
print(hash(t))
it worked but i still don't understand how ,how do we get this output
Deleteif __name__ == '__main__':
Deleten = int(raw_input())
integer_list = map(int, raw_input().split())
t=tuple(integer_list)
print(hash(t))
Correct code
Deleteits wrong, no loop has been used
ReplyDeleteno need of loop while using map
DeleteIt is wrong
ReplyDeleteI tried this:
ReplyDeleten = int(raw_input())
a = tuple(map(int, raw_input().split('')))
print hash(a)
#this code is working try this
ReplyDeleten = int(input())
b=input()
a = tuple(map(int, b.split(' ')))
print(hash(a))
yes this code working try this first
Deleteit is working good
Deleteit is working ty
Deletenah dude it's not working it's giving answer in negativity and value is also little bit different
Deleten = int(input())
ReplyDeleteb=input()
a = tuple(map(int, b.split(' ')))
if len(a) == n:
print(hash(a))
else:
print('you have exceeded your limit')
TRY THIS OUT!
n = int(input())
ReplyDeleteb=input()
a = tuple(map(int, b.split(' ')))
if len(a) == n:
print(hash(a))
else:
print('you have exceeded your limit')
TRY THIS OUT
Best Solution is:
ReplyDeleteif __name__ == '__main__':
n = int(input())
integer_list = tuple(map(int, input().split()))
print(hash(integer_list))
n = int(input())
ReplyDeleteinteger_list = map(int, input().split())
t=tuple(integer_list)
print(hash(t))
Even this worked well!
if __name__ == '__main__':
ReplyDeleten = int(input())
integer_list = tuple(map(int, input().split()))
print(hash(integer_list))
n = int(input())
ReplyDeleteb=input()
a = tuple(map(int, b.split(' ')))
print(hash(a))
n=int(input())
ReplyDeletex=(map(int,input().split()))
z = tuple(x)
print(hash(z))
# best practices
No matter which code you try, the tuple value is coming the same and not matching with hacker-rank predefined output. I tried the below code, still not working.
ReplyDeleten = int(input())
inp = input().split()
m = tuple(map(int,inp))
print(hash(m))
Bro I used your code using language Pypy 3 and it worked fine for me.
Deletebrah it's not working
Deleteinfact not a single code is working i had tried dozens
n = int(input())
integer_list = map(int, input().split())
t = tuple(integer_list)
print(hash(t))
this one is also not working