3 ms·
x = File.read('puzle.txt') y = x.split(/ \w /) module Enumerable def dups inject({}) {|h,v| h[v]=h[v].to_i+1; h}.reject{|k,v| v==1}.keys end
by y0ghur7_xxx 16y ago
x = File.read('puzle.txt')
y = x.split(/ \w /)
module Enumerable
def dups
inject({}) {|h,v| h[v]=h[v].to_i+1; h}.reject{|k,v| v==1}.keys
end
end
d = y.dups
require 'mathn'
dp = []
d.each {|z| z = z.to_i; dp << z if z.prime?}
dp