Created
January 21, 2022 17:10
-
-
Save mhtocs/724452451b3004fbf6475a4c3586d1f7 to your computer and use it in GitHub Desktop.
A tiny game in elixir
This file contains 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
# bread | |
defmodule Game do | |
def play do | |
hints = "flour, water, yeast, bakery" | |
IO.puts "Hints: #{hints}" | |
guess = IO.gets "Guess the word: " | |
guess = String.trim guess | |
attempt guess | |
end | |
def attempt("bread") do | |
IO.puts "won!" | |
end | |
def attempt(guess) do | |
IO.puts "That is not correct!" | |
guess = IO.gets "Try again: " | |
guess = String.trim guess | |
attempt guess | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment