Solutions for the SPOJ competition at Bouvet.
Every user requires an account at SPOJ which is free. After signing up, one needs to choose a problem and to write a solution. All input is read from standard input, all results need to be written to standard output.
For Java, these streams are represented by System.in
and System.out
. Most programming languages are equivalent constructs. All solutions are represented by a single class in the default package called Main
with a default entry point as a public static void main(String[] args)
. The class can use the Java standard library but no external dependencies. It is the easiest (but not the fastest) to read from the stream by using a Scanner
on System.in
.
Every problem offers an example file. For testing purposes, it often makes sense to stor the sample input as a file on the local system. Then, System.in
can be easily replaced by new FileInputStream("somefile")
while testing. Before submitting a problem, the stream needs to be replaced by System.in
again.
SPOJ does not expose error messages in order to not allow backwards engineering of the actual data. Debugging can therefore be tricky. Read the description to find potential special cases that you did not cover. Consider tweaking the sample input data for special problem sizes (like zero).
Simply create a folder with your SPOJ account name within a folder named by the problem code. Put your solution into the folder with your name. This way, all solutions become browseable on GitHub such that we can discuss them afterwards. We can then lookup and find the results of your solutions on the SPOJ website. Do not look at other's solutions or googled solutions before you have solved a problem yourself. SPOJ is about thinking about a problem.