Skip to content

Instantly share code, notes, and snippets.

@tomaes
Last active May 31, 2019 06:31
Show Gist options
  • Save tomaes/753cc85618b8a1646d72751e4df7788a to your computer and use it in GitHub Desktop.
Save tomaes/753cc85618b8a1646d72751e4df7788a to your computer and use it in GitHub Desktop.
Spot the missing die face as quickly as possible. Micro game in Ruby.
# No-Show Die Face, a micro game in Ruby
r = 0
e = false
s = Time.now.to_f
begin
# die faces 1 to 6
n = { 1 => "\u2680",
2 => "\u2681",
3 => "\u2682",
4 => "\u2683",
5 => "\u2684",
6 => "\u2685" }
t = Time.now.to_f
d = rand(1..6)
n.delete(d)
# show permutated die faces
(1..6).to_a.shuffle.each {|i| print n[i]; }
print " Missing?"
a = gets.to_i
puts
r += 1
q = (Time.now.to_f - t).round(3)
if a == d then
print "Yes! Time: #{q}\n"
else
puts "Wrong!"
e = true
end;
end while !e and q < 3
print "You're not quick enough!\n"
print "#{r} round(s) in #{ (Time.now.to_f-s).round(3) }s"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment