raspberry pi algorithm