Skip to content

Instantly share code, notes, and snippets.

@lcowell
Last active December 11, 2015 22:18
Show Gist options
  • Save lcowell/4668631 to your computer and use it in GitHub Desktop.
Save lcowell/4668631 to your computer and use it in GitHub Desktop.
add ops in to expand your truth table
#!/usr/bin/env ruby
ops = [
"l && r",
"l || r",
"l ^ r",
"!l && !r",
"!(l ^ r)"
]
ops.each do |key|
puts key.center(12)
puts "=" * 20
[true, false].product([true, false]).each do |l, r|
printf "|%5s|%5s|%5s|\n", l, r, eval(key)
end
puts "=" * 20
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment