#! perl -slw use strict; use Data::Dumper; use List::Util qw[ reduce sum ]; use constant { MAXX => 100, MAXY => 100, }; sub calcSig { my $sum = reduce { $a->[ 0 ] += $b->[ 0 ] / MAXX; $a->[ 1 ] += $b->[ 1 ] / MAXY; $a; } [], @_; $sum->[ 0 ] /= @_; $sum->[ 1 ] /= @_; return int( $sum->[ 0 ] * MAXX * MAXY ) + $sum->[ 1 ] } my( @sigs, %sigs ); while( ) { chomp; my @points; push @points, [ $1, $2 ] while m[\((\d+?),(\d+?)\)(?:,\s|$)]g; # print Dumper \@points; push @sigs, my $sig = calcSig @points; $sigs{ $sig } = \@points; } @sigs = sort{ $a <=> $b } @sigs; printf "%9.5f => %s\n", $_, join ' ', map{ @$_ } @{ $sigs{ $_ } } for @sigs; print "\n ------ \n"; my @adjusted = map{ [ @$_ ] } values %sigs; for my $aref ( @adjusted ) { if( rand > .3 ) { ## delete a pair splice @$aref, rand( @$aref ), 1; } else { ## Adjust a few values; @$aref = map{ rand > .5 and $_->[ 0 ] += -10+int( rand 20 ); rand > .5 and $_->[ 1 ] += -10+int( rand 20 ); $_; } @$aref; } push @sigs, my $sig = calcSig @$aref; $sigs{ $sig } = $aref; } @sigs = sort{ $a <=> $b } @sigs; printf "%9.5f => %s\n", $_, join ' ', map{ @$_ } @{ $sigs{ $_ } } for @sigs; __DATA__ (67,66), (7,45), (77,19), (4,84), (74,53), (0,65), (37,12), (91,65), (84,36) (92,44), (27,30), (94,43), (51,96) (46,57), (45,2), (64,46), (46,1), (40,54) (84,26), (93,43), (11,80), (16,50), (66,80), (46,76) (92,32), (91,28), (80,76), (55,2) (94,40), (90,13), (57,36), (83,3) (13,69), (53,24), (61,90), (56,28), (61,82), (17,85), (12,59), (14,55) (33,44), (1,71), (35,71), (97,26), (39,78), (31,3), (32,65), (87,61) (70,26), (38,71), (78,36), (84,58), (84,5), (81,75) (70,98), (20,25), (79,19), (18,49), (48,78), (50,77), (40,53) (27,32), (54,19), (46,20), (38,93), (61,19), (9,53), (25,1) (43,83), (41,83), (16,69), (99,49), (22,60) (98,42), (79,0), (72,26), (95,11), (89,38) (67,0), (57,24), (46,50), (44,38) (76,20), (41,22), (93,64), (74,92) (82,24), (88,16), (49,9), (63,19), (84,77), (25,90), (48,11), (69,45), (30,88) (53,23), (72,95), (27,29), (94,59), (18,22), (89,33), (57,97), (63,95) (20,43), (25,36), (33,84), (63,11), (15,2), (70,69), (47,77), (67,91), (96,32) (59,55), (4,88), (74,63), (20,33), (28,34), (3,93), (9,19), (10,22), (42,44) (8,33), (21,55), (51,48), (6,20), (52,63) (72,27), (30,52), (37,35), (7,76), (23,45), (71,25), (75,17), (86,29), (95,30) (51,38), (31,65), (62,4), (37,35), (73,48) (98,33), (3,22), (75,40), (64,18), (91,67), (8,65), (29,68), (11,96) (45,32), (65,80), (58,22), (95,44), (51,36), (93,61), (76,94) (55,90), (88,6), (9,1), (56,45), (26,56) (26,21), (25,46), (46,14), (79,11), (85,39), (30,9) (37,18), (90,23), (38,13), (97,63), (17,26), (41,56), (22,85) (13,42), (79,34), (5,47), (25,20), (78,35), (59,75), (89,42), (0,26), (48,36) (60,73), (51,45), (95,63), (98,28) (91,84), (9,40), (13,98), (88,60), (17,83)