[BangPypers] golf problem

Pratap Chakravarthy prataprc at gmail.com
Mon Dec 26 13:04:47 CET 2011

> I don't like special casing stuff and the 3 selections outside the> "main" flow sticks out in my solution.
I guess that is right. Any logic that is outside the main flow breaks
the beauty
and create kludge.

Attempted to solve the same problem using Erlang, and surprisingly what was
looking like kludge in python perfectly blends with recursion and

Attached is the file. If you have erlang installed,

$ escript golf.erl  # To execute

A note on the source,
1. Only lines 6-14 are part of the golf permutation logic.
2. Function main() provides execution entry point.
3. Function ootygames() provides the sample data.
4. Function shuffle() is copy paste of Knuth / Fischer - Yates shuffle algorithm

And interestingly it takes just N+3 pass on the sample list (plus O(NlogN) for
shuffle()  ) ....


On Mon, Dec 26, 2011 at 4:32 PM, Noufal Ibrahim <noufal at gmail.com> wrote:
> Kenneth Gonsalves <lawgon at gmail.com> writes:
> [...]
>> just curious - why do you and Noufal think this is a crude method?
> --
> ~noufal
> http://nibrahim.net.in
> Parting is such sweet sorrow. -William Shakespeare
> _______________________________________________
> BangPypers mailing list
> BangPypers at python.org
> http://mail.python.org/mailman/listinfo/bangpypers


More information about the BangPypers mailing list