Created
June 25, 2018 02:50
-
-
Save johnta0/85bd8c1809d249e0e5280dbbf908f6b3 to your computer and use it in GitHub Desktop.
殆どが「暇」で構成される文字列から、1つの「蝦」を見つけ出すためのRuby script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
str = '暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇蝦暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇暇' | |
arr = str.split(/\s*/) | |
arr.each_with_index do |hima, index| | |
if arr[index] != arr[index - 1] | |
puts "#{index + 1}番目が#{hima}です" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment