Because I haven't done Groovy for a while. I miss it!
(0..999).each { def square = String.valueOf(it*it) def len = square.length() square = len % 2 != 0 ? "0$square" : square square = square.replaceAll(/.*0+$/,'') len = square.length() def half = Integer.valueOf((len / 2).toString()) def side1 = square.substring(0, half) def side2 = square.substring(half) if (side1 && side2 && Integer.valueOf(side1) + Integer.valueOf(side2) == it) { println it } }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Because I haven't done Groovy for a while. I miss it!