LoginSignup
0
0

More than 3 years have passed since last update.

[ruby]ドリルアウトプット

Posted at

内容

image.png

実装

image.png

解説

input.each_with_indexでinputに格納されている番号をnumとして1つずつ取り出し、取り出された順で番号付けをします。

そして取り出されたnumがtarget_numと同じとき、何番目に含まれているかの結果を出力するため、配列が0番目から始まることを考慮して、#{index + 1}としています。

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