Skip to content

Instantly share code, notes, and snippets.

@mhtocs
Created January 21, 2022 17:10
Show Gist options
  • Save mhtocs/724452451b3004fbf6475a4c3586d1f7 to your computer and use it in GitHub Desktop.
Save mhtocs/724452451b3004fbf6475a4c3586d1f7 to your computer and use it in GitHub Desktop.
A tiny game in elixir
# 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