shortened C++ version with /u/bugrit's help

see: http://www.reddit.com/r/programming/comments/2btrvt/gal/cj93awc
Merge pull request #88 from panzi/master

shortened C++ version with /u/bugrit's help