#!/bin/sh
#
# no-extra-credit -- extract only the non-extra credit problems from a homework
#
# AUTHOR:	Gary T. Leavens

USAGE='no-extra-credit homework-file'

# only one argument allowed
if test $# -ne 1
then
	echo "$USAGE" >&2
	exit 1
fi

sed -n -e ':copying
	   /^[0-9][0-9]*\./{
		   /extra credit/{
			n
			b notc
		   }
		   p
		   n
		   b copying
	   }
	   p
	   n
	   b copying
	   :notc
	   /^[0-9][0-9]*\./{
		   /extra credit/{
			n
			b notc
		   }
		   p
		   n
		   b copying
	   }
	   /^[A-Z]/{
	        p
	        n
	        b copying
	   }
	   n
	   b notc
	' $*
