Hangman in Haskell

I wrote a Haskell implementation of a popular game Hangman. Hangman thinks of a word and tells you its length. You get that many chance to guess it. The procedure of guessing is following assuming length of the word is n.

  • You guess a letter, if the word contains that letter, hangman reveals the location of this letter. You still have n more guesses.
  • If the word does not contain your letter, your no of guesses is reduced by 1.
  • If you guess the word before n == 0, you live else you die.

You have to get two files from this folder; hangman.hs which contains the code and words which contains all possible words hangman can guess. Compile it using ghc compiler.

ghc --make hangman.hs

Run the binary produced. Have fun.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s