Skip to content

Instantly share code, notes, and snippets.

@rightfold
Last active August 29, 2015 14:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rightfold/5b5ac73aaaf0d9ccd8bd to your computer and use it in GitHub Desktop.
Save rightfold/5b5ac73aaaf0d9ccd8bd to your computer and use it in GitHub Desktop.
identification division.
program-id. hangman.
data division.
working-storage section.
01 state.
05 word pic A(100).
05 word-length pic 9(3).
05 guess pic A.
05 guesses occurs 256 times pic 9.
05 done pic 9.
01 i pic 9(3).
procedure division.
* TODO: pick random word from word list
move "hello" to word
move 5 to word-length
* TODO: show this in debug mode only
display "word: " word
perform until done = 1
accept guess
move 1 to guesses(function ord(guess))
move 1 to done
perform varying i from 1 by 1 until i > word-length
if guesses(function ord(word(i:1))) = 1 then
display word(i:1) with no advancing
else
move 0 to done
display "_" with no advancing
end-if
end-perform
display " "
end-perform.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment