A contractible space has no higher homology groups, so your example doesn't work. A working example would be $X=\mathbb CP^2$ and $Y=S^2\vee S^4$. They have the same homology, but are not homotopy equivalent. One way of seeing this, is looking at the cohomology.