summaryrefslogtreecommitdiff
path: root/joint-set
diff options
context:
space:
mode:
authorpks <pks@macbook.local>2020-02-19 16:19:09 +0100
committerpks <pks@macbook.local>2020-02-19 16:19:09 +0100
commit8c1c7c21f16e5800d615130831a8932a5d2b2bd2 (patch)
tree5bbae3e11b810dac500631e01342b8d15b1e92b5 /joint-set
parent4bb4c4b4e35d00a4a8e96a3f1de4301f481b9cc6 (diff)
misc. scripts
Diffstat (limited to 'joint-set')
-rwxr-xr-xjoint-set30
1 files changed, 30 insertions, 0 deletions
diff --git a/joint-set b/joint-set
new file mode 100755
index 0000000..b9b9b22
--- /dev/null
+++ b/joint-set
@@ -0,0 +1,30 @@
+#!/usr/bin/env ruby
+
+require 'set'
+require 'zipf'
+
+n = ARGV.pop.to_i
+
+all = []
+all_sets = []
+ARGV.each { |file|
+ fp = ReadFile.new file
+ a = []
+ s = Set.new
+ while line = fp.gets
+ a << line
+ s << line
+ end
+ all << a
+ all_sets << s
+}
+
+joint_set = all_sets.pop
+all_sets.each { |set|
+ joint_set &= set
+}
+
+joint_set.each { |i|
+ puts i
+}
+