Liar, Liar

Overview

“Liar, Liar” is the name of the first of the Puzzles available from the Facebook Puzzles page. It is a sorting exercise which simply asks the developer write a script/program to sort a list of forum members into two groups based on whether they are lying or telling the truth, and then return the number of members in each group. The full specification of the puzzle can be found here.

Technical Details

My solution has been written in C++, making use of the STL set, map and vector objects to separate the names into two separate lists. The full source code is available from the downloads list on the right, including a makefile for you to compile it in a Unix environment with the g++ compiler.

Results

The first version that was judged (v1) ran with a time of 733.071ms. Version 2 that was uploaded later used a greatly improved file loading algorithm, and successfully ran in 387.809ms, almost twice as fast.

Licencing

All solutions provided are licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.