P81, P83, P85: Tweaked Java solutions.
P82: Simplified Java solution.