h algorithm (2)
h algorithm (2)
The Hyve
April 30, 2018
1 General Instructions
This document describes a programming assignment with a simple algorithmic and
I/O component.
You should have received a preparatory text a week or so before starting this
assignment, with some general hints on doing binary input/output and reading and
writing data to and from standard input and output. This assignment will assume
you are familiar with these terms and you know how to use these features.
The assignment is designed to be completed in 3 hours, though an extension
of 1 hour can be granted on request from the applicant. Writing the algorithm
component should be possible in well under this time. However, it is expected that
the code be well-structured, minimally documented and unit tested. Time allowing,
integration or functional tests would be regarded favorably. The objective here is
not to create an “enterprise” Hello World program full of design patterns [1], yet a
straightforward, purely procedural implementation with no abstractions would fall
short of the target of this assignment.
Any programming language is acceptable, provided that the program uses the
object oriented paradigm, in particular polymorphism.
The program can be distributed in any way the applicant wants. It is suggested
that the code be pushed to a public git server (e.g. one on Github or Bitbucket),
but this is not a requirement. Binaries are not necessary; in case a scripting
language is not used, the applicant should include simple instructions on how to
compile the supplied program.
1
These pairs come in two forms; each pair can either be in the form (pi = 0, qi = c),
where c is any byte value, or it can be composed of two positive integers such
that 0 < qi ≤ pi (with i = 0, . . . , n − 1). In the first case, the pair represents
exactly one decoded byte (the value of qi ). In the other, the pair represents the
sequence obtained by taking qi bytes starting from an offset of pi bytes behind in
the decoded stream (see below).
(0, 61), (1, 1), (0, 62), (3, 2), (3, 3) (2)
2
The program should default to the latter and only switch to the first one if
the environment variable USE_TRIVIAL_IMPLEMENTATION has value 1.
It is left undefined how much data the program should buffer before decoding
or re-encoding data.
3 Closing
You are expected to write a simple command line program that does the required
I/O and implements the described algorithms. If you have insufficient time to finish
the solution, please try to focus on the algorithms first. If you have time left, don’t
forget to add some minimal documentation and unit tests or other automatic tests.
References
[1] Taskinoor Hasan. “The Abuse of Design Patterns in Writing a Hello World
Program.” Internet: http://taskinoor.wordpress.com/2011/09/21/
the-abuse-of-design-patterns-in-writing-a-hello-world-program/.
Sept. 21 2011 [Aug. 29, 2013]