Updated calculator.rb for a smarter input selection