solved problem025 in haskell, cleaned up java code