From 0d01f67611f47df33dced823eb50a8a5e231dc8f Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Wed, 6 May 2020 12:23:58 +0100 Subject: - Added Ruby solution by Shawak. --- challenge-059/shawak/ruby/ch-02.rb | 7 ------- challenge-059/shawak/ruby/ch-2.rb | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) delete mode 100644 challenge-059/shawak/ruby/ch-02.rb create mode 100644 challenge-059/shawak/ruby/ch-2.rb (limited to 'challenge-059') diff --git a/challenge-059/shawak/ruby/ch-02.rb b/challenge-059/shawak/ruby/ch-02.rb deleted file mode 100644 index c0eb71a461..0000000000 --- a/challenge-059/shawak/ruby/ch-02.rb +++ /dev/null @@ -1,7 +0,0 @@ -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] - } -} diff --git a/challenge-059/shawak/ruby/ch-2.rb b/challenge-059/shawak/ruby/ch-2.rb new file mode 100644 index 0000000000..c0eb71a461 --- /dev/null +++ b/challenge-059/shawak/ruby/ch-2.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] + } +} -- cgit