Problem Link: http://www.spoj.com/problems/INTEST6

from sys import stdin
import numpy as np
t, k = map(int, stdin.readline().split())
data = np.loadtxt(stdin, dtype='int')
out = 0
for i in xrange(t):
	if not data[i] % k:
		out += 1
print out

I thought(read) numpy is fast when in comes to loading data from files, is it true? am I doing something wrong?
there are solutions close to 1s, can you give me a hint about how it is done?
thanks..

  • created

    Dec '14
  • last reply

    Dec '14
  • 1

    reply

  • 645

    views

  • 2

    users

  • 1

    link

Without NumPy at all.

Pure PyPy: 1.06s.
PyPy+NumPy: 0.39s.

Edit:
The point is not to read faster but to take advantage of numpy arrays speed.