Skip to content

Instantly share code, notes, and snippets.

@jeena
Created July 1, 2010 11:26
Show Gist options
  • Save jeena/459846 to your computer and use it in GitHub Desktop.
Save jeena/459846 to your computer and use it in GitHub Desktop.
#!/usr/bin/lua
secretword = "llama" -- the secret word
write ("What is your name? ")
name = read ("*l")
if name == "Randal" then
print ("Hello, Randal! How good of you to be here!")
else
print ("Hello " .. name .. "!") -- ordinary greeting
write ("What is the secret word? ")
guess = read ("*l")
while guess ~= secretword do
write ("Wrong, try again. What is the secret word? ")
guess = read ("*l")
end
end
#!/usr/bin/env ruby -wKU
secretword = Regexp.new "llama" # the secret word
print("What is your name? ")
name = gets
if name == "Randal" then
print("Hello, Randal! How good of you to be here!")
else
puts("Hello " + name.strip + "!") # ordinary greeting
print("What is the secret word? ")
guess = gets
while not guess =~ secretword do
puts("Wrong, try again. What is the secret word? ")
guess = gets
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment