Project Euler — Problem 79 Solution

Problem

A com­mon secu­ri­ty method used for online bank­ing is to ask the user for three ran­dom char­ac­ters from a pass­code. For exam­ple, if the pass­code was 531278, they may ask for the 2nd, 3rd, and 5th char­ac­ters; the expect­ed reply would be: 317.

The text file, keylog.txt, con­tains fifty suc­cess­ful login attempts.

Giv­en that the three char­ac­ters are always asked for in order, analyse the file so as to deter­mine the short­est pos­si­ble secret pass­code of unknown length.

Solution

This prob­lem is actu­al­ly solved much eas­i­er by hand with pen and paper, but regard­less here’s a F# solu­tion to the prob­lem.