Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

RE: Generating a Pattern

by bastard (Hermit)
on Jul 29, 2000 at 02:01 UTC ( #25032=note: print w/ replies, xml ) Need Help??


in reply to Generating a Pattern

1-10, 500 reps = 1 secs ( 1.09 usr 0.00 sys = 1.09 cpu)
1-35, 10 reps = 17 secs (17.67 usr 0.02 sys = 17.69 cpu)

#!/usr/local/bin/perl use Benchmark; $t0 = new Benchmark; for (my $x = 0; $x < 500; $x++) { my $numb = 1; for (my $x = 0; $x < 10; $x++) { my @numb = split(//, $numb); my $count = 1; my $newnumb = ""; for(my $x = 1; $x <= length($numb); $x++) { if ($numb[$x-1] ne $numb[$x]) { $newnumb .= "$count$numb[$x-1]"; $count = 1; } else { $count++; } } $numb = $newnumb; } } $t1 = new Benchmark; $td = timediff($t1,$t0); print timestr($td), "\n";


Comment on RE: Generating a Pattern
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://25032]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (13)
As of 2015-07-02 09:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (33 votes), past polls