From 3943d0c8f249c5eb068d6079a9bed87d4f03c532 Mon Sep 17 00:00:00 2001 From: booboy Date: Mon, 6 May 2019 23:41:08 -0500 Subject: [PATCH] added a boolean algebra file --- algorithms/lib/algorithms.rb | 1 + algorithms/lib/algorithms/boolean_algebra.rb | 21 ++++++++++++++++++++ algorithms/lib/algorithms/sorting.rb | 10 +++++----- 3 files changed, 27 insertions(+), 5 deletions(-) create mode 100644 algorithms/lib/algorithms/boolean_algebra.rb diff --git a/algorithms/lib/algorithms.rb b/algorithms/lib/algorithms.rb index 3ac1a5f..b2e14fc 100644 --- a/algorithms/lib/algorithms.rb +++ b/algorithms/lib/algorithms.rb @@ -1,5 +1,6 @@ require "algorithms/version" require "algorithms/sorting" +require "algorithms/boolean_algebra" module Algorithms class Error < StandardError; end diff --git a/algorithms/lib/algorithms/boolean_algebra.rb b/algorithms/lib/algorithms/boolean_algebra.rb new file mode 100644 index 0000000..c2692a1 --- /dev/null +++ b/algorithms/lib/algorithms/boolean_algebra.rb @@ -0,0 +1,21 @@ +module Algorithms + class BooleanAlgebra + def multiplication_table +<<-TABLE +0.0 = 0 +0.1 = 0 +1.0 = 0 +1.1 = 1 +TABLE + end + + def addition_table +<<-TABLE +0+0 = 0 +0+1 = 1 +1+0 = 1 +1+1 = 1 +TABLE + end + end +end \ No newline at end of file diff --git a/algorithms/lib/algorithms/sorting.rb b/algorithms/lib/algorithms/sorting.rb index b0ba266..446839f 100644 --- a/algorithms/lib/algorithms/sorting.rb +++ b/algorithms/lib/algorithms/sorting.rb @@ -9,13 +9,13 @@ module Algorithms # Step 4 − Increment MIN to point to next element # Step 5 − Repeat until list is sorted - a.each_with_index do |value, index| - # set minimum to location - min = a[index] - + counter = 0 + max = a.length + a.map do |item| + #binding.pry + counter += 1 end - end end