0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

レベルアップ問題を解いてみる

Posted at

はじめに

paizaの問題集を使い、ハンズオン学習をしています。
標準入力の問題を一通り解いたので、レベルアップ問題に挑戦してみました。

乗客人数 Ruby編

自分の回答

quiita.rb
a,b,c = gets.split.map(&:to_i)

n = a
n -= b
n += c

puts n
  • map
    入力値を配列に格納するメソッド

占い Ruby編

自分の回答

quiita.rb
n = gets.chomp.to_i

if n == 7
    puts "Yes"
else
    puts "No"
end

FizzBuzz Ruby編

自分の回答

quiita.rb
(1..100).each do |i|
    if i % 3 == 0 && i % 5 == 0
        puts "FizzBuzz"
    elsif i % 3 == 0
        puts "Fizz"
    elsif i % 5 == 0
        puts "Buzz"
    else
        puts i
    end
end

問題を解く際、参考させていただいた記事

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?