summaryrefslogblamecommitdiffstats
path: root/SUBS.rs
blob: 4b99a0e3d087f8a4399b7328b492c7c9cdb03e51 (plain) (tree)



















                                                                   
extern mod rosalind;
use rosalind::io::input_line;

fn substrings(haystack: &str, needle: &str) -> ~[uint] {
    let mut indices = ~[];
    do str::find_str(haystack, needle).while_some |start| {
        indices.push(start + 1);
        str::find_str_from(haystack, needle, start + 1)
    }
    indices
}

fn main() {
    let haystack = input_line();
    let needle   = input_line();

    let indices = substrings(haystack, needle);

    io::println(str::connect(indices.map(|i| fmt!("%u", *i)), " "))
}