School of Computing

Self-test for programmers

Purpose of test

This self-test is intended for people who already have some experience of computer programming. Its purpose is to help you determine whether your programming skills are sufficient for the advanced stream in our MSc courses. If you complete the test successfully then the advanced stream is probably suitable for you (although this can't be guaranteed with a single test). If not, we recommend the introductory stream which requires no prior knowledge of programming.

Please note only the advanced stream is available for certain courses that relate directly to advanced programming and only the introductory stream is available for some joint courses administered by other schools. Please see the course web pages or handbooks for which modules are available for your course.

Important - this self-test is provided solely for your personal guidance. It is not part of the admissions requirements for any of our programmes or modules. You do not need to send us your solution.

Undertaking the test

The test must be completed:

  • without help from anyone else;
  • without help from anywhere else, such as the web, with the sole exception of a text book or similar reference on your chosen programming language;
  • without using high-level string manipulation APIs/libraries that already perform a large part of the processing required.

The example data given below can be used to verify your solution. You do not need to send it to us.

An experienced programmer should be able to develop a correct solution in less than one hour (including design, implementation, testing and debugging).  If it takes you more than two hours then the advanced stream may be unsuitable for you.  Please seek advice if you're unsure (see bottom of page for contact details).

The test

Write a computer program in a language of your choice that inputs one or more lines of text from the keyboard or a file and then outputs the text justified to a specified line length. The start and end of each line should be aligned neatly like in a word processor. The line length should be set/input when the programme is started.

For example, suppose the following text is input:

Once upon a time,
there were three chickens who wanted to
cross a very wide road. At first, they looked for a safe
place to cross, but could not find one.

After half an hour of looking, they gave up and went home.

If the line length is set at 25 characters, the correct output would be:

Once upon a  time,  there
were  three  chickens who
wanted  to  cross  a very
wide  road.   At   first,
they  looked  for  a safe
place to cross, but could
not find one.

After  half  an  hour  of
looking, they gave up and
went home.

Notes

  • The last line of each paragraph does not need to be stretched across the specified line length.
  • There should be no trailing spaces (i.e. after the last visible character on each line).
  • Punctuation is considered to be attached to any immediately preceding letters.
  • You may assume no single word will be longer than the specified line length.

[Test based on an exercise designed by David Barnes.]

Advice and support

If, having attempted the test, you are unsure whether the advanced stream is suitable please contact us for advice.

If you are unable to test your solution because you don't currently have access to a computer with the necessary programming language installed then we can take a look at your code to determine whether it's of the standard expected for entry to the advanced stream. In this case please email or post a printout of your source code.

Please note we are unable to assist students with the solution to this test as its purpose is to assess programming skills, not to teach them.

Students who have already started their postgraduate course at Kent should contact the appropriate course director (see course handbook for contact details).

Prospective applicants may email the School of Computing at computer-science@kent.ac.uk.

School of Computing, University of Kent, Canterbury, Kent, CT2 7NF

Enquiries: +44 (0)1227 824180 or contact us.

Last Updated: 12/04/2016