Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try optimizing fitness functions #4

Open
iKevinY opened this issue Oct 19, 2021 · 0 comments
Open

Try optimizing fitness functions #4

iKevinY opened this issue Oct 19, 2021 · 0 comments

Comments

@iKevinY
Copy link
Owner

iKevinY commented Oct 19, 2021

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant