in reply to JAPH - more obscure than obfuscated...
Here's a version which works for Perl version 5.8.0 i386-linux-thread-multi:
@i='058233660927207121220869229603962185544803008278'=~/.{8}/g; map{srand$i[$_];map{print chr(32+int(rand 59))}1..4}0..5;
And here is a program which finds the required seeds for whatever O/S one is currently using:
use strict; use warnings; my $b_show_almost = 1; # Show string which "almost" match? map { find_string($_) } ('JUST', ' ANO', 'THER', ' PER', 'L HA', 'CKER +'); sub find_string { my ($string) = @_; my $display = substr($string, 0, 3); # Indication of progress my $seed = 0; # Try all seed values my $result; # Result of rnd generation while (1) { $result = ""; srand $seed; map { $result .= sprintf "%s", chr(32 + int(rand 59))} (1..4); if ($result =~ /^$display/) { if ($result eq $string) { printf "Seed %08.8s => '$result' ** Success **\n", $s +eed; return; } if ($b_show_almost) { printf "Seed %08.8s => '$result'\n", $seed; } } ++$seed; } }
Update: Changed "unique" to "clever", after ambrus' observation below. Actually, his reference alludes to an even earlier version with a similar concept. Just goes to show that great minds think alike!
|
|---|