Last active
May 22, 2019 07:21
-
-
Save tomaes/3cb139137a12280e9b8bd989e7695397 to your computer and use it in GitHub Desktop.
Emoji-enhanced Ruby version of whatsmore.bas
This file contains hidden or 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
# What's more? | |
# a quick guesstimation game | |
# (Emoji-enhanced Ruby version) | |
require 'time' | |
cont = true | |
r = 0 | |
t = Time.now.to_f | |
# "Fisheye" & "Bullseye" | |
#bchar = ["\u25C9","\u25CE"] | |
# "Cloud" & "Umbrella" | |
bchar = ["\u2601", "\u2602"] | |
begin | |
c = [ 0, 0 ] | |
r += 1 | |
br = rand() | |
fd = "" | |
# field composition & output needs to be cached in Ruby | |
for y in 1..10 do | |
for x in 1..10 do | |
rand() > br ? n = 1 : n = 0 | |
c[n] += 1 | |
fd += " #{ bchar[n] } " | |
end | |
fd += "\n" * 2 | |
end | |
fd += "\n" | |
puts fd | |
begin | |
inp_err = false | |
print "What's more (#{bchar[0]}=0 or #{bchar[1]}=1)?" | |
k = gets.to_i | |
if k != 0 and k != 1 then | |
puts "invalid input!" | |
inp_err = true | |
end | |
end while inp_err | |
for i in 0..1 do | |
puts "#{bchar[i]}: #{c[i]}" | |
if c[i] > c[k] then cont = false; end | |
end | |
puts | |
end while cont | |
puts "YOUR RUN: #{r} ROUNDS(S) in #{(Time.now.to_f - t).round(3)} SECONDS TIME!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment