Re: can this code be improved



On Thu, 17 Aug 2006 06:15:51 +0100, Patricia Shanahan <pats@xxxxxxx> wrote:
Why not run Fisher-Yates for 6 iterations, and then pick up the
first 6 elements of the array?

OK, but if you are going to generate 6 random numbers between 1 and 49 in order to decide which elements to swap, why not just use those random numbers as your selected lottery numbers?

Dan.

--
Daniel Dyer
http://www.dandyer.co.uk
.



Relevant Pages

  • Re: can this code be improved
    ... Daniel Dyer wrote: ... first 6 elements of the array? ... in order to decide which elements to swap, why not just use those random numbers as your selected lottery numbers? ...
    (comp.lang.java.programmer)
  • Re: can this code be improved
    ... first 6 elements of the array? ... in order to decide which elements to swap, why not just use those random numbers as your selected lottery numbers? ... Daniel Dyer ...
    (comp.lang.java.programmer)
  • Re: Constant array
    ... But I can't quite figure out how to make an array of constants without ... DOES> SWAP CELLS + @ EXECUTE; ...
    (comp.lang.forth)
  • Re: "Sorting" assignment
    ... you think using memcpy a block at a time is not the best way to swap ... trouble now or later. ... It does not bother to zero the array (you'd need a clever optimiser ... void memswap(char *ptrToA, char *ptrToB, int intLength) ...
    (comp.programming)
  • Re: Constant array
    ... But I can't quite figure out how to make an array of constants without ... here cell- swap! ... swap 1+ cells over + ... xtarray xa xtlist[dup swap drop]xtlist ...
    (comp.lang.forth)