weissman writeup with Java solution