Flipping Numbers

Flipping Numbers Problem from Irish collegiate programming contest