Sort by

recency

|

1739 Discussions

|

  • + 0 comments

    if name == 'main': n = int(input()) string_list=input().split() int_list=[int(string_list[i]) for i in range(n)] t=tuple(int_list) print(hash(t)) One who is wondering use of n variable, it can be used as above for string to int conversion.

  • + 0 comments

    if name == 'main': n = int(input()) integer_list = map(int, input().split())

    t = tuple(integer_list)
    print(hash(t))
    
        #this worked for me
    
  • + 0 comments

    I don't know how to pass this test.... this is my code:

    n = int(input())
    numbers = input().split()
    t = tuple(int(x) for x in numbers[:n])
    
    print(hash(t))
    
    #i conseder myself succeeded in this test, i dont care
    
  • + 0 comments

    While this problem provides n as input, it's not actually needed in the solution. This longer version of the code is provided as an alternative for programmers who aren't yet comfortable using map() and prefer a more step-by-step approach.

    if name == 'main':

    n = int(input()) 
    
    numbers = input().split() 
    
    int_list = []
    
    for num in numbers:
    
        int_list.append(int(num))
    
    t = tuple(int_list)
    
    print(hash(t))
    
  • + 1 comment

    HackerRank relies on Pypy and its hash() algorithm. You should've mentioned it in the problem facts. Either adapt your Python environment to use its own hash() or state this in the problem ducuments. Lots of time wasted on a technical mistake!!