Am I Prepared for CSCI-E26?
CSCI-E26 assumes students have a certain level of
programming experience and knowledge. The course is
an introduction to C/Unix and CGI, but it is not an
introduction to programming.
There is no sure way to predict if the level and
speed of the course will be too quick for you, but
here are some problems to try. Write the solutions in any language
you like. If you have trouble
solving, coding, or getting working solutions to
these problems, you should consider taking a more
introductory programming class.
Note about AI: If you need to use AI to do these ...
then you will be better off in an introductory programming
course. If you want an explanation of why I expect/want
students to know how to program on their own,
please write or call me: Bruce Molay, molay@fas.harvard.edu,
617-864-8832 immediately. This is very
important. And is not a joke. I really want to hear your
thoughts, and I really want to talk to you. The more all of us
can understand AI, education, and the human brain, the better.
The Problems
-
Write a program to read in a list of non-zero integers.
The user inputs a zero to indicate end of input. The
program then prints the average of all the numbers and
the difference between the largest number and the smallest
number entered. There should be no maximum number of
integers in the list. Do not use built-in max, min, or
average functions.
-
Write a program that finds the number of days between
two dates in the same year. The user inputs one
date, presses the return key, then enters another date.
The input is of the form "Month day", for example, Jul 4
or Oct 31.
Do not use built-in date parsing functions. Write the algorithm
yourself.
-
Write a prgram that prints out a diamond shape made of
alternating #'s and _'s that looks like:
#
#_#
#_#_#
#_#
#
Your program should accept a positive integer as input
and print a checkerboard diamond with that many rows. In
the example shown, the number of rows is five. Your program
should work for even and odd numbers.
-
Write a program that sorts the words in a text file.
In particular, the file contains one word per line.
The user specifies the name of the file containing the
words and the name of a file to put the result. The
program reads the words from the input file and
writes the sorted list into the output file. You have to code
a sorting algorithm; using a built-in sort operation for a language
is not ok for this problem. You may use any sorting algorithm;
you do not have to devise a new one.
-
Write a program that reads an arbitrary amount of text
from a file or from the keyboard and reports how many
a's, b's, c's, d's, ... z's are in the text. The
program should ignore whether the letter is upper case
or lower case.
version 2 Modify the program so
the output lists the letters and the number of times
each appears in
frequency order: most frequent first, least frequent last.