in reply to How to generate test data?
Try this:
Update: Perhaps my answer wasn't so helpful to you as i intended, sorry.
You wrote: "At first, I want to begin by generating a test set for N integer numbers..."
So i just wanted to show a way to generate such a randomized test set. I hope very much that i didn't confuse you.
#!/usr/bin/perl use strict; use warnings; #...get a seed open(RANDOM, "<", "/dev/random") or die $!; read(RANDOM, $_, 4); close RANDOM; srand(unpack("L", $_)); #...do the shuffle my @k = ( 1..10 ); for ( my $i = @k ; --$i ; ) { my $j = int( rand( $i + 1 ) ); next if $i == $j; @k[ $i, $j ] = @k[ $j, $i ]; } print join( " ", @k) . qq(\n); #...and give your custom sort a chance
Regards, Karl
«The Crux of the Biscuit is the Apostrophe»
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to generate test data?
by abdullah.yildiz (Novice) on Nov 25, 2012 at 00:48 UTC | |
by roboticus (Chancellor) on Nov 25, 2012 at 02:33 UTC | |
by abdullah.yildiz (Novice) on Nov 25, 2012 at 11:48 UTC |