12345678910111213141516171819 |
- #!/usr/bin/ruby
- # Daniel "Trizen" Șuteu
- # License: GPLv3
- # https://github.com/trizen
- # https://projecteuler.net/problem=42
- # Runtime: 0.653s
- var words = eval('[' + %f'p042_words.txt'.read + ']')
- var dict = Hash()
- dict{('A'..'Z')...} = (1..26)...
- say words.count { |word|
- 8*word.chars.map{ dict{_} }.sum + 1 -> is_square
- }
|