Ruby addition

ruby addition

Value to be entered

Expected output

Input example

Output example

Pattern 1


a = gets.to_i
b = gets.to_i
puts a + b

Pattern 2


a = gets.to_i
b = gets.to_i
num = a + b
puts num

Pattern 3


a = gets
b = gets
puts a + b

Pattern 4


a = gets
b = gets
puts (a + b).to_i

Pattern 5


a = gets.to_s
b = gets.to_s
puts a + b

I haven't done much to say that it's a pattern, but I can't just do "1 + 1". Probably because I am bound by the peculiar rule of pai ○ a, the test does not pass ~, today I spent about 4 hours here and the harvest was 0. Remorse

Postscript

It's done


s = gets.split(' ').map(&:to_i)
result = s[0] + s[1]
puts result

that's all

Recommended Posts

Ruby addition
Ruby learning 4
[Ruby] Array
Ruby basics
Ruby learning 5
Ruby basics
Refactoring Ruby
Ruby learning 3
Ruby setting 2
Ruby problem ⑦
Ruby learning 2
[Ruby] Block
Refactoring Ruby
ruby calculator
Ruby learning 6
Ruby settings 1
Refactoring Ruby
Ruby basics
Ruby memo
Ruby learning 1
Ruby Review 1
[Ruby] Module
[Rails] Addition of Ruby On Rails comment function
Introduction to Ruby 2
ruby Uppercase letters
ruby search problem
Ruby Learning # 25 Comments
Ruby to_s method
[Ruby] postfix if
[Ruby] FizzBuzz problem
Ruby text conversion
Ruby basic terms
ruby exception handling
Ruby Learning # 13 Arrays
About Ruby symbols
Ruby Learning # 1 Introduction
Ruby Learning # 34 Modules
[ruby] drill output
I started Ruby
[Ruby] Iterative processing
ruby API problem
Ruby vertical writing
About ruby ​​form
[ruby] drill output
About Ruby Hashes
Ruby setting 3 Rubocop
Ruby Learning # 14 Hashes
[ruby] drill output
[Ruby] each nested
[Ruby] Arithmetic progression
[Ruby] FizzBuzz problem
Ruby Hash notes
Class in Ruby
[Ruby] slice method
Ruby standard output
[Ruby] end_with? method
[Ruby] Method memorandum
Chart type Ruby
[Ruby] Hash retrieval
Basics of Ruby
[WIP] Ruby Tips