-
-
Save 0x0dea/d97760180bf25c67377d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "Gimme numbars! Say 'done' as appropriate." | |
nums = ARGF.take_while { |line| line.chomp.upcase != 'DONE' } | |
.map { |n| n.delete(?,).to_i } | |
puts "These are teh numbars: #{nums}" | |
puts "Which op you wantses? add(+1), sub(-2), mul(*3), div(/4)" | |
valid = %w[add sub mul div 1 2 3 4 + - * /] | |
op = gets.chomp until valid.include? op | |
op = '+-*/'[valid.index(op) % 4] | |
puts "#{nums * op.center(3)} = #{nums.reduce op}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment