This code is only marginally tested. I've passed a couple hundred Account IDs and Contact IDs through the function and so far everything has matched, but this is hardly rigorous.
This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.
- Allen Freeman