Execution time using time.time() in Python -


i wrote code hackerrank problem (https://www.hackerrank.com/challenges/acm-icpc-team).

import time itertools import combinations  start_time = time.time()  n,m = raw_input().strip().split(' ') # n = no of people , m = no of topics n,m = [int(n),int(m)] topic = [] topic_i = 0 topic_i in xrange(n):    topic_t = str(raw_input().strip())    topic.append(topic_t)    # populate topic[] list topics  counts = [] list1, list2 in combinations(topic, 2):    if list1 != list2:       count = 0       in xrange(m):         if int(list1[i]) | int(list2[i]):             count += 1       counts.append(count)  print max(counts) print counts.count(max(counts))  print time.time() - start_time 

when try run code, execution time of 8.37576699257 seconds. program got on in jiffy. have read timeit() function, default, runs function passed million times. similar happen here?

you counted time when program waited user input too. may want move first time.time() invocation below raw_input().


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -