Skip to content

Instantly share code, notes, and snippets.

@shuntaroy
Created March 29, 2022 11:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shuntaroy/e45a29b2fd8099b1caae65d916610141 to your computer and use it in GitHub Desktop.
Save shuntaroy/e45a29b2fd8099b1caae65d916610141 to your computer and use it in GitHub Desktop.
# 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