They already did invent a pill for that. It's called Modafinil and I use it. Basically, it allows you to sleep for 2-3 hours and you will wake up fully refreshed like you had a full nights sleep.
It's also an antidepressant and mood/memory enhancer, it makes you more intelligent too. Plus, it has been used by people trying to quit smoking/drugs, or lose weight.
There's been controversy from parents, basically saying that when this shit is everywhere, say a decade from now, they're worried that their kids will fall behind if they don't give them the pill. One guy I heard of, went round a few universities in the UK a few weeks before finals, and made $6,000 profit from selling it to students, cos it really works. Particularly on the side of your brain that deals with maths and problems, it works wonders.
The US and British armies give them to the troops in Iraq. In a test, it was noted that a helicopter pilot have improved responses when he had not slept in 48 hours and was on the medication, compared to when he was not on the medication and had a full nights sleep.
One time, we were playing at a big music festival and I decided I wasn't going to sleep that night. Everyone else crashed out a 3am, so I took the pill at 3am too. When literally thousands of people at this festival were all asleep, circa 5am or so, I was still dancing in a muddy field (with my earphones on, all the live music was finished at that point). We went home and everyone else was still so knackered that they went to bed to sleep it off - I however had a fully functional day.
It was developed as a cure for narcolepsy (involuntarily falling asleep) and works by blocking the sensors that make you feel tired. However, if you decide to sleep it won't affect you - but like I said, you can get 2 hours and feel like you got 8. Oh yeah, and it's neuroprotective too. That means it protects your brain from developing degenerative conditions like Alzheimers and Parkinsons.