Coding challenge 3
So, the challenge this time is all around compression.Take a string, compress it into a byte[], record the size, decompress it.You can use any algorithm you chose, but it must be coded by you and not included from an external libraryI have defined an Interface ICompress as follows:public interface ICompressWe had 4 solutions submitted, and they were all of a really high standard. I tested them with 6 different input scenarios:
{
/// <summary>
/// Take a string and convert it into a byte[]
/// </summary>
/// <param name="source">The string to be converted</param>
/// <returns>The converted byte[]</returns>
byte[] Compress(string source); /// <summary>
/// Take the bytearray produced by the call to Compress, and decompress it
/// </summary>
/// <param name="compressedData">The data to be decompressed</param>
/// <returns>The string</returns>
string DeCompress(byte[] compressedData);
}I have provided a solution with the interface (Interface), a console app (CodingChallenge3) and an implementation of the interface (Compressor) (which just converts from string to byte[] and back again, no compression) on the development file share.The source string is provided through the app.config file of the CodingChallenge3 project (the console app).What do you need to submit?
- A Compressor project that I can plug in to the provided solution
- A couple of paragraphs explaining how your algorithm works
- The original provided sample - the text for "Mary had a little lamb"
- An empty string - which caused a few exceptions to be raised
- A single space
- A string of numbers
- The contents of war and peace
- The contents of the 3 musketeers in FrenchEach sample was run through each person's solution, and the most compressed result won that round. In the end, one person won 2 rounds (having implemented their own algorithm) and one won 4 rounds (having implemented 3 different methods and selected the one with the highest compression).This was based around Puzzle 16: Zip me up, Buttercup from the great resource Collection Of Puzzles For Programmers Previous coding challenges have been based loosely on LTD Puzzle 4: Finding Prime Numbers (which was Madgex coding challenge 1) and LTD Puzzle 3: ASCII Art Shapes (Madgex coding challenge 2).I'm delighted with how these are going, and the interest and general communication that they generate - lots of discussion, hints of secrecy, and comparisons between each other - and then lots of discussion once the results have been announced, and the code is available for scrutiny. So, I'm now busy thinking up ideas for Madgex Coding Challenge 4 - if anyone has any suggestions or resources for me to use, please pop them in the comments