Skip to content

Instantly share code, notes, and snippets.

@Wonderfall
Last active August 29, 2015 14:02
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 Wonderfall/e0f41b1267ce6cb2a897 to your computer and use it in GitHub Desktop.
Save Wonderfall/e0f41b1267ce6cb2a897 to your computer and use it in GitHub Desktop.
Shake some words!
# Copyleft
# Thanks to Caletlog ! Shorter & Faster !
# Good game !
puts "You have to find a secret word, each player has 5 tries !"
score = 0
loop do
print "Enter some word : "
secretWord = gets.chomp
30.times { puts }
shakedWord = secretWord.split(//).shuffle.join
(1..5).each do |i|
puts "--- #{6-i} tries/try left."
print "What's this word : #{shakedWord} ? "
if gets.chomp == secretWord
puts "Well played !"
score += 5
puts
break
else
puts "Try again..."
score -= 1
puts
end
end
print "The game is over. Play a new one ? (y/n)"
break if gets.chomp == 'n'
end
at_exit { puts "Your score is : #{score} !" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment