24 min problem

Description

This problem was given to the competitors 24 minutes before the end of the contest. We gave an input text which contained about 5000 words separated by single spaces. All the words contained only letters (a-z, A-Z). The task was to find a permutation of the words with as small MD5 checksum as possible. The team with the smallest MD5 hash got 24 points. The best one (submitted by UPC/UAM - Si es que va!) had 0000116e39a2a7fc31c89b9bdfa043c5 as its hash.

Solution

We made up the whole problem about 35 minutes before the end of the contest, so at the contest we didn't know any better algorithm than bruteforcing permutations and choosing the smallest one among them.

The text contained 18 different words with only 1 character, so one could permutate only these to get a higher speed. MD5 hash divides the text to blocks with 64-byte lengths. We wrote a solver which fixes almost full of the input and uses precomputed mediate values so only the end of the hashing has to be calculated every time. It can compute 1.5 million hash values per second on a AMD Phenom X4 9750+ (2400Mhz), but only using one core. It finds a solution starting with 6 zeros in about 10 seconds (for almost any random seed). It found the solution with 9 zeros in 5 hours running on 4 cores.