Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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 romping around the Monastery: (14)
As of 2014-10-22 08:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (114 votes), past polls