Idempotent partition around median of 5?
Xinok via Digitalmars-d
digitalmars-d at puremagic.com
Fri Feb 5 13:42:41 PST 2016
On Friday, 5 February 2016 at 15:13:56 UTC, tn wrote:
> On Thursday, 4 February 2016 at 20:30:57 UTC, Timon Gehr wrote:
>> At most 6 comparisons, <=3 swaps, idempotent (optimal number
>> of swaps):
>>
>> ...
>>
>
> Inspired by this, I made four other versions of the function
> that are shorter but make more swaps (at most 4, 6, 7 and 8
> swaps respectively). Each makes 6 comparisons and should be
> idempotent.
>
> http://dpaste.dzfl.pl/1c53d8f432f7
>
> ...
Very nice! I'm curious, to both you and Timon, how did you go
about writing these and coming up with the solutions? I'm not
sure if I could come up with these results myself and so quickly
at that.
More information about the Digitalmars-d
mailing list