[net.sources] NFL football pool via EMAIL, outlines and source code

ajk@solar.UUCP (A.KESSLER) (12/28/84)

Yo sports fans,
	The following is an outline for a football pool.  Its very simple
to run.  Send out the forms each week like the sample below.  The person
who runs the pool fills in the teams and the spread, I used Tuesday's
USA Today sports page spreads.  Each person in the pool puts an X
between the < > in the appropriate column and mails it back to you.
You save one file that has everyone's picks.  When the results are
known, fill out a form yourself that has the name RESULTS and put
X's in the correct column.  I save all the picks in a file such as
week16.picks

Just run the program score as:
$ score week16.picks

A list of all the names will be spit out in order of number of correct picks.
Pushes ( games that end in exactly the spread ) leave both columns blank.
Your all set for hours of fun and entertainment.

the program conver.c is used to keep track of the teams that cover the spread.
Every week run as:
$ cover week1.picks
and then to see the teams listed alphabetically and how many times until then
that they have covered the spread use uncover.c
$ uncover covers

Have fun.  Feel free to butcher my already shabby code.

Warnings:  score.c is pretty good at skipping over bullshit lines but don't
let you users mess around with the outline, just fill in X's inside the < >.
Make sure they all put in their NAME and make sure you use the name
RESULTS in caps for the correct picks.
For cover and uncover to work well, use the exact names and spaces I used
in my sample outline because it looks at the first 5 or 6 letters and both
N.Y. and L.A. teams are a pain.


--------------------------------------------------------------------
NAME: 
*************************************************
Week 16
-----------------------------------------------------------

A: < > L.A. Rams		at < > San Francisco	-6
B: < > Green Bay		at < > Minnesota	+7.5
C: < > Denver			at < > Seattle		-4
D: < > Kansas City  		at < > San Diego	-2
E: < > New Orleans		at < > N.Y. Giants	-9.5
F: < > N.Y. Jets		at < > Tampa Bay	-4
G: < > Buffalo			at < > Cincinnati	-13.5
H: < > Philadelphia 		at < > Atlanta		+3
I: < > Chicago			at < > Detroit		-2
J: < > Pittsburgh		at < > L.A. Raiders	-6.5
K: < > Cleveland		at < > Houston		-2
L: < > St. Louis 		at < > Washington	-5.5
M: < > Indianapolis		at < > New England	-10.5

   MONDAY NIGHT
N: < > Dallas			at < > Miami		-5

Tiebreaker - Total number of passes on Monday Night: 


********** For Amusement Only *****************************

--------------------------------------------------------------------
score.c
--------------------------------------------------------------------
#include <stdio.h>
char outline[ 2048 ];

char *bp;
char pname[ 50 ][ 132 ];
char name[ 132 ];

int pick[ 50 ][ 14 ] = { 0 };
int res[ 14 ];
int correct[ 50 ];
int most;

FILE *ioptr;
FILE *ioptr2;
int fildes;
char string[ 1024 ];
int lineno;



main( argc, argv )
int argc;
char *argv[];
{

	int i, j, k, l;



	if( ( ioptr = fopen( argv[ 1 ], "r" ) ) == NULL )
	{
		printf( "Could not open %s for reading\n", argv[ 1 ] );
		exit( 0 );
	}

	lineno = 0;
	i = 0;

	while( fgets( string, 1024, ioptr ) != NULL )
	{
		lineno++;
		if( sscanf( string, "NAME:%s\n", name ) == 1 )
		{
			/* got one */
			strcpy( pname[ i ], name );
			while( string[ 0 ] != 'A' ) getaline();
			for( j = 0; j < 13; j++ )
			{
				bp = string;
				while( *bp++ != '<' );
				if( *bp++ != ' ' ) pick[ i ][ j ] = 1;
					else pick[ i ][ j ] = 0;
				while( *bp++ != '<' );
				if( *bp != ' ' ) 
				{
					if( pick[ i ][ j ] == 1 ) 
						pick[ i ][ j ] = 3;
					else pick[ i ][ j ] = 2;
				}
				else if(pick[ i ][ j ] == 0) pick[ i ][ j ] = 3;
				getaline();
			}
			while( string[ 0 ] != 'N' ) getaline();
			bp = string;
			while( *bp++ != '<' );
			if( *bp++ != ' ' ) pick[ i ][ 13 ] = 1;
				else pick[ i ][ 13 ] = 0;
			while( *bp++ != '<' );
			if( *bp != ' ' ) 
			{
				if( pick[ i ][ 13 ] == 1 )
					pick[ i ][ 13 ] = 3;
				else pick[ i ][ 13 ] = 2;
			}
			else if(pick[ i ][ 13 ] == 0) pick[ i ][ 13 ] = 3;
			if( strcmp( pname[ i ], "RESULTS" ) == 0 )
			{
				for( j=0; j<14;j++)
				{
					res[ j ] = pick[ i ][ j ];
				}
				i--;
			}

			i++;
		}
	}
	most = 0;
	for( k=0; k<i; k++ )
	{
		correct[k] = 0;
		for( l=0;l<14;l++)
		{
			if( pick[ k ][ l ] == res[ l ] ) 
			{
				correct[ k ]++;
			}
		}
		if( correct[ k ] > most ) most = correct[ k ];
	}

	for( k = most; k>= 0; k-- )
	{
		for( l=0;l<i;l++)
		{
			if( correct[ l ] == k )
				printf( "%s\t\t%d\n", pname[ l ], correct[ l ] );
		}
	}
	fclose( ioptr );
}

getaline()
{
	if( fgets( string, 1024, ioptr ) == NULL )
	{
		printf( "File corrupt at line #: %d\n", lineno );
	}
	lineno++;
}
usage()
{
	printf( "Usage:\n" );
	printf( "\tscore week#.picks\n" );
	exit();
}
--------------------------------------------------------------------
cover.c
--------------------------------------------------------------------
#include <stdio.h>
char outline[ 2048 ];

char *bp;
char pname[ 50 ][ 132 ];
char name[ 132 ];

int pick[ 50 ][ 14 ] = { 0 };
int res[ 14 ];
int correct[ 50 ];
int most;

FILE *ioptr;
FILE *ioptr2;
int fildes;
char string[ 1024 ];
int lineno;
char team1[ 50 ][ 50 ], team2[ 50 ][ 50 ];



main( argc, argv )
int argc;
char *argv[];
{

	int i, j, k, l;



	if( ( ioptr = fopen( argv[ 1 ], "r" ) ) == NULL )
	{
		printf( "Could not open %s for reading\n", argv[ 1 ] );
		exit( 0 );
	}

	if( ( ioptr2 = fopen( "covers", "a+" ) ) == NULL )
	{
		printf( "Could not open covers for appending\n" );
		exit( 0 );
	}
	lineno = 0;
	i = 0;

	while( fgets( string, 1024, ioptr ) != NULL )
	{
		lineno++;
		if( sscanf( string, "NAME:%s\n", name ) == 1 )
		{
			/* got one */
			strcpy( pname[ i ], name );
			while( string[ 0 ] != 'A' ) getaline();
			for( j = 0; j < 13; j++ )
			{
				getteams( j );
				bp = string;
				while( *bp++ != '<' );
				if( *bp++ != ' ' ) pick[ i ][ j ] = 1;
					else pick[ i ][ j ] = 0;
				while( *bp++ != '<' );
				if( *bp != ' ' ) 
				{
					if( pick[ i ][ j ] == 1 ) 
						pick[ i ][ j ] = 3;
					else pick[ i ][ j ] = 2;
				}
				else if(pick[ i ][ j ] == 0) pick[ i ][ j ] = 3;
				getaline();
			}
			while( string[ 0 ] != 'N' ) getaline();
			j = 13;
			getteams( j );
			bp = string;
			while( *bp++ != '<' );
			if( *bp++ != ' ' ) pick[ i ][ 13 ] = 1;
				else pick[ i ][ 13 ] = 0;
			while( *bp++ != '<' );
			if( *bp != ' ' ) 
			{
				if( pick[ i ][ 13 ] == 1 )
					pick[ i ][ 13 ] = 3;
				else pick[ i ][ 13 ] = 2;
			}
			else if(pick[ i ][ 13 ] == 0) pick[ i ][ 13 ] = 3;
			if( strcmp( pname[ i ], "RESULTS" ) == 0 )
			{
				for( j=0; j<14;j++)
				{
					res[ j ] = pick[ i ][ j ];
					if( res[ j ] == 1 ) fprintf( ioptr2, "%s\n", team1[ j ] );
					if( res[ j ] == 2 ) fprintf( ioptr2, "%s\n", team2[ j ] );
				}
				i--;
			}

			i++;
		}
	}
	most = 0;
	for( k=0; k<i; k++ )
	{
		correct[k] = 0;
		for( l=0;l<14;l++)
		{
			if( pick[ k ][ l ] == res[ l ] ) 
			{
				correct[ k ]++;
			}
		}
		if( correct[ k ] > most ) most = correct[ k ];
	}

	fclose( ioptr );
}

getaline()
{
	if( fgets( string, 1024, ioptr ) == NULL )
	{
		printf( "File corrupt at line #: %d\n", lineno );
	}
	lineno++;
}
usage()
{
	printf( "Usage:\n" );
	printf( "\tscore week#.picks\n" );
	exit();
}
getteams( x )
int x;
{
	char *bphold;
	char string2[ 1024];
	strcpy( string2, string );
	bp = string2;
	while( *bp++ != '>' );
	bp++;	/* get over the space */
	bphold = bp;
	while( *bp++ != '\t' );
	*bp = NULL;
	strcpy( team1[ x ], bphold );

	while( *bp++ != '>' );
	bp++;	/* get over the space */
	bphold = bp;
	while( *bp++ != '\t' );
	*bp = NULL;
	strcpy( team2[ x ], bphold );
}
--------------------------------------------------------------------
uncover.c
--------------------------------------------------------------------
#include <stdio.h>
#define NUMTEAMS 28
char outline[ 2048 ];

char *bp;
char pname[ 50 ][ 132 ];
char name[ 132 ];

int pick[ 50 ][ 14 ] = { 0 };
int res[ 14 ];
int correct[ 50 ];
int most;

FILE *ioptr;
FILE *ioptr2;
int fildes;
char string[ 1024 ];
int lineno;
char team1[ 50 ][ 50 ], team2[ 50 ][ 50 ];
char teams[ NUMTEAMS ][ 7 ] = {
	"Atlant",
	"Buffal",
	"Chicag",
	"Cincin",
	"Clevel",
	"Dallas",
	"Denver",
	"Detroi",
	"Green ",
	"Housto",
	"Indian",
	"Kansas",
	"L.A. R",
	"Miami ",
	"Minnes",
	"New En",
	"New Or",
	"N.Y. G",
	"N.Y. J",
	"Philad",
	"Pittsb",
	"Rams",
	"San Di",
	"San Fr",
	"Seattl",
	"St. Lo",
	"Tampa ",
	"Washin"
};
int covcnt[ NUMTEAMS ];



main( argc, argv )
int argc;
char *argv[];
{

	int i, j, k, l;



	if( ( ioptr = fopen( argv[ 1 ], "r" ) ) == NULL )
	{
		printf( "Could not open %s for reading\n", argv[ 1 ] );
		exit( 0 );
	}

	lineno = 0;
	i = 0;

	while( fgets( string, 1024, ioptr ) != NULL )
	{
		if( strncmp( string, "L.A. Ram", 8 ) == 0 )
			strcpy( string, "Rams" );
		if( strncmp( string, "Miam", 4 ) == 0 )
			strcpy( string, "Miami " );
		lineno++;
		for( i = 0; i < NUMTEAMS; i++ )
		{
			if( strncmp( string, teams[ i ], 6 ) == 0 )
			{
				covcnt[ i ]++;
				i = NUMTEAMS;
			}
		}
	}
	for( i = 0; i < NUMTEAMS; i++ )
	{
		printf( "%s\t%d\n", teams[ i ], covcnt[ i ] );
	}
}
getaline()
{
	if( fgets( string, 1024, ioptr ) == NULL )
	{
		printf( "File corrupt at line #: %d\n", lineno );
	}
	lineno++;
}
usage()
{
	printf( "Usage:\n" );
	printf( "\tscore week#.picks\n" );
	exit();
}
getteams( x )
int x;
{
	char *bphold;
	char string2[ 1024];
	strcpy( string2, string );
	bp = string2;
	while( *bp++ != '>' );
	bp++;	/* get over the space */
	bphold = bp;
	while( *bp++ != '\t' );
	*bp = NULL;
	strcpy( team1[ x ], bphold );

	while( *bp++ != '>' );
	bp++;	/* get over the space */
	bphold = bp;
	while( *bp++ != '\t' );
	*bp = NULL;
	strcpy( team2[ x ], bphold );
}