Skip to content

Try optimizing fitness functions #4

@iKevinY

Description

@iKevinY

This might be faster as an explicit loop where the outgoing character is modulo'd off the accumulated index, the index is multiplied by 26, then the incoming character is added in.

ultra/src/fitness.rs

Lines 66 to 69 in 5ac5ef0

char_indices.windows(n)
.map(|w| w.iter().fold(0, |acc, x| 26 * acc + x))
.map(|i| ngrams[i])
.sum()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions