Skip to content

Instantly share code, notes, and snippets.

@shuntaroy
Created Mar 29, 2022
Embed
What would you like to do?
# 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