Ever wonder how much coffee you should you drink to function on, say, 5 hours of sleep? You might not need to play the guessing game much longer because the US Army says it's got it all figured out.

Soldiers often go extended periods of time with little or no sleep and rely on coffee to help keep them alert in situations that require high levels of performance. The military already has guidelines around how much caffeine soldiers should consume when they're running on empty, but a new algorithm developed by US Army Medical Research and Materiel Command can make dosing suggestions that are much more specific.

"If you could come to work, drink caffeine and have your mental acuity improved by 40 percent for four hours, wouldn't you like that?" Dr. Jaques Reifman - who helped develop the new algorithm - explained to The Wall Street Journal. "That's what we're trying to do here."

The algorithm was developed by analyzing decades worth of sleep deprivation research. It works by evaluating how much sleep and caffeine a person has already had and suggests how much caffeine a person should consume throughout the day and when they should take it.

"We can do simulations of thousands of combinations of when and how much caffeine to give," Reifman said. "Then we pick the best solution."

And the Army is working on bringing their algorithm to everyday people, too. A smartphone app is currently in development which would be able to learn your on specific caffeine needs over time and work to find a dosing schedule that works best for you. While the app is still a few months out, you can check out a simplified version of the system over at 2B Alert.

And while we might soon be able to know exactly how to overcome a sleepless night with a few cups of coffee, you should probably still try to get your 8 hours.

Cannabis for Beginners - What is an indica?