Created
March 29, 2022 11:33
-
-
Save shuntaroy/e45a29b2fd8099b1caae65d916610141 to your computer and use it in GitHub Desktop.
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
# slightly modified from: | |
# @Kta-M リズムに乗ってズンドコキヨシ♪ with Ruby | |
# https://qiita.com/Kta-M/items/c5ea66ddd0e4123a298c | |
def zundoko | |
l = 1 | |
loop do | |
n = rand(32) | |
s = ("%05b" % n).gsub(/0/, 'ズン').gsub(/1/, 'ドコ') | |
r = [0, 1.0, 0, 0.5, 0, 0.5, 0, 0.5, 0.25, 0.25] | |
print ("%3d" % l) + ' ' | |
print_with_rythm s, r | |
if n == 1 | |
print ' ' | |
print_with_rythm "キ・ヨ・シ!", [0, 0.25, 0, 0.25, 0, 1.0] | |
print "\n" | |
break | |
else | |
sleep(0.75) | |
end | |
puts | |
l += 1 | |
end | |
end | |
def print_with_rythm(s, r) | |
s.split(//).zip(r).each do |c, w| | |
print c | |
sleep(w) | |
end | |
end | |
zundoko |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment