Last active
December 15, 2015 13:39
-
-
Save coderaven/5268829 to your computer and use it in GitHub Desktop.
Project Euler Problem 42 Solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'open-uri' | |
(o = "\n") && ( puts "There are a total of %s " % (open('http://projecteuler.net/project/words.txt', 'r'){ |f| IO.readlines(f).to_s.gsub(/\"|\\|\[|\]/,"").split(",").inject(0){|t,s| (z =( Math.sqrt(8 * (c = s.split(//).inject(0){|n,l| n+(l.ord-64)}) +1)-1)/2) % 1==0 ? (t+1 if ((o = o + "#{t+1}.#{s} (#{c},#{z.to_i})\n") || true) ) : t}}.to_s + "triangle words:" + o) ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment