aboutsummaryrefslogtreecommitdiff
path: root/challenge-059
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-059')
-rw-r--r--challenge-059/shawak/README.md6
-rw-r--r--challenge-059/shawak/ruby/ch-02.rb7
2 files changed, 13 insertions, 0 deletions
diff --git a/challenge-059/shawak/README.md b/challenge-059/shawak/README.md
new file mode 100644
index 0000000000..e511d1c9b6
--- /dev/null
+++ b/challenge-059/shawak/README.md
@@ -0,0 +1,6 @@
+Solution by Shawak
+
+```bash
+echo "2,3,4" | ruby ch-02.rb
+```
+
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]
+ }
+}