Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Is it possible to make reference to substrings and sort them?

by choroba (Cardinal)
on Mar 22, 2015 at 11:02 UTC ( [id://1120873]=note: print w/replies, xml ) Need Help??


in reply to Is it possible to make reference to substrings and sort them?

This is how I implemented BW for Rosalind.info:
my @suff = 0 .. length $string; pop @suff; @suff = sort { substr($string, $a) cmp substr $string, $b } @suff; for my $idx (@suff) { print substr $string, $idx - 1, 1; } print "\n";

Update: Now I noticed they mentioned O(|Text|) solution wasn't needed in the Note.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Is it possible to make reference to substrings and sort them?
by hdb (Monsignor) on Mar 22, 2015 at 12:06 UTC

    Your algorithm is somewhat different from the OP's in that you do not sort cyclic rotations at all, only the variable length endings of the text.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-18 01:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found