Asteroid is 1.4×10^12 kilograms, a number I googled for a 1 kilometer asteroid. In order to push it’s impact probability down acceptably, a 1 cm/second change in velocity is needed. (I read that in a wired magazine article as being enough)
Nuclear pulse charge + small thrusters for guidance is assumed to be 300 kilograms, with a 150 kiloton yield. ISP is assumed to be 7500. (10k-20k from a paper on Project Orion, reducing it because you need a guidance system)
So how many nukes do you need?
(1.4×10^12)(0.01) = (7500*9.8)(300)(n)
n = 634. So 300 kilograms * 634 = 190,200 kilograms must reach the asteroid.
Falcon heavy stated payload to mars is 16,800. So you need 11 launches to do it.
Of course, you need to actually develop those nuclear pulse charges. Maybe you can’t get a really efficient one in the time you have and you need 10 times as many inefficient ones. Not all the rockets will make it. You may need a lot more dV than a “mere” mars injection in order to reach the asteroid in time. All these push the numbers into the less favorable territory, but it feels like it might work from this napkin analysis.
Bigger asteroids - 10 kilometer spheres - yeah, it’s not good. 1000 times the mass, this problem becomes 1000 times harder. Now you would need to hope you can eject craters in it, which in turn means it better be made of the right kind of material for that.