Jump to content

Ormiston triples: Difference between revisions

→‎{{header|Ruby}}: anagram, not palindrome.
(→‎{{header|Ruby}}: anagram, not palindrome.)
Line 2,122:
require 'prime'
 
def all_palinall_anagram?(arr)
sorted = arr.first.digits.sort
arr[1..].all?{|a| a.digits.sort == sorted}
end
 
res = Prime.each.each_cons(3).lazy.filter_map{|ar| ar.first if all_palinall_anagram?(ar)}.first(25)
res.each_slice(5){|slice| puts slice.join(", ")}
 
n = 1E9
res = Prime.each(n).each_cons(3).count {|ar| all_palinall_anagram?(ar)}
puts "\nThere are #{res} Ormiston triples below #{n}"
</syntaxhighlight>
1,149

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.