Top Level Namespace
Instance Method Summary collapse
Instance Method Details
#bools! ⇒ Object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/bools.rb', line 1 def bools! vars = method(:test).arity cols = vars.times.map {|i| (97 + i).chr} runs = 1 << vars puts puts [*cols, '|', 'result'] * ' ' puts ['--' * cols.size, '-' * 6] * '+-' runs.times do |i| list = ("%0*b" % [vars, i]).split('') vals = list.map {|item| item == '1'} resu = !!test(*vals) ? '1' : '0' puts [*list, '|', resu] * ' ' end end |