#!/usr/bin/env ruby =begin full_adder_rules0.rb Stephen Fickas QUESTIONS? -> fickas@cs.uoregon.edu =end # Match a 3 digit binary number and follow rules below: # 000 => 00 # 001 => 10 # 010 => 10 # 011 => 01 # 100 => 10 # 101 => 01 # 110 => 01 # 111 => 11 # Use procedural form of rules to solve the problem. def simulate_full_adder(digits) result = 'initial value' case digits when '000' result = '00' when '001' result = '10' when '010' result = '10' when '011' result = '01' when '100' result = '10' when '101' result = '01' when '110' result = '01' when '111' result = '11' end return result end