added a boolean algebra file
This commit is contained in:
parent
8891f1c975
commit
3943d0c8f2
3 changed files with 27 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
||||||
require "algorithms/version"
|
require "algorithms/version"
|
||||||
require "algorithms/sorting"
|
require "algorithms/sorting"
|
||||||
|
require "algorithms/boolean_algebra"
|
||||||
|
|
||||||
module Algorithms
|
module Algorithms
|
||||||
class Error < StandardError; end
|
class Error < StandardError; end
|
||||||
|
|
21
algorithms/lib/algorithms/boolean_algebra.rb
Normal file
21
algorithms/lib/algorithms/boolean_algebra.rb
Normal file
|
@ -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
|
|
@ -9,13 +9,13 @@ module Algorithms
|
||||||
# Step 4 − Increment MIN to point to next element
|
# Step 4 − Increment MIN to point to next element
|
||||||
# Step 5 − Repeat until list is sorted
|
# Step 5 − Repeat until list is sorted
|
||||||
|
|
||||||
a.each_with_index do |value, index|
|
counter = 0
|
||||||
# set minimum to location
|
max = a.length
|
||||||
min = a[index]
|
|
||||||
|
|
||||||
|
|
||||||
|
a.map do |item|
|
||||||
|
#binding.pry
|
||||||
|
counter += 1
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue