Search Members Help

» Welcome Guest
[ Log In :: Register ]

Mini-ITX Boards Sale, Fanless BareBones Mini-ITX, Bootable 1G DSL USBs, 533MHz Fanless PC <-- SALE $200 each!
Get The Official Damn Small Linux Book. DSL Market , Great VPS hosting provided by Tektonic
Pages: (13) </ ... 4 5 6 7 8 [9] 10 11 12 13 >/

[ Track this topic :: Email this topic :: Print this topic ]

reply to topic new topic new poll
Topic: C question, loops< Next Oldest | Next Newest >
WDef Offline





Group: Members
Posts: 798
Joined: Sep. 2005
Posted: Jan. 18 2008,17:11 QUOTE

if (($max ge 3) && ($result =~ /$c{3}$/)) {

should have been (I think)

if (($max >= 3) && ($result =~ /$c{3,}$/)) {

[EDIT:  classic mistake confusing string and numeric comparisons ]

If that didn't work would have applied a regex somewhere like:

=~ /(.)\1\1/

which would match any string containing 3 or more identical adjacent chars.

You might notice the similarity to sed syntax.  Perl regex's are much easier and more intuitive and you do a lot less escaping of backslashes and brackets and other hassles.
Back to top
Profile PM 
curaga Offline





Group: Members
Posts: 2163
Joined: Feb. 2007
Posted: Jan. 18 2008,17:24 QUOTE

Is the new algorithm guaranteed to try every combination?

--------------
There's no such thing as life. Those mean little jocks invented it ;)
-
Windows is not a virus. A virus does something!
Back to top
Profile PM 
WDef Offline





Group: Members
Posts: 798
Joined: Sep. 2005
Posted: Jan. 18 2008,17:31 QUOTE

AKAIK - it's taken from the Algorithm::Permute man page, basically just put in a loop to do all string lengths between 1 and the number of elements in @set.

There's also benchmarks on the man page comparing speeds to other implementations.

There may possibly be a faster way of using the module via the callback interface but I'll have to think and maybe post somewhere about that. [ EDIT I doubt it .  The callback thing won't take a perm length argument,  and the man page warns against trying to change the array mid execution.  ]

EDIT:  I've updated the above to allow for setting desired string length ranges.
Back to top
Profile PM 
WDef Offline





Group: Members
Posts: 798
Joined: Sep. 2005
Posted: Jan. 20 2008,12:26 QUOTE

Yesterday I had a crack at a version using threads, but there were segfaults - I think Algorithm::Permute is probably not thread-safe.  Googling reveals this is likely since (a) any module that does not explicitly state it is thread-safe should be assumed not to be, and (b) it's written in XS code and XS code modules are less likely to be thread-safe.

Anyway I have some other improvements in mind for speed increases.
Back to top
Profile PM 
curaga Offline





Group: Members
Posts: 2163
Joined: Feb. 2007
Posted: Jan. 29 2008,18:32 QUOTE

The smaller ones have run through - aka all under 7 chars. That proved my pass isn't 7 chars or less. Oh well.

Then I did a quick reschedule - new dial is:
8-9, 10-11, 12-13, 14-15, 16-17, 18-19, 20-21, 22-23; that is, one process goes through two lengths, instead of one going from 8 to 23. These are all running on the main lappy - load averages have floated above 15 for some time now :D

I haven't yet applied the fix for adjacent chars, maybe I should have? Haven't had time.


--------------
There's no such thing as life. Those mean little jocks invented it ;)
-
Windows is not a virus. A virus does something!
Back to top
Profile PM 
64 replies since Jan. 12 2008,13:35 < Next Oldest | Next Newest >

[ Track this topic :: Email this topic :: Print this topic ]

Pages: (13) </ ... 4 5 6 7 8 [9] 10 11 12 13 >/
reply to topic new topic new poll
Quick Reply: C question

Do you wish to enable your signature for this post?
Do you wish to enable emoticons for this post?
Track this topic
View All Emoticons
View iB Code