LoginSignup
3
1

More than 5 years have passed since last update.

Rubyでセリをする問題を解いてみた[プログラミング問題]

Last updated at Posted at 2018-04-30

友達に問題を出されて考えたのでメモとして残しておきます

AとBが交互に取引をして行く。
Aは200円ずつ、Bは300円ずつ取引をして行く。
片方が値段をあげることができなくなったらセリは終了し、最後に値段をあげたほうが購入する。

標準出力から商品の値段、Aの予算、Bの予算を受け取る


loop do
    price += 200
    if A_budget >= price && B_budget < price + 1000
        puts "A #{price}"
        return
    end
    price += 300
    if B_budget >= price && A_budget < price + 10
        puts "B #{price}"
        return
    end
end

プログラミング問題を解いたらオファーがもらえたりするサービスもあるみたいだし本格的にやってみようかな〜

おすすめのサービスとかがあれば教えてもらいたい

それと実行スピードとかあるみたいだけど早くするためにはどうしたらいいんだろう??
誰か教えて〜

3
1
2

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
3
1