This is how algorithms work

It’s actually a pretty simple concept.