def three_in_a_row(game_state, last_move):
    """Return true if X or O have three in a row in one of the
    rows that include last_move. Else return false."""    
    if last_move == 0:
        if game_state[0] == game_state[1] == game_state[2]: return True
        if game_state[0] == game_state[4] == game_state[8]: return True 
        if game_state[0] == game_state[3] == game_state[6]: return True

    if last_move == 1:
        if game_state[1] == game_state[0] == game_state[2]: return True
        if game_state[1] == game_state[4] == game_state[7]: return True

    if last_move == 2:
        if game_state[2] == game_state[0] == game_state[1]: return True
        if game_state[2] == game_state[5] == game_state[8]: return True
        if game_state[2] == game_state[4] == game_state[6]: return True

    if last_move == 3:
        if game_state[3] == game_state[0] == game_state[6]: return True
        if game_state[3] == game_state[4] == game_state[5]: return True

    if last_move == 4:
        if game_state[4] == game_state[1] == game_state[7]: return True
        if game_state[4] == game_state[3] == game_state[5]: return True
        if game_state[4] == game_state[0] == game_state[8]: return True
        if game_state[4] == game_state[2] == game_state[6]: return True

    if last_move == 5:
        if game_state[5] == game_state[3] == game_state[4]: return True
        if game_state[5] == game_state[2] == game_state[8]: return True

    if last_move == 6:
        if game_state[6] == game_state[0] == game_state[3]: return True
        if game_state[6] == game_state[7] == game_state[8]: return True
        if game_state[6] == game_state[2] == game_state[4]: return True

    if last_move == 7:
        if game_state[7] == game_state[1] == game_state[4]: return True
        if game_state[7] == game_state[6] == game_state[8]: return True

    if last_move == 8:
        if game_state[8] == game_state[2] == game_state[5]: return True
        if game_state[8] == game_state[6] == game_state[7]: return True
        if game_state[8] == game_state[0] == game_state[4]: return True

    return False