I was pleased with my Ruby solution to the problem of finding the last ten digits of the sum of 1 + 22 + 33 + … + 10001000

puts ((1..1000).inject(0) {|sum, n| sum += n**n}).to_s[-10,10]

until I saw this Haskell solution:

main = print $ sum ([n^n | n <- [1..1000]]) `mod` 10^10

I’m still finding it easier to think in Ruby, but Haskell is so much cleaner, especially for numerical problems.