Jump to content

pmcgee

Members
  • Content Count

    52
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by pmcgee

  1. I came across this trying to duplicate C++'s std::next_permutation using Delphi. I went through various modifications, and had left a string declaration in where it was no longer needed: procedure reverse(var s:AnsiString; const a,x:word); inline; var i,j : word; //t : string; begin // x is one past the end of string if a = x-1 then exit; j := ( x-a ) shr 1; // trunc((x-a)/2); for i := 1 to j do swapCh( s[a-1+i] , s[x-i] ); end; All permutations of 12 chars = 479,001,600. C++ = 2s. Commenting out the string reduced the Delphi code from 9s to 6s. (I haven't been back to it since then.)
×