Skip to content

Instantly share code, notes, and snippets.

@felinebabies
Created December 11, 2017 12:59
Show Gist options
  • Select an option

  • Save felinebabies/f4f8a907959585cded8ae30a42d5847e to your computer and use it in GitHub Desktop.

Select an option

Save felinebabies/f4f8a907959585cded8ae30a42d5847e to your computer and use it in GitHub Desktop.
筒の中のボール
ballCount, ballInput = $stdin.read.split("\n")
ballCount = ballCount.to_i
tube = []
ballCount.times do |i|
ballNum = i + 1
ballDirection = ballInput[i]
if ballDirection == "L"
tube.unshift(ballNum.to_s)
elsif ballDirection == "R"
tube.push(ballNum.to_s)
end
end
puts tube.join(" ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment