numpy solution