aboutsummaryrefslogtreecommitdiff
path: root/challenge-059/shawak/ruby
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-059/shawak/ruby')
-rw-r--r--challenge-059/shawak/ruby/ch-02.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/challenge-059/shawak/ruby/ch-02.rb b/challenge-059/shawak/ruby/ch-02.rb
new file mode 100644
index 0000000000..c0eb71a461
--- /dev/null
+++ b/challenge-059/shawak/ruby/ch-02.rb
@@ -0,0 +1,7 @@
+a=gets.split(',').map &:to_i
+a=a.combination(2).map{|a,b| [a.to_s(2), b.to_s(2)]}
+puts a.sum{|a,b|
+ ([a.size, b.size].max-1).downto(0).count {|i|
+ a[i] == b[i] || !a[i] || !b[i]
+ }
+}