An interesting algorithm implementation