diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-05-06 12:23:58 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2020-05-06 12:23:58 +0100 |
| commit | 0d01f67611f47df33dced823eb50a8a5e231dc8f (patch) | |
| tree | e14d7debd65dd64d0153dc790c829ce6656fa34c /challenge-059/shawak/ruby/ch-2.rb | |
| parent | 5be10a5a5d7d477e15d3869fbed2b767495bccb0 (diff) | |
| download | perlweeklychallenge-club-0d01f67611f47df33dced823eb50a8a5e231dc8f.tar.gz perlweeklychallenge-club-0d01f67611f47df33dced823eb50a8a5e231dc8f.tar.bz2 perlweeklychallenge-club-0d01f67611f47df33dced823eb50a8a5e231dc8f.zip | |
- Added Ruby solution by Shawak.
Diffstat (limited to 'challenge-059/shawak/ruby/ch-2.rb')
| -rw-r--r-- | challenge-059/shawak/ruby/ch-2.rb | 7 |
1 files changed, 7 insertions, 0 deletions
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] + } +} |
