Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

★【Challenge!】【Easy】 Hangman Solver

Name: !WIZardrY9E!UhEWzHM7+1tYUG2 2012-05-14 13:16

⚫ The Game of Hangman

A player guesses letters that are part of a word!
If he has not guessed the complete word before making six (6) mistakes, he has lost!

      _______
     |/      |
     |      (_)
     |      \|/   It is a game over!
     |       |
     |      / \
     |
  ___|___


⚫ Your Challenge

In a language of your choice, write a program that takes as its input (in some way) the target word (with blanks) and the letters that have been guessed already. It should then output the next letter to be guessed.
For example:

$ echo -n "p...s\npds" | ./guesser
e

You may assume the word to be guessed is an English word and contains only lowercase ASCII letters.
Provide code and instructions if usage is not obvious. Consider using a tripcode to ease conversation about your entry.

Entries will be judged on GOODITUDE (defined as its win/loss ratio over twenty random games), on SPEED, and on CLEVERNESS.

Your deadline is 23:59:59 on Sunday, May 20th. Results will be posted the following day.

 |∧_∧
 |´・ω・) < Good luck!♫
 ||と ノ

Name: VIPPER 2012-05-20 16:49

(use-modules (ice-9 rdelim))

(define Hang 0)
(define Len 1)
(define File "hangman.txt")
(define Char 0)

(define Handle
        (open-input-file File))
(define Word
        (read-line Handle)); For time reasons i put one word in here :/
; Thought of making it read lines in a loop and the test being a random number of some sort with the last read line being the word
(while (and (if (= Hang 6)
                (begin (display "LOST!\n") ; I wish i had time to make it draw a hanging man but i dont have it
                       #f))
            (not (= (string-length Word)
                    Len)))
       (set! Char
             (read-char (current-input-port)))
       (if (not (char=? Char #\nl)) ; Filter #\nl(\n) read when pressing enter
           (if (not (char=? Char (string-ref Word
                                             Len)))
               (set! Hang
                     (+ 1 Hang))
               (begin (set! Len
                            (+ 1 Len))
                      (display Char))))

A very simple and primitive implementation
Im made this sort of in a real rush, but i send it in anyway.
I wish i had the time to improve it.

Dont be hard on me since this is my first real scheme program.
It should work, i couldnt test i as much as i should.

Im glad OP took the time to make a programming contest, i missed those.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List