#include 
#include 
#include 

#define SZ 32

char *pickWord (char *filename) {
    char *lines[RAND_MAX], buf[SZ], *word;
    int lineno;
    FILE *fp;

    srand(time(NULL));

    fp = fopen(filename, "r");
    if ( ! fp ) {
        fprintf(stderr, "Failed opening '%s': %s\n", filename, strerror(errno));
        return NULL;
    }
    for (lineno=0; fgets(buf, SZ, fp); lineno++) {
        lines[lineno] = strdup(buf);
    }

    word = lines[rand()%lineno];
    if ( strchr(word, '\n') ) {
        word[strlen(word)-1] = '\0';
    }

    return word;
}

int zero()
{
    printf("+----+\n");
    printf("|    +\n");
    printf("|     \n");
    printf("|      \n");
    printf("|      \n");
    printf("|      \n");
    printf("=========\n");
    return 0;
}
int one()
{
    printf("+----+\n");
    printf("|    +\n");
    printf("|    0 \n");
    printf("|     \n");
    printf("|    \n");
    printf("|     \n");
    printf("=========\n");
    return 0;
}

int two()
{
    printf("+----+\n");
    printf("|    +\n");
    printf("|    0 \n");
    printf("|    |   \n");
    printf("|       \n");
    printf("|     \n");
    printf("=========\n");
    return 0;
}

int three()
{
    printf("+----+\n");
    printf("|    +\n");
    printf("|    0 \n");
    printf("|    |  \n");
    printf("|     \\ \n");
    printf("|     \n");
    printf("=========\n");
    return 0;
}

int four()
{
    printf("+----+\n");
    printf("|    +\n");
    printf("|    0 \n");
    printf("|    |\\  \n");
    printf("|     \\ \n");
    printf("|     \n");
    printf("=========\n");
    return 0;
}


int five()
{
    printf("+----+\n");
    printf("|    +\n");
    printf("|    0 \n");
    printf("|   /|\\  \n");
    printf("|     \\ \n");
    printf("|     \n");
    printf("=========\n");
    return 0;
}


int six()
{
    printf("+----+\n");
    printf("|    +\n");
    printf("|    | \n");
    printf("|    X \n");
    printf("|   /|\\  \n");
    printf("|   / \\ \n");
    printf("=========\n");
    return 0;
}
int drawGallows(char *guesses) {
    switch (strlen(guesses)) {
    case 0:
        zero();
        break;
    case 1:
        one();
        break;
    case 2:
        two();
        break;
    case 3:
        three();
        break;
    case 4:
        four();
        break;
    case 5:
        five();
        break;
    case 6:
        six();
        return 1;
    default:
        printf("OH NOES, I BROKE HANGMAN!\n");
        break;
    }
    return 0;
}

int drawSlots(char *word, char *guesses) {
    int i;
    int maybeWeWon = 1;
    for (i=0; i